locked archer direction, changed boss hitbox

This commit is contained in:
OfficialCHenry 2022-05-09 14:46:09 -04:00
parent 384ca87f10
commit 4b8c7a0bf9
4 changed files with 50 additions and 7 deletions

View File

@ -3,7 +3,7 @@ import EnemyAI, { EnemyStates } from "./EnemyAI";
import BossAttack from "./EnemyStates/BossAttack"; import BossAttack from "./EnemyStates/BossAttack";
import Weapon from "../GameSystems/items/Weapon"; import Weapon from "../GameSystems/items/Weapon";
import Vec2 from "../../Wolfie2D/DataTypes/Vec2"; import Vec2 from "../../Wolfie2D/DataTypes/Vec2";
import { Player_Events } from "../sword_enums";
export default class BossAI extends EnemyAI { export default class BossAI extends EnemyAI {
@ -19,4 +19,45 @@ export default class BossAI extends EnemyAI {
canAttack(position: Vec2): boolean { canAttack(position: Vec2): boolean {
return this.attackTimer.isStopped() && this.owner.position.distanceTo(position)<=128; return this.attackTimer.isStopped() && this.owner.position.distanceTo(position)<=128;
} }
damage(damage: number): void {
// enemy already dead, do not send new event
if (this.CURRENT_HP <= 0) {
return;
}
//console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left");
this.CURRENT_HP -= damage;
//TODO -
if (!this.isAttacking && !this.isCharging) {
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
if (this.CURRENT_HP <= 0) {
this.owner.setAIActive(false, {});
this.owner.isCollidable = false;
this.owner.visible = false;
if (this.healthBar) {
this.healthBar.destroy();
this.healthBar = undefined;
}
if (this.poisonStat) {
this.poisonStat.destroy();
this.poisonStat = undefined;
}
if (this.burnStat) {
this.burnStat.destroy();
this.burnStat = undefined;
}
if (this.bleedStat) {
this.bleedStat.destroy();
this.bleedStat = undefined;
}
this.emitter.fireEvent("nextLevel", {owner: this.owner.id, ai:this});
}
this.damageTimer.start();
}
} }

View File

@ -4,23 +4,25 @@ import Attack from "./Attack";
import ArcherAI from "../ArcherAI"; import ArcherAI from "../ArcherAI";
import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite";
import Timer from "../../../Wolfie2D/Timing/Timer"; import Timer from "../../../Wolfie2D/Timing/Timer";
import Vec2 from "../../../Wolfie2D/DataTypes/Vec2";
//TODO - unfinished //TODO - unfinished
export default class ArcherAttack extends Attack { export default class ArcherAttack extends Attack {
pauseTimer : Timer; pauseTimer : Timer;
dir :Vec2;
onEnter(options: Record<string, any>): void { onEnter(options: Record<string, any>): void {
super.onEnter(options); super.onEnter(options);
this.pauseTimer = new Timer(1000); this.pauseTimer = new Timer(1000);
this.pauseTimer.start(); this.pauseTimer.start();
this.dir = this.parent.getPlayerPosition().clone().sub(this.owner.position).normalize();
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
} }
update(deltaT: number): void { update(deltaT: number): void {
if(this.pauseTimer.isStopped()){ if(this.pauseTimer.isStopped()){
this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1;
let dir = this.parent.getPlayerPosition().clone().sub(this.owner.position).normalize();
(<ArcherAI>this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0)); (<ArcherAI>this.parent).weapon.use(this.owner, "enemy", this.dir.scale(1,0));
(<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false ; (<Sprite>this.owner).invertX = this.parent.direction === 1 ? true : false ;
this.finished(EnemyStates.ALERT); this.finished(EnemyStates.ALERT);
} }

View File

@ -17,7 +17,7 @@ export default class GameFinish extends Scene {
this.addUILayer("primary"); this.addUILayer("primary");
const congra = <Label>this.add.uiElement(UIElementType.LABEL, "primary", {position: new Vec2(center.x, center.y), text: "CONGRATULATION!"}); const congra = <Label>this.add.uiElement(UIElementType.LABEL, "primary", {position: new Vec2(center.x, center.y), text: "CONGRATULATIONS!"});
congra.textColor = Color.GREEN; congra.textColor = Color.GREEN;
congra.fontSize = 100; congra.fontSize = 100;

View File

@ -983,8 +983,8 @@ export default class GameLevel extends Scene {
health: 1000, health: 1000,
tilemap: "Main", tilemap: "Main",
scale: 2, scale: 2,
size: new Vec2(60,31), size: new Vec2(60,50),
offset : new Vec2(0,50), offset : new Vec2(0,30),
exp: 75, exp: 75,
weapon: this.createWeapon("laserGun") weapon: this.createWeapon("laserGun")
}) })