Add gen 6-7 sprites and update icon set

This commit is contained in:
Flashfyre committed 2023-12-07 00:52:20 -05:00
1 parent 0e366986b5
commit b7687a9a30
4574 files changed
+90979 -517496

No files matched your search

+1 -1
View File
@@ -40,7 +40,7 @@ export default class PartyExpBar extends Phaser.GameObjects.Container {
return resolve();
this.pokemonIcon.setTexture(pokemon.getIconAtlasKey());
this.pokemonIcon.play(pokemon.getIconKey()).stop();
this.pokemonIcon.setFrame(pokemon.getIconId());
this.expText.setText(`+${expValue.toString()}`);
this.bg.width = this.expText.displayWidth + 28;
+19 -10
View File
@@ -10,6 +10,7 @@ import { PokemonHeldItemModifier, SwitchEffectTransferModifier } from "../modifi
import { Moves, allMoves } from "../data/move";
import { getGenderColor, getGenderSymbol } from "../data/gender";
import { StatusEffect } from "../data/status-effect";
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
const defaultMessage = 'Choose a Pokémon.';
@@ -81,6 +82,8 @@ export default class PartyUiHandler extends MessageUiHandler {
private moveSelectFilter: PokemonMoveSelectFilter;
private tmMoveId: Moves;
private iconAnimHandler: PokemonIconAnimHandler;
private static FilterAll = (_pokemon: PlayerPokemon) => null;
public static FilterNonFainted = (pokemon: PlayerPokemon) => {
@@ -147,6 +150,9 @@ export default class PartyUiHandler extends MessageUiHandler {
this.optionsContainer = this.scene.add.container((this.scene.game.canvas.width / 6) - 1, -1);
partyContainer.add(this.optionsContainer);
this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup(this.scene);
this.options = [];
this.partySlots = [];
@@ -362,7 +368,7 @@ export default class PartyUiHandler extends MessageUiHandler {
for (let p in party) {
const slotIndex = parseInt(p);
const partySlot = new PartySlot(this.scene, slotIndex, party[p], this.partyUiMode, this.tmMoveId);
const partySlot = new PartySlot(this.scene, slotIndex, party[p], this.iconAnimHandler, this.partyUiMode, this.tmMoveId);
this.scene.add.existing(partySlot);
this.partySlotsContainer.add(partySlot);
this.partySlots.push(partySlot);
@@ -713,13 +719,17 @@ class PartySlot extends Phaser.GameObjects.Container {
private slotBg: Phaser.GameObjects.Image;
private slotPb: Phaser.GameObjects.Sprite;
constructor(scene: BattleScene, slotIndex: integer, pokemon: PlayerPokemon, partyUiMode: PartyUiMode, tmMoveId: Moves) {
private pokemonIcon: Phaser.GameObjects.Sprite;
private iconAnimHandler: PokemonIconAnimHandler;
constructor(scene: BattleScene, slotIndex: integer, pokemon: PlayerPokemon, iconAnimHandler: PokemonIconAnimHandler, partyUiMode: PartyUiMode, tmMoveId: Moves) {
super(scene, slotIndex >= scene.currentBattle.getBattlerCount() ? 230.5 : 64,
slotIndex >= scene.currentBattle.getBattlerCount() ? -184 + (scene.currentBattle.double ? -38 : 0)
+ (28 + (scene.currentBattle.double ? 6 : 0)) * slotIndex : -124 + (scene.currentBattle.double ? -8 : 0) + slotIndex * 64);
this.slotIndex = slotIndex;
this.pokemon = pokemon;
this.iconAnimHandler = iconAnimHandler;
this.setup(partyUiMode, tmMoveId);
}
@@ -739,15 +749,12 @@ class PartySlot extends Phaser.GameObjects.Container {
this.add(slotPb);
const pokemonIcon = this.scene.add.sprite(slotPb.x, slotPb.y, this.pokemon.getIconAtlasKey(true));
if (this.pokemon.getSpeciesForm().generation <= 5)
pokemonIcon.play(this.pokemon.getIconKey(true));
else {
pokemonIcon.setFrame(this.pokemon.getIconId());
pokemonIcon.setScale(0.75);
}
this.pokemonIcon = this.scene.add.sprite(slotPb.x, slotPb.y, this.pokemon.getIconAtlasKey(true));
this.pokemonIcon.setFrame(this.pokemon.getIconId());
this.add(pokemonIcon);
this.add(this.pokemonIcon);
this.iconAnimHandler.addOrUpdate(this.pokemonIcon, PokemonIconAnimMode.PASSIVE);
const slotInfoContainer = this.scene.add.container(0, 0);
this.add(slotInfoContainer);
@@ -842,6 +849,7 @@ class PartySlot extends Phaser.GameObjects.Container {
return;
this.selected = true;
this.iconAnimHandler.addOrUpdate(this.pokemonIcon, PokemonIconAnimMode.ACTIVE);
this.updateSlotTexture();
this.slotPb.setFrame('party_pb_sel');
@@ -852,6 +860,7 @@ class PartySlot extends Phaser.GameObjects.Container {
return;
this.selected = false;
this.iconAnimHandler.addOrUpdate(this.pokemonIcon, PokemonIconAnimMode.PASSIVE);
this.updateSlotTexture();
this.slotPb.setFrame('party_pb');
+75
View File
@@ -0,0 +1,75 @@
import BattleScene from "../battle-scene";
import * as Utils from "../utils";
export enum PokemonIconAnimMode {
NONE,
PASSIVE,
ACTIVE
}
export default class PokemonIconAnimHandler {
private counter: Phaser.Tweens.Tween;
private icons: Map<Phaser.GameObjects.Sprite, PokemonIconAnimMode>;
private toggled: boolean;
setup(scene: BattleScene): void {
this.icons = new Map();
this.toggled = false;
const onAlternate = (tween: Phaser.Tweens.Tween) => {
const value = tween.getValue();
this.toggled = !!value;
for (let i of this.icons.keys())
i.y += this.getModeYDelta(this.icons.get(i)) * (this.toggled ? 1 : -1);
};
this.counter = scene.tweens.addCounter({
duration: Utils.fixedInt(200),
from: 0,
to: 1,
yoyo: true,
repeat: -1,
onRepeat: onAlternate,
onYoyo: onAlternate
});
}
getModeYDelta(mode: PokemonIconAnimMode): number {
switch (mode) {
case PokemonIconAnimMode.NONE:
return 0;
case PokemonIconAnimMode.PASSIVE:
return -1;
case PokemonIconAnimMode.ACTIVE:
return -2;
}
}
addOrUpdate(icons: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[], mode: PokemonIconAnimMode): void {
if (!Array.isArray(icons))
icons = [ icons ];
for (let i of icons) {
if (this.icons.has(i) && this.icons.get(i) === mode)
continue;
if (this.toggled) {
console.log(i.frame)
const lastYDelta = this.icons.has(i)
? this.icons.get(i)
: 0;
const yDelta = this.getModeYDelta(mode);
i.y += yDelta + lastYDelta;
console.log(yDelta - lastYDelta)
}
this.icons.set(i, mode);
}
}
remove(icons: Phaser.GameObjects.Sprite | Phaser.GameObjects.Sprite[]): void {
if (!Array.isArray(icons))
icons = [ icons ];
for (let i of icons) {
if (this.toggled)
i.y -= this.getModeYDelta(this.icons.get(i));
this.icons.delete(i);
}
}
}
+21 -19
View File
@@ -12,6 +12,7 @@ import { GrowthRate, getGrowthRateColor } from "../data/exp";
import { DexAttr, DexEntry } from "../system/game-data";
import * as Utils from "../utils";
import { Stat, getStatName } from "../data/pokemon-stat";
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
export type StarterSelectCallback = (starters: Starter[]) => void;
@@ -75,6 +76,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
private starterValueLabels: Phaser.GameObjects.Text[];
private shinyIcons: Phaser.GameObjects.Image[];
private iconAnimHandler: PokemonIconAnimHandler;
private starterSelectCallback: StarterSelectCallback;
constructor(scene: BattleScene) {
@@ -96,6 +99,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
starterSelectBg.setOrigin(0, 0);
this.starterSelectContainer.add(starterSelectBg);
this.iconAnimHandler = new PokemonIconAnimHandler();
this.iconAnimHandler.setup(this.scene);
this.pokemonNumberText = addTextObject(this.scene, 17, 1, '000', TextStyle.SUMMARY);
this.pokemonNumberText.setOrigin(0, 0);
this.starterSelectContainer.add(this.pokemonNumberText);
@@ -196,32 +202,26 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.genSpecies[g].push(species);
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
species.generateIconAnim(this.scene, defaultProps.female, defaultProps.formIndex);
const x = (s % 9) * 18;
const y = Math.floor(s / 9) * 18;
const icon = this.scene.add.sprite(x, y, species.getIconAtlasKey(defaultProps.formIndex));
const icon = this.scene.add.sprite(x - 2, y + 2, species.getIconAtlasKey(defaultProps.formIndex));
icon.setScale(0.5);
icon.setOrigin(0, 0);
icon.play(species.getIconKey(defaultProps.female, defaultProps.formIndex)).stop();
icon.setFrame(species.getIconId(defaultProps.female, defaultProps.formIndex, defaultProps.shiny));
icon.setTintFill(0);
this.starterSelectGenIconContainers[g].add(icon);
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.NONE);
s++;
}
}
this.scene.anims.create({
key: 'pkmn_icon__000',
frames: this.scene.anims.generateFrameNames('pokemon_icons_0', { prefix: `000_`, zeroPad: 2, suffix: '.png', start: 1, end: 34 }),
frameRate: 128,
repeat: -1
});
this.starterIcons = new Array(3).fill(null).map((_, i) => {
const icon = this.scene.add.sprite(115, 95 + 16 * i, 'pokemon_icons_0');
const icon = this.scene.add.sprite(113, 97 + 16 * i, 'pokemon_icons_0');
icon.setScale(0.5);
icon.setOrigin(0, 0);
icon.play('pkmn_icon__000');
icon.setFrame('unknown');
this.starterSelectContainer.add(icon);
this.iconAnimHandler.addOrUpdate(icon, PokemonIconAnimMode.PASSIVE);
return icon;
});
@@ -438,9 +438,9 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
const cursorObj = this.starterCursorObjs[this.starterCursors.length];
cursorObj.setVisible(true);
cursorObj.setPosition(this.cursorObj.x, this.cursorObj.y);
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
const defaultProps = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
this.starterIcons[this.starterCursors.length].play(species.getIconKey(defaultProps.female, defaultProps.formIndex));
const props = this.scene.gameData.getSpeciesDexAttrProps(species, this.dexAttrCursor);
this.starterIcons[this.starterCursors.length].setTexture(species.getIconAtlasKey(props.formIndex));
this.starterIcons[this.starterCursors.length].setFrame(species.getIconId(props.female, props.formIndex, props.shiny));
this.starterGens.push(this.genCursor);
this.starterCursors.push(this.cursor);
this.starterAttr.push(this.dexAttrCursor);
@@ -661,7 +661,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
const dexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(this.lastSpecies);
const props = this.scene.gameData.getSpeciesDexAttrProps(this.lastSpecies, dexAttr);
const lastSpeciesIcon = (this.starterSelectGenIconContainers[this.lastSpecies.generation - 1].getAt(this.genSpecies[this.lastSpecies.generation - 1].indexOf(this.lastSpecies)) as Phaser.GameObjects.Sprite);
lastSpeciesIcon.play(this.lastSpecies.getIconKey(props.female, props.formIndex)).stop();
lastSpeciesIcon.setFrame(this.lastSpecies.getIconId(props.female, props.formIndex, props.shiny));
this.iconAnimHandler.addOrUpdate(lastSpeciesIcon, PokemonIconAnimMode.NONE);
}
this.lastSpecies = species;
@@ -674,6 +675,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonGrowthRateText.setShadowColor(getGrowthRateColor(species.growthRate, true));
this.pokemonGrowthRateLabelText.setVisible(true);
this.pokemonAbilityLabelText.setVisible(true);
this.iconAnimHandler.addOrUpdate(this.starterSelectGenIconContainers[species.generation - 1].getAt(this.genSpecies[species.generation - 1].indexOf(species)) as Phaser.GameObjects.Sprite, PokemonIconAnimMode.PASSIVE);
const defaultDexAttr = this.scene.gameData.getSpeciesDefaultDexAttr(species);
const props = this.scene.gameData.getSpeciesDexAttrProps(species, defaultDexAttr);
@@ -735,8 +737,7 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.pokemonSprite.setVisible(!this.statsMode);
});
species.generateIconAnim(this.scene, female, formIndex);
(this.starterSelectGenIconContainers[this.genCursor].getAt(this.cursor) as Phaser.GameObjects.Sprite).play(species.getIconKey(female, formIndex));
(this.starterSelectGenIconContainers[this.genCursor].getAt(this.cursor) as Phaser.GameObjects.Sprite).setFrame(species.getIconId(female, formIndex, shiny));
this.canCycleShiny = !!(dexEntry.caughtAttr & DexAttr.NON_SHINY && dexEntry.caughtAttr & DexAttr.SHINY);
this.canCycleGender = !!(dexEntry.caughtAttr & DexAttr.MALE && dexEntry.caughtAttr & DexAttr.FEMALE);
@@ -774,7 +775,8 @@ export default class StarterSelectUiHandler extends MessageUiHandler {
this.starterCursors.pop();
this.starterAttr.pop();
this.starterCursorObjs[this.starterCursors.length].setVisible(false);
this.starterIcons[this.starterCursors.length].play('pkmn_icon__000');
this.starterIcons[this.starterCursors.length].setTexture('pokemon_icons_0');
this.starterIcons[this.starterCursors.length].setFrame('unknown');
this.tryUpdateValue();
}