diff --git a/src/shattered_sword/AI/EnemyAI.ts b/src/shattered_sword/AI/EnemyAI.ts index bd33645..569098f 100644 --- a/src/shattered_sword/AI/EnemyAI.ts +++ b/src/shattered_sword/AI/EnemyAI.ts @@ -63,6 +63,7 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { bleedStat: Sprite; attackTimer : Timer; + isAttaking: boolean = false; initializeAI(owner: AnimatedSprite, options: Record): void { @@ -105,7 +106,10 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left"); this.CURRENT_HP -= damage; //TODO - - this.owner.animation.play("HURT",false); + if (!this.isAttaking) { + this.owner.animation.play("HURT",false); + } + console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left"); // If health goes below 0, disable AI and fire enemyDied event @@ -134,6 +138,10 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { } } + collideWithPlayer(player: PlayerController): void { + player.damage(10); + } + //TODO - need to modify for side view isPlayerVisible(pos: Vec2): Vec2{ //Check ifplayer is visible, taking into account walls @@ -181,9 +189,6 @@ export default class EnemyAI extends StateMachineAI implements BattlerAI { } return pos; } - - - /** * gets the position of the player diff --git a/src/shattered_sword/AI/EnemyStates/Attack.ts b/src/shattered_sword/AI/EnemyStates/Attack.ts index e1cd3ef..db0cc12 100644 --- a/src/shattered_sword/AI/EnemyStates/Attack.ts +++ b/src/shattered_sword/AI/EnemyStates/Attack.ts @@ -9,6 +9,7 @@ export default class Attack extends EnemyState { onEnter(options: Record): void { this.parent.attackTimer.start(); this.parent.velocity.x = 0; + this.parent.isAttaking = true; this.charged = this.owner.id+"charged"; this.attacked = this.owner.id+"attacked"; @@ -34,6 +35,7 @@ export default class Attack extends EnemyState { } onExit(): Record { + this.parent.isAttaking = false; (this.owner).animation.stop(); return null; } diff --git a/src/shattered_sword/AI/EnemyStates/SnakeAttack.ts b/src/shattered_sword/AI/EnemyStates/SnakeAttack.ts index 718ad2b..d9372cd 100644 --- a/src/shattered_sword/AI/EnemyStates/SnakeAttack.ts +++ b/src/shattered_sword/AI/EnemyStates/SnakeAttack.ts @@ -1,5 +1,4 @@ import EnemyAI, { EnemyStates } from "../EnemyAI"; -import EnemyState from "./EnemyState"; import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite"; import AABB from "../../../Wolfie2D/DataTypes/Shapes/AABB"; import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 9680a95..8df4123 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -950,7 +950,7 @@ export default class GameLevel extends Scene { } if(typeof enemy != undefined && typeof player != undefined){ //damage the player - (this.player._ai).damage(10); //10 collision dmg for now + (enemy._ai).collideWithPlayer(this.player._ai); } }