feat: make SnakeAttack extend Attack

This commit is contained in:
Renge 2022-04-24 22:29:15 -04:00
parent da99dc9883
commit 51be51916b

View File

@ -1,25 +1,16 @@
import EnemyAI, { EnemyStates } from "../EnemyAI"; import EnemyAI, { EnemyStates } from "../EnemyAI";
import EnemyState from "./EnemyState"; import EnemyState from "./EnemyState";
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite"; import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
import Shape from "../../../Wolfie2D/DataTypes/Shapes/Shape";
import Vec2 from "../../../Wolfie2D/DataTypes/Vec2";
import AABB from "../../../Wolfie2D/DataTypes/Shapes/AABB"; import AABB from "../../../Wolfie2D/DataTypes/Shapes/AABB";
import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite";
import Attack from "./Attack";
export default class Attack extends EnemyState { export default class SnakeAttack extends Attack {
protected charged: string; protected charged: string;
protected attacked: string; protected attacked: string;
onEnter(options: Record<string, any>): void { onEnter(options: Record<string, any>): void {
this.parent.attackTimer.start(); super.onEnter(options);
this.parent.velocity.x = 0;
this.charged = this.owner.id+"charged";
this.attacked = this.owner.id+"attacked";
// TODO replace DYING with CHARGING
(<AnimatedSprite>this.owner).animation.play("DYING", false, this.charged);
this.receiver.subscribe(this.charged);
this.receiver.subscribe(this.attacked);
} }
update(deltaT: number): void { update(deltaT: number): void {
@ -36,7 +27,6 @@ export default class Attack extends EnemyState {
break; break;
} }
} }
console.log(this.parent.direction);
(<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false ; (<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false ;
} }