fix: slime don't have a charge state

This commit is contained in:
Renge 2022-04-25 21:06:27 -04:00
parent 76ac59ac9c
commit bc625b9530
3 changed files with 18 additions and 13 deletions

View File

@ -3,18 +3,12 @@ import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
import Attack from "./Attack";
export default class SlimeAttack extends Attack {
onEnter(options: Record<string, any>): void {
}
update(deltaT: number): void {
while (this.receiver.hasNextEvent()) {
let event = this.receiver.getNextEvent().type;
switch (event) {
case this.charged:
(<AnimatedSprite>this.owner).animation.play("ATTACK", false, this.attacked);
break;
case this.attacked:
this.finished(EnemyStates.ALERT);
break;
}
}
super.update(deltaT);
this.finished(EnemyStates.ALERT);
}
onExit(): Record<string, any> {
return null;
}
}

View File

@ -0,0 +1,10 @@
import AnimatedSprite from "../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
import EnemyAI, { EnemyStates } from "./EnemyAI";
import SlimeAttack from "./EnemyStates/SlimeAttack";
export default class SlimeAI extends EnemyAI {
initializeAI(owner: AnimatedSprite, options: Record<string, any>): void {
super.initializeAI(owner, options);
this.addState(EnemyStates.ATTACK, new SlimeAttack(this, owner));
}
}

View File

@ -21,6 +21,7 @@ import Weapon from "../GameSystems/items/Weapon";
import BattleManager from "../GameSystems/BattleManager";
import EnemyAI from "../AI/EnemyAI";
import SnakeAI from "../AI/SnakeAI";
import SlimeAI from "../AI/SlimeAI";
import BattlerAI from "../AI/BattlerAI";
import InventoryManager from "../GameSystems/InventoryManager";
import Item from "../GameSystems/items/Item";
@ -907,7 +908,7 @@ export default class GameLevel extends Scene {
})
break;
case "black_pudding":
this.addEnemy("black_pudding", enemy.position.scale(32), EnemyAI, {
this.addEnemy("black_pudding", enemy.position.scale(32), SlimeAI, {
player: this.player,
health: 200,
tilemap: "Main",