Another refactor
This commit is contained in:
@@ -188,12 +188,25 @@ export class DungeonRenderer {
|
||||
if (a.category === "combatant") {
|
||||
if (a.isPlayer) {
|
||||
if (this.playerSprite) {
|
||||
this.playerSprite.setPosition(a.pos.x * TILE_SIZE + TILE_SIZE / 2, a.pos.y * TILE_SIZE + TILE_SIZE / 2);
|
||||
const tx = a.pos.x * TILE_SIZE + TILE_SIZE / 2;
|
||||
const ty = a.pos.y * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
if (this.playerSprite.x !== tx || this.playerSprite.y !== ty) {
|
||||
this.scene.tweens.add({
|
||||
targets: this.playerSprite,
|
||||
x: tx,
|
||||
y: ty,
|
||||
duration: 120,
|
||||
ease: 'Quad.easeOut',
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
this.playerSprite.setVisible(true);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (!isVis) continue;
|
||||
|
||||
activeEnemyIds.add(a.id);
|
||||
@@ -207,8 +220,21 @@ export class DungeonRenderer {
|
||||
this.enemySprites.set(a.id, sprite);
|
||||
}
|
||||
|
||||
sprite.setPosition(a.pos.x * TILE_SIZE + TILE_SIZE / 2, a.pos.y * TILE_SIZE + TILE_SIZE / 2);
|
||||
const tx = a.pos.x * TILE_SIZE + TILE_SIZE / 2;
|
||||
const ty = a.pos.y * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
if (sprite.x !== tx || sprite.y !== ty) {
|
||||
this.scene.tweens.add({
|
||||
targets: sprite,
|
||||
x: tx,
|
||||
y: ty,
|
||||
duration: 120,
|
||||
ease: 'Quad.easeOut',
|
||||
overwrite: true
|
||||
});
|
||||
}
|
||||
sprite.setVisible(true);
|
||||
|
||||
} else if (a.category === "collectible") {
|
||||
if (a.type === "exp_orb") {
|
||||
if (!isVis) continue;
|
||||
|
||||
@@ -106,9 +106,12 @@ describe('DungeonRenderer', () => {
|
||||
destroy: vi.fn(),
|
||||
}),
|
||||
},
|
||||
|
||||
tweens: {
|
||||
add: vi.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
mockWorld = {
|
||||
width: 10,
|
||||
height: 10,
|
||||
|
||||
Reference in New Issue
Block a user