Minor refactoring
This commit is contained in:
1 parent
8d314b199f
commit
f48464d48d
41 files changed
+115
-111
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import BattleScene from "../battle-scene";
|
||||
import Pokemon from "../pokemon";
|
||||
import Pokemon from "../field/pokemon";
|
||||
import { TextStyle, addTextObject } from "./text";
|
||||
|
||||
const hiddenX = -91;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EnemyPokemon, default as Pokemon } from '../pokemon';
|
||||
import { EnemyPokemon, default as Pokemon } from '../field/pokemon';
|
||||
import { getLevelTotalExp, getLevelRelExp } from '../data/exp';
|
||||
import * as Utils from '../utils';
|
||||
import { addTextObject, TextStyle } from './text';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import BattleScene, { Button } from "../battle-scene";
|
||||
import { Mode } from "./ui";
|
||||
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "../sprite/pokemon-icon-anim-handler";
|
||||
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
|
||||
import { TextStyle, addTextObject } from "./text";
|
||||
import MessageUiHandler from "./message-ui-handler";
|
||||
import { EGG_SEED, Egg, GachaType, getEggGachaTypeDescriptor, getEggHatchWavesMessage, getEggDescriptor } from "../data/egg";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BattleScene from "../battle-scene";
|
||||
import Pokemon from "../pokemon";
|
||||
import Pokemon from "../field/pokemon";
|
||||
import { TextStyle, addTextObject } from "./text";
|
||||
|
||||
export default class PartyExpBar extends Phaser.GameObjects.Container {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CommandPhase } from "../phases";
|
||||
import BattleScene, { Button } from "../battle-scene";
|
||||
import { PlayerPokemon, PokemonMove } from "../pokemon";
|
||||
import { PlayerPokemon, PokemonMove } from "../field/pokemon";
|
||||
import { addTextObject, TextStyle } from "./text";
|
||||
import { Command } from "./command-ui-handler";
|
||||
import MessageUiHandler from "./message-ui-handler";
|
||||
@@ -11,7 +11,7 @@ import { allMoves } from "../data/move";
|
||||
import { Moves } from "../data/enums/moves";
|
||||
import { getGenderColor, getGenderSymbol } from "../data/gender";
|
||||
import { StatusEffect } from "../data/status-effect";
|
||||
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "../sprite/pokemon-icon-anim-handler";
|
||||
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
|
||||
import { pokemonEvolutions } from "../data/pokemon-evolutions";
|
||||
import { addWindow } from "./window";
|
||||
import { SpeciesFormChangeItemTrigger } from "../data/pokemon-forms";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import BattleScene from "../battle-scene";
|
||||
import Pokemon from "../pokemon";
|
||||
import Pokemon from "../field/pokemon";
|
||||
|
||||
export default class PokeballTray extends Phaser.GameObjects.Container {
|
||||
private player: boolean;
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import BattleScene from "../battle-scene";
|
||||
import * as Utils from "../utils";
|
||||
|
||||
export enum PokemonIconAnimMode {
|
||||
NONE,
|
||||
PASSIVE,
|
||||
ACTIVE
|
||||
}
|
||||
|
||||
export default class PokemonIconAnimHandler {
|
||||
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);
|
||||
};
|
||||
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) {
|
||||
const lastYDelta = this.icons.has(i)
|
||||
? this.icons.get(i)
|
||||
: 0;
|
||||
const yDelta = this.getModeYDelta(mode);
|
||||
i.y += 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);
|
||||
}
|
||||
}
|
||||
|
||||
removeAll(): void {
|
||||
for (let i of this.icons.keys()) {
|
||||
if (this.toggled)
|
||||
i.y -= this.getModeYDelta(this.icons.get(i));
|
||||
this.icons.delete(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { Unlockables } from "../system/unlockables";
|
||||
import { GrowthRate, getGrowthRateColor } from "../data/exp";
|
||||
import { DexAttr, DexEntry, StarterFormMoveData, StarterMoveset } from "../system/game-data";
|
||||
import * as Utils from "../utils";
|
||||
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "../sprite/pokemon-icon-anim-handler";
|
||||
import PokemonIconAnimHandler, { PokemonIconAnimMode } from "./pokemon-icon-anim-handler";
|
||||
import { StatsContainer } from "./stats-container";
|
||||
import { addWindow } from "./window";
|
||||
import { Nature, getNatureName } from "../data/nature";
|
||||
|
||||
@@ -2,7 +2,7 @@ import BattleScene, { Button } from "../battle-scene";
|
||||
import { Mode } from "./ui";
|
||||
import UiHandler from "./ui-handler";
|
||||
import * as Utils from "../utils";
|
||||
import { PlayerPokemon } from "../pokemon";
|
||||
import { PlayerPokemon } from "../field/pokemon";
|
||||
import { Type, getTypeRgb } from "../data/type";
|
||||
import { TextStyle, addBBCodeTextObject, addTextObject, getBBCodeFrag, getTextColor } from "./text";
|
||||
import Move, { MoveCategory } from "../data/move";
|
||||
|
||||
Reference in new issue
Block a user