Skip to content
Snippets Groups Projects
Commit 75e0123b authored by Paolo.Brasolin's avatar Paolo.Brasolin
Browse files

refactor: #fe fith scene spawning

parent 102e2111
No related branches found
No related tags found
No related merge requests found
......@@ -126,7 +126,7 @@ export default class FightScene extends Phaser.Scene {
})
).data;
gameStart(this);
spawnFoes();
}
createAnimations() {
......@@ -333,21 +333,17 @@ export default class FightScene extends Phaser.Scene {
this.hud.input.text = inputStatus.final;
};
}
}
function gameStart(scene: any) {
spawn(scene);
}
async function spawn(scene: any) {
if (!scene.scene.isActive()) return;
await spawnFoe(scene);
scene.time.now;
const delay =
(8 * 1000 * (60 * 1000 - scene.time.now)) / 60 / 1000 + 2 * 1000;
setTimeout(() => spawn(scene), Math.max(2000, delay));
}
async spawnFoes() {
if (!this.scene.isActive()) return;
await this.spawnFoe();
const delay =
(8 * 1000 * (60 * 1000 - this.time.now)) / 60 / 1000 + 2 * 1000;
// TODO: think of a progression which makes sense
setTimeout(this.spawnFoes.bind(this), Math.max(2000, delay));
}
async function spawnFoe(scene: FightScene) {
await new Foe(scene).initialize();
async spawnFoe() {
await new Foe(this).initialize();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment