Remove debug console.log, add enemy cleanup on death, and implement dynamic faction spawning
This commit is contained in:
parent
86fa4c7ea4
commit
a2d24d6fbb
|
|
@ -168,7 +168,6 @@ export class Faction extends Phaser.GameObjects.Sprite {
|
|||
// Attack
|
||||
if (this.enemy && this.enemy.active && this.timerAttack >= 2000) {
|
||||
this.timerAttack = 0;
|
||||
console.log('attack');
|
||||
this.attack();
|
||||
}
|
||||
}
|
||||
|
|
@ -215,6 +214,7 @@ export class Faction extends Phaser.GameObjects.Sprite {
|
|||
if (this.stats.type === 'melee' && this.enemy && this.enemy.active) {
|
||||
const status = this.enemy.takeDamage('melee', Phaser.Math.Between(this.stats.attackMin, this.stats.attackMax));
|
||||
if (status === 'dead') {
|
||||
this.enemy = false;
|
||||
this.resumePath();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ export class Level extends Phaser.Scene {
|
|||
this.isDragging = false;
|
||||
this.dragStartX = 0;
|
||||
this.dragStartY = 0;
|
||||
|
||||
this.time1 = 2000;
|
||||
this.timer1 = 0;
|
||||
this.time2 = 3000;
|
||||
this.timer2 = 0;
|
||||
}
|
||||
|
||||
init(data) {
|
||||
|
|
@ -36,9 +41,6 @@ export class Level extends Phaser.Scene {
|
|||
|
||||
this.factionLeft = this.add.group();
|
||||
this.factionRight = this.add.group();
|
||||
|
||||
const test = new Faction(this, 4*64, 5*64, 'dark-ages', 0, 'left', 1, 'dark-ages').setOrigin(0.5);
|
||||
const test2 = new Faction(this, 27*64, 4*64, 'dark-ages', 0, 'right', 1, 'dark-ages').setOrigin(0.5);
|
||||
}
|
||||
|
||||
update(time, delta) {
|
||||
|
|
@ -53,6 +55,20 @@ export class Level extends Phaser.Scene {
|
|||
faction.update(time, delta);
|
||||
}
|
||||
});
|
||||
|
||||
this.timer1 += delta;
|
||||
this.timer2 += delta;
|
||||
|
||||
if (this.timer1 >= this.time1) {
|
||||
this.timer1 = 0;
|
||||
this.time1 = Phaser.Math.Between(6000,20000);
|
||||
const test = new Faction(this, 4*64, 5*64, 'dark-ages', 0, 'left', 1, 'dark-ages').setOrigin(0.5);
|
||||
}
|
||||
if (this.timer2 >= this.time2) {
|
||||
this.timer2 = 0;
|
||||
this.time2 = Phaser.Math.Between(6000,20000);
|
||||
const test2 = new Faction(this, 27*64, 4*64, 'dark-ages', 0, 'right', 1, 'dark-ages').setOrigin(0.5);
|
||||
}
|
||||
}
|
||||
|
||||
onPointerDown(pointer) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue