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"; import Attack from "./Attack";
export default class SlimeAttack extends Attack { export default class SlimeAttack extends Attack {
onEnter(options: Record<string, any>): void {
}
update(deltaT: number): 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); this.finished(EnemyStates.ALERT);
break; }
} onExit(): Record<string, any> {
} return null;
super.update(deltaT);
} }
} }

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