Add gender indicator

This commit is contained in:
Flashfyre 2023-04-01 20:06:44 -04:00
parent 4635808873
commit 987697e6c7
13 changed files with 82 additions and 57 deletions

View File

@ -25,13 +25,13 @@
- Battle info
- Owned icon
- Status effect indicator
- Gender icon
- Evolution
- Evolution screen
- Background (ripped video?)
- Particles
- Modifiers
- PP Up
- Ether/elixir
- Type enhancers
- Evolution items
- Various mainline game items for various enhancements

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1,6 +1,8 @@
import { default as Pokemon } from './pokemon';
import { getLevelTotalExp, getLevelRelExp } from './exp';
import * as Utils from './utils';
import { addTextObject, TextStyle } from './text';
import { getGenderSymbol, getGenderColor } from './gender';
export default class BattleInfo extends Phaser.GameObjects.Container {
private player: boolean;
@ -13,6 +15,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
private lastName: string;
private nameText: Phaser.GameObjects.Text;
private genderText: Phaser.GameObjects.Text;
private levelContainer: Phaser.GameObjects.Container;
private hpBar: Phaser.GameObjects.Image;
private levelNumbersContainer: Phaser.GameObjects.Container;
@ -37,41 +40,31 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
box.setOrigin(1, 0.5);
this.add(box);
const nameText = this.scene.add.text(player ? -115 : -124, player ? -15.2 : -11.2, '', {
color: '#404040',
font: '72px emerald'
});
nameText.setShadow(4, 4, '#ded6b5');
nameText.setOrigin(0, 0);
nameText.setScale(0.1666666667);
this.add(nameText);
this.nameText = addTextObject(this.scene, player ? -115 : -124, player ? -15.2 : -11.2, '', TextStyle.BATTLE_INFO);
this.nameText.setOrigin(0, 0);
this.add(this.nameText);
this.nameText = nameText;
this.genderText = addTextObject(this.scene, 0, 0, '', TextStyle.BATTLE_INFO);
this.genderText.setOrigin(0, 0);
this.genderText.setPositionRelative(this.nameText, 0, 2);
this.add(this.genderText);
const levelContainer = this.scene.add.container(player ? -41 : -50, player ? -10 : -5);
this.add(levelContainer);
this.levelContainer = levelContainer;
this.levelContainer = this.scene.add.container(player ? -41 : -50, player ? -10 : -5);
this.add(this.levelContainer);
const levelOverlay = this.scene.add.image(0, 0, 'overlay_lv');
levelContainer.add(levelOverlay);
this.levelContainer.add(levelOverlay);
const hpBar = this.scene.add.image(player ? -61 : -71, player ? -1 : 4.5, 'overlay_hp');
hpBar.setOrigin(0);
this.add(hpBar);
this.hpBar = this.scene.add.image(player ? -61 : -71, player ? -1 : 4.5, 'overlay_hp');
this.hpBar.setOrigin(0);
this.add(this.hpBar);
this.hpBar = hpBar;
const levelNumbersContainer = this.scene.add.container(9.5, 0);
levelContainer.add(levelNumbersContainer);
this.levelNumbersContainer = levelNumbersContainer;
this.levelNumbersContainer = this.scene.add.container(9.5, 0);
this.levelContainer.add(this.levelNumbersContainer);
if (this.player) {
const hpNumbersContainer = this.scene.add.container(-15, 10);
this.add(hpNumbersContainer);
this.hpNumbersContainer = hpNumbersContainer;
this.hpNumbersContainer = this.scene.add.container(-15, 10);
this.add(this.hpNumbersContainer);
const expBar = this.scene.add.image(-98, 18, 'overlay_exp');
expBar.setOrigin(0);
@ -84,7 +77,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
initInfo(pokemon: Pokemon) {
this.nameText.setText(pokemon.name);
this.lastName = pokemon.species.name;
const nameSizeTest = addTextObject(this.scene, 0, 0, pokemon.name, TextStyle.BATTLE_INFO);
const nameTextWidth = nameSizeTest.displayWidth;
nameSizeTest.destroy();
this.genderText.setText(getGenderSymbol(pokemon.gender));
this.genderText.setColor(getGenderColor(pokemon.gender));
this.genderText.setPositionRelative(this.nameText, nameTextWidth, 0);
this.hpBar.setScale(pokemon.getHpRatio(), 1);
if (this.player)
@ -107,11 +107,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
if (!this.scene)
return;
if (this.lastName !== pokemon.species.name) {
this.nameText.setText(pokemon.name);
this.lastName = pokemon.species.name;
}
const updatePokemonHp = () => {
const duration = Utils.clampInt(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000);
this.scene.tweens.add({

View File

@ -247,10 +247,7 @@ export class SummonPhase extends BattlePhase {
onComplete: () => {
playerPokemon.cry();
playerPokemon.getSprite().clearTint();
this.scene.time.delayedCall(1000, () => {
this.scene.currentBattle.addParticipant(playerPokemon);
this.end();
});
this.scene.time.delayedCall(1000, () => this.end());
}
});
}
@ -326,13 +323,7 @@ export class CheckSwitchPhase extends BattlePhase {
super.start();
this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => {
this.scene.ui.setMode(Mode.SWITCH_CHECK, () => {
console.log('handler', this.scene.ui.getHandler());
console.log(this.scene.ui.getHandler().getCursor())
if (this.scene.ui.getHandler().getCursor())
this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon());
this.end();
});
this.scene.ui.setMode(Mode.SWITCH_CHECK, () => this.end());
});
}
}
@ -348,6 +339,8 @@ export class CommandPhase extends BattlePhase {
//interp(this.scene);
this.scene.ui.setMode(Mode.COMMAND);
console.log('add participant', this.scene.getPlayerPokemon().name)
this.scene.currentBattle.addParticipant(this.scene.getPlayerPokemon());
}
handleCommand(command: Command, cursor: integer): boolean{

View File

@ -103,6 +103,7 @@ export default class BattleScene extends Phaser.Scene {
this.loadImage('pbinfo_enemy', 'ui');
this.loadImage('overlay_lv', 'ui');
this.loadAtlas('numbers', 'ui');
this.loadAtlas('gender', 'ui');
this.loadAtlas('overlay_hp', 'ui');
this.loadImage('overlay_exp', 'ui');
this.loadImage('level_up_stats', 'ui');

25
src/gender.ts Normal file
View File

@ -0,0 +1,25 @@
export enum Gender {
GENDERLESS = -1,
FEMALE,
MALE
}
export function getGenderSymbol(gender: Gender) {
switch (gender) {
case Gender.MALE:
return '♂';
case Gender.FEMALE:
return '♀';
}
return '';
}
export function getGenderColor(gender: Gender) {
switch (gender) {
case Gender.MALE:
return '#40c8f8';
case Gender.FEMALE:
return '#f89890';
}
return '#ffffff';
}

View File

@ -18,8 +18,8 @@ export default class PokemonSpecies {
public legendary: boolean;
public mythical: boolean;
public species: string;
public type1: integer;
public type2: integer;
public type1: Type;
public type2: Type;
public height: number;
public weight: number;
public ability1: string;

View File

@ -10,7 +10,7 @@ export enum Stat {
};
export function getStatName(stat: Stat) {
let ret;
let ret: string;
switch (stat) {
case Stat.HP:
ret = 'Max. HP';

View File

@ -9,8 +9,9 @@ import * as Utils from './utils';
import { getTypeDamageMultiplier } from './type';
import { getLevelTotalExp } from './exp';
import { Stat } from './pokemon-stat';
import { ExpShareModifier, PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoosterModifier } from './modifier';
import { PokemonBaseStatModifier as PokemonBaseStatBoosterModifier, ShinyRateBoosterModifier } from './modifier';
import { PokeballType } from './pokeball';
import { Gender } from './gender';
export default abstract class Pokemon extends Phaser.GameObjects.Container {
public id: integer;
@ -22,7 +23,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
public level: integer;
public exp: integer;
public levelExp: integer;
public gender: integer;
public gender: Gender;
public hp: integer;
public stats: integer[];
public ivs: integer[];
@ -67,13 +68,13 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
//this.id = parseInt(Utils.decToBin(this.ivs[Stat.HP]) + Utils.decToBin(this.ivs[Stat.ATK]) + Utils.decToBin(this.ivs[Stat.DEF]) + Utils.decToBin(this.ivs[Stat.SPATK]) + Utils.decToBin(this.ivs[Stat.SPDEF]) + Utils.decToBin(this.ivs[Stat.SPD]) + this.id.toString(2).slice(30));
if (this.species.malePercent === null)
this.gender = -1;
this.gender = Gender.GENDERLESS;
else {
const genderChance = (this.id % 256) / 32;
const genderChance = (this.id % 256) * 0.390625;
if (genderChance < this.species.malePercent)
this.gender = 0;
this.gender = Gender.MALE;
else
this.gender = 1;
this.gender = Gender.FEMALE;
}
const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16));

View File

@ -1,12 +1,14 @@
export enum TextStyle {
MESSAGE,
WINDOW,
BATTLE_INFO,
PARTY
};
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) {
let styleOptions;
let shadowColor;
let shadowSize = 6;
switch (style) {
case TextStyle.WINDOW:
@ -31,6 +33,15 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content
};
shadowColor = '#6b5a73';
break;
case TextStyle.BATTLE_INFO:
styleOptions = {
fontFamily: 'emerald',
fontSize: '72px',
color: '#404040'
};
shadowColor = '#ded6b5';
shadowSize = 4;
break;
case TextStyle.PARTY:
styleOptions = {
fontFamily: 'pkmnems',
@ -49,7 +60,7 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content
const ret = scene.add.text(x, y, content, styleOptions);
ret.setScale(0.1666666667);
ret.setShadow(6, 6, shadowColor);
ret.setShadow(shadowSize, shadowSize, shadowColor);
ret.setLineSpacing(5);
return ret;

View File

@ -61,7 +61,7 @@ export default class SwitchCheckUiHandler extends AwaitableUiHandler {
if (keyCode === keyCodes.Z || keyCode === keyCodes.X) {
success = true;
if (keyCode === keyCodes.X)
this.cursor = 1;
this.setCursor(1);
if (this.onActionInput) {
if (!this.cursor)
this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true));
@ -88,7 +88,6 @@ export default class SwitchCheckUiHandler extends AwaitableUiHandler {
}
setCursor(cursor: integer): boolean {
const ui = this.getUi();
const ret = super.setCursor(cursor);
if (!this.cursorObj) {