Add gen 6-7 sprites and update icon set
This commit is contained in:
1 parent
0e366986b5
commit
b7687a9a30
4574 files changed
+90979
-517496
No files matched your search
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user