locked archer direction, changed boss hitbox
This commit is contained in:
parent
384ca87f10
commit
4b8c7a0bf9
|
@ -3,7 +3,7 @@ import EnemyAI, { EnemyStates } from "./EnemyAI";
|
|||
import BossAttack from "./EnemyStates/BossAttack";
|
||||
import Weapon from "../GameSystems/items/Weapon";
|
||||
import Vec2 from "../../Wolfie2D/DataTypes/Vec2";
|
||||
|
||||
import { Player_Events } from "../sword_enums";
|
||||
|
||||
export default class BossAI extends EnemyAI {
|
||||
|
||||
|
@ -19,4 +19,45 @@ export default class BossAI extends EnemyAI {
|
|||
canAttack(position: Vec2): boolean {
|
||||
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();
|
||||
}
|
||||
}
|
|
@ -4,23 +4,25 @@ import Attack from "./Attack";
|
|||
import ArcherAI from "../ArcherAI";
|
||||
import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite";
|
||||
import Timer from "../../../Wolfie2D/Timing/Timer";
|
||||
import Vec2 from "../../../Wolfie2D/DataTypes/Vec2";
|
||||
|
||||
//TODO - unfinished
|
||||
export default class ArcherAttack extends Attack {
|
||||
pauseTimer : Timer;
|
||||
dir :Vec2;
|
||||
onEnter(options: Record<string, any>): void {
|
||||
super.onEnter(options);
|
||||
this.pauseTimer = new Timer(1000);
|
||||
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 {
|
||||
|
||||
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 ;
|
||||
this.finished(EnemyStates.ALERT);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class GameFinish extends Scene {
|
|||
|
||||
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.fontSize = 100;
|
||||
|
||||
|
|
|
@ -983,8 +983,8 @@ export default class GameLevel extends Scene {
|
|||
health: 1000,
|
||||
tilemap: "Main",
|
||||
scale: 2,
|
||||
size: new Vec2(60,31),
|
||||
offset : new Vec2(0,50),
|
||||
size: new Vec2(60,50),
|
||||
offset : new Vec2(0,30),
|
||||
exp: 75,
|
||||
weapon: this.createWeapon("laserGun")
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user