Add gender indicator
This commit is contained in:
parent
4635808873
commit
987697e6c7
|
@ -25,13 +25,13 @@
|
||||||
- Battle info
|
- Battle info
|
||||||
- Owned icon
|
- Owned icon
|
||||||
- Status effect indicator
|
- Status effect indicator
|
||||||
- Gender icon
|
|
||||||
- Evolution
|
- Evolution
|
||||||
- Evolution screen
|
- Evolution screen
|
||||||
- Background (ripped video?)
|
- Background (ripped video?)
|
||||||
- Particles
|
- Particles
|
||||||
- Modifiers
|
- Modifiers
|
||||||
- PP Up
|
- PP Up
|
||||||
|
- Ether/elixir
|
||||||
- Type enhancers
|
- Type enhancers
|
||||||
- Evolution items
|
- Evolution items
|
||||||
- Various mainline game items for various enhancements
|
- 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 |
|
@ -1,6 +1,8 @@
|
||||||
import { default as Pokemon } from './pokemon';
|
import { default as Pokemon } from './pokemon';
|
||||||
import { getLevelTotalExp, getLevelRelExp } from './exp';
|
import { getLevelTotalExp, getLevelRelExp } from './exp';
|
||||||
import * as Utils from './utils';
|
import * as Utils from './utils';
|
||||||
|
import { addTextObject, TextStyle } from './text';
|
||||||
|
import { getGenderSymbol, getGenderColor } from './gender';
|
||||||
|
|
||||||
export default class BattleInfo extends Phaser.GameObjects.Container {
|
export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
private player: boolean;
|
private player: boolean;
|
||||||
|
@ -13,6 +15,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
private lastName: string;
|
private lastName: string;
|
||||||
|
|
||||||
private nameText: Phaser.GameObjects.Text;
|
private nameText: Phaser.GameObjects.Text;
|
||||||
|
private genderText: Phaser.GameObjects.Text;
|
||||||
private levelContainer: Phaser.GameObjects.Container;
|
private levelContainer: Phaser.GameObjects.Container;
|
||||||
private hpBar: Phaser.GameObjects.Image;
|
private hpBar: Phaser.GameObjects.Image;
|
||||||
private levelNumbersContainer: Phaser.GameObjects.Container;
|
private levelNumbersContainer: Phaser.GameObjects.Container;
|
||||||
|
@ -37,41 +40,31 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
box.setOrigin(1, 0.5);
|
box.setOrigin(1, 0.5);
|
||||||
this.add(box);
|
this.add(box);
|
||||||
|
|
||||||
const nameText = this.scene.add.text(player ? -115 : -124, player ? -15.2 : -11.2, '', {
|
this.nameText = addTextObject(this.scene, player ? -115 : -124, player ? -15.2 : -11.2, '', TextStyle.BATTLE_INFO);
|
||||||
color: '#404040',
|
this.nameText.setOrigin(0, 0);
|
||||||
font: '72px emerald'
|
this.add(this.nameText);
|
||||||
});
|
|
||||||
nameText.setShadow(4, 4, '#ded6b5');
|
|
||||||
nameText.setOrigin(0, 0);
|
|
||||||
nameText.setScale(0.1666666667);
|
|
||||||
this.add(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.levelContainer = this.scene.add.container(player ? -41 : -50, player ? -10 : -5);
|
||||||
this.add(levelContainer);
|
this.add(this.levelContainer);
|
||||||
|
|
||||||
this.levelContainer = levelContainer;
|
|
||||||
|
|
||||||
const levelOverlay = this.scene.add.image(0, 0, 'overlay_lv');
|
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');
|
this.hpBar = this.scene.add.image(player ? -61 : -71, player ? -1 : 4.5, 'overlay_hp');
|
||||||
hpBar.setOrigin(0);
|
this.hpBar.setOrigin(0);
|
||||||
this.add(hpBar);
|
this.add(this.hpBar);
|
||||||
|
|
||||||
this.hpBar = hpBar;
|
this.levelNumbersContainer = this.scene.add.container(9.5, 0);
|
||||||
|
this.levelContainer.add(this.levelNumbersContainer);
|
||||||
const levelNumbersContainer = this.scene.add.container(9.5, 0);
|
|
||||||
levelContainer.add(levelNumbersContainer);
|
|
||||||
|
|
||||||
this.levelNumbersContainer = levelNumbersContainer;
|
|
||||||
|
|
||||||
if (this.player) {
|
if (this.player) {
|
||||||
const hpNumbersContainer = this.scene.add.container(-15, 10);
|
this.hpNumbersContainer = this.scene.add.container(-15, 10);
|
||||||
this.add(hpNumbersContainer);
|
this.add(this.hpNumbersContainer);
|
||||||
|
|
||||||
this.hpNumbersContainer = hpNumbersContainer;
|
|
||||||
|
|
||||||
const expBar = this.scene.add.image(-98, 18, 'overlay_exp');
|
const expBar = this.scene.add.image(-98, 18, 'overlay_exp');
|
||||||
expBar.setOrigin(0);
|
expBar.setOrigin(0);
|
||||||
|
@ -84,7 +77,14 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
|
|
||||||
initInfo(pokemon: Pokemon) {
|
initInfo(pokemon: Pokemon) {
|
||||||
this.nameText.setText(pokemon.name);
|
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);
|
this.hpBar.setScale(pokemon.getHpRatio(), 1);
|
||||||
if (this.player)
|
if (this.player)
|
||||||
|
@ -107,11 +107,6 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
|
||||||
if (!this.scene)
|
if (!this.scene)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.lastName !== pokemon.species.name) {
|
|
||||||
this.nameText.setText(pokemon.name);
|
|
||||||
this.lastName = pokemon.species.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
const updatePokemonHp = () => {
|
const updatePokemonHp = () => {
|
||||||
const duration = Utils.clampInt(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000);
|
const duration = Utils.clampInt(Math.abs((this.lastHp) - pokemon.hp) * 5, 250, 5000);
|
||||||
this.scene.tweens.add({
|
this.scene.tweens.add({
|
||||||
|
|
|
@ -247,10 +247,7 @@ export class SummonPhase extends BattlePhase {
|
||||||
onComplete: () => {
|
onComplete: () => {
|
||||||
playerPokemon.cry();
|
playerPokemon.cry();
|
||||||
playerPokemon.getSprite().clearTint();
|
playerPokemon.getSprite().clearTint();
|
||||||
this.scene.time.delayedCall(1000, () => {
|
this.scene.time.delayedCall(1000, () => this.end());
|
||||||
this.scene.currentBattle.addParticipant(playerPokemon);
|
|
||||||
this.end();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -326,13 +323,7 @@ export class CheckSwitchPhase extends BattlePhase {
|
||||||
super.start();
|
super.start();
|
||||||
|
|
||||||
this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => {
|
this.scene.ui.showText('Will you switch\nPOKéMON?', null, () => {
|
||||||
this.scene.ui.setMode(Mode.SWITCH_CHECK, () => {
|
this.scene.ui.setMode(Mode.SWITCH_CHECK, () => this.end());
|
||||||
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();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,6 +339,8 @@ export class CommandPhase extends BattlePhase {
|
||||||
//interp(this.scene);
|
//interp(this.scene);
|
||||||
|
|
||||||
this.scene.ui.setMode(Mode.COMMAND);
|
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{
|
handleCommand(command: Command, cursor: integer): boolean{
|
||||||
|
|
|
@ -103,6 +103,7 @@ export default class BattleScene extends Phaser.Scene {
|
||||||
this.loadImage('pbinfo_enemy', 'ui');
|
this.loadImage('pbinfo_enemy', 'ui');
|
||||||
this.loadImage('overlay_lv', 'ui');
|
this.loadImage('overlay_lv', 'ui');
|
||||||
this.loadAtlas('numbers', 'ui');
|
this.loadAtlas('numbers', 'ui');
|
||||||
|
this.loadAtlas('gender', 'ui');
|
||||||
this.loadAtlas('overlay_hp', 'ui');
|
this.loadAtlas('overlay_hp', 'ui');
|
||||||
this.loadImage('overlay_exp', 'ui');
|
this.loadImage('overlay_exp', 'ui');
|
||||||
this.loadImage('level_up_stats', 'ui');
|
this.loadImage('level_up_stats', 'ui');
|
||||||
|
|
|
@ -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';
|
||||||
|
}
|
|
@ -18,8 +18,8 @@ export default class PokemonSpecies {
|
||||||
public legendary: boolean;
|
public legendary: boolean;
|
||||||
public mythical: boolean;
|
public mythical: boolean;
|
||||||
public species: string;
|
public species: string;
|
||||||
public type1: integer;
|
public type1: Type;
|
||||||
public type2: integer;
|
public type2: Type;
|
||||||
public height: number;
|
public height: number;
|
||||||
public weight: number;
|
public weight: number;
|
||||||
public ability1: string;
|
public ability1: string;
|
||||||
|
|
|
@ -10,7 +10,7 @@ export enum Stat {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getStatName(stat: Stat) {
|
export function getStatName(stat: Stat) {
|
||||||
let ret;
|
let ret: string;
|
||||||
switch (stat) {
|
switch (stat) {
|
||||||
case Stat.HP:
|
case Stat.HP:
|
||||||
ret = 'Max. HP';
|
ret = 'Max. HP';
|
||||||
|
|
|
@ -9,8 +9,9 @@ import * as Utils from './utils';
|
||||||
import { getTypeDamageMultiplier } from './type';
|
import { getTypeDamageMultiplier } from './type';
|
||||||
import { getLevelTotalExp } from './exp';
|
import { getLevelTotalExp } from './exp';
|
||||||
import { Stat } from './pokemon-stat';
|
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 { PokeballType } from './pokeball';
|
||||||
|
import { Gender } from './gender';
|
||||||
|
|
||||||
export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
public id: integer;
|
public id: integer;
|
||||||
|
@ -22,7 +23,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container {
|
||||||
public level: integer;
|
public level: integer;
|
||||||
public exp: integer;
|
public exp: integer;
|
||||||
public levelExp: integer;
|
public levelExp: integer;
|
||||||
public gender: integer;
|
public gender: Gender;
|
||||||
public hp: integer;
|
public hp: integer;
|
||||||
public stats: integer[];
|
public stats: integer[];
|
||||||
public ivs: 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));
|
//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)
|
if (this.species.malePercent === null)
|
||||||
this.gender = -1;
|
this.gender = Gender.GENDERLESS;
|
||||||
else {
|
else {
|
||||||
const genderChance = (this.id % 256) / 32;
|
const genderChance = (this.id % 256) * 0.390625;
|
||||||
if (genderChance < this.species.malePercent)
|
if (genderChance < this.species.malePercent)
|
||||||
this.gender = 0;
|
this.gender = Gender.MALE;
|
||||||
else
|
else
|
||||||
this.gender = 1;
|
this.gender = Gender.FEMALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16));
|
const rand1 = Utils.binToDec(Utils.decToBin(this.id).substring(0, 16));
|
||||||
|
|
13
src/text.ts
13
src/text.ts
|
@ -1,12 +1,14 @@
|
||||||
export enum TextStyle {
|
export enum TextStyle {
|
||||||
MESSAGE,
|
MESSAGE,
|
||||||
WINDOW,
|
WINDOW,
|
||||||
|
BATTLE_INFO,
|
||||||
PARTY
|
PARTY
|
||||||
};
|
};
|
||||||
|
|
||||||
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) {
|
export function addTextObject(scene: Phaser.Scene, x: number, y: number, content: string, style: TextStyle, extraStyleOptions?: Phaser.Types.GameObjects.Text.TextStyle) {
|
||||||
let styleOptions;
|
let styleOptions;
|
||||||
let shadowColor;
|
let shadowColor;
|
||||||
|
let shadowSize = 6;
|
||||||
|
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case TextStyle.WINDOW:
|
case TextStyle.WINDOW:
|
||||||
|
@ -31,6 +33,15 @@ export function addTextObject(scene: Phaser.Scene, x: number, y: number, content
|
||||||
};
|
};
|
||||||
shadowColor = '#6b5a73';
|
shadowColor = '#6b5a73';
|
||||||
break;
|
break;
|
||||||
|
case TextStyle.BATTLE_INFO:
|
||||||
|
styleOptions = {
|
||||||
|
fontFamily: 'emerald',
|
||||||
|
fontSize: '72px',
|
||||||
|
color: '#404040'
|
||||||
|
};
|
||||||
|
shadowColor = '#ded6b5';
|
||||||
|
shadowSize = 4;
|
||||||
|
break;
|
||||||
case TextStyle.PARTY:
|
case TextStyle.PARTY:
|
||||||
styleOptions = {
|
styleOptions = {
|
||||||
fontFamily: 'pkmnems',
|
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);
|
const ret = scene.add.text(x, y, content, styleOptions);
|
||||||
ret.setScale(0.1666666667);
|
ret.setScale(0.1666666667);
|
||||||
ret.setShadow(6, 6, shadowColor);
|
ret.setShadow(shadowSize, shadowSize, shadowColor);
|
||||||
ret.setLineSpacing(5);
|
ret.setLineSpacing(5);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -61,7 +61,7 @@ export default class SwitchCheckUiHandler extends AwaitableUiHandler {
|
||||||
if (keyCode === keyCodes.Z || keyCode === keyCodes.X) {
|
if (keyCode === keyCodes.Z || keyCode === keyCodes.X) {
|
||||||
success = true;
|
success = true;
|
||||||
if (keyCode === keyCodes.X)
|
if (keyCode === keyCodes.X)
|
||||||
this.cursor = 1;
|
this.setCursor(1);
|
||||||
if (this.onActionInput) {
|
if (this.onActionInput) {
|
||||||
if (!this.cursor)
|
if (!this.cursor)
|
||||||
this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true));
|
this.scene.unshiftPhase(new SwitchPhase(this.scene, false, true));
|
||||||
|
@ -88,7 +88,6 @@ export default class SwitchCheckUiHandler extends AwaitableUiHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
setCursor(cursor: integer): boolean {
|
setCursor(cursor: integer): boolean {
|
||||||
const ui = this.getUi();
|
|
||||||
const ret = super.setCursor(cursor);
|
const ret = super.setCursor(cursor);
|
||||||
|
|
||||||
if (!this.cursorObj) {
|
if (!this.cursorObj) {
|
||||||
|
|
Loading…
Reference in New Issue