diff --git a/dist/shattered_sword_assets/spritesheets/Bull.json b/dist/shattered_sword_assets/spritesheets/Bull.json index 18c31f9..ac9c7ee 100644 --- a/dist/shattered_sword_assets/spritesheets/Bull.json +++ b/dist/shattered_sword_assets/spritesheets/Bull.json @@ -36,8 +36,8 @@ "repeat": false, "frames": [ { - "index": 0, - "duration": 20 + "index": 5, + "duration": 60 } ] }, diff --git a/src/shattered_sword/AI/EnemyStates/ArcherAttack.ts b/src/shattered_sword/AI/EnemyStates/ArcherAttack.ts index 938e609..3ccc131 100644 --- a/src/shattered_sword/AI/EnemyStates/ArcherAttack.ts +++ b/src/shattered_sword/AI/EnemyStates/ArcherAttack.ts @@ -17,7 +17,7 @@ export default class ArcherAttack extends Attack { update(deltaT: number): void { if(this.pauseTimer.isStopped()){ - this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; + 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(); (this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0)); diff --git a/src/shattered_sword/AI/EnemyStates/AssassinAttack.ts b/src/shattered_sword/AI/EnemyStates/AssassinAttack.ts index 0fecafd..2d69449 100644 --- a/src/shattered_sword/AI/EnemyStates/AssassinAttack.ts +++ b/src/shattered_sword/AI/EnemyStates/AssassinAttack.ts @@ -45,7 +45,7 @@ export default class AssassinAttack extends Attack { this.runTimer.start(); (this.owner).animation.play("ATTACK", true); if(this.parent.getPlayerPosition() !==null) - this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; + this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1; break; case this.attacked: this.parent.isAttacking = false; diff --git a/src/shattered_sword/AI/EnemyStates/Attack.ts b/src/shattered_sword/AI/EnemyStates/Attack.ts index 6dbeb9f..8df3be9 100644 --- a/src/shattered_sword/AI/EnemyStates/Attack.ts +++ b/src/shattered_sword/AI/EnemyStates/Attack.ts @@ -5,6 +5,7 @@ import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite"; export default class Attack extends EnemyState { protected charged: string; protected attacked: string; + protected hasCharged: boolean; onEnter(options: Record): void { this.parent.attackTimer.start(); @@ -12,6 +13,7 @@ export default class Attack extends EnemyState { this.parent.isCharging = true; this.charged = this.owner.id+"charged"; this.attacked = this.owner.id+"attacked"; + this.hasCharged = false; // TODO replace DYING with CHARGING (this.owner).animation.play("CHARGE", false, this.charged); diff --git a/src/shattered_sword/AI/EnemyStates/BossAttack.ts b/src/shattered_sword/AI/EnemyStates/BossAttack.ts index 96c276c..ea20c5d 100644 --- a/src/shattered_sword/AI/EnemyStates/BossAttack.ts +++ b/src/shattered_sword/AI/EnemyStates/BossAttack.ts @@ -56,7 +56,7 @@ export default class BossAttack extends Attack { switch( this.atknum){ case 0: //archer atk if(this.pauseTimer.isStopped()){ - this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; + 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(); (this.parent).weapon.use(this.owner, "enemy", dir.scale(1,0)); @@ -79,7 +79,7 @@ export default class BossAttack extends Attack { this.runTimer.start(); (this.owner).animation.play("ATTACK", true); if(this.parent.getPlayerPosition() !==null) - this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; + this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1; break; case this.attacked: this.parent.isAttacking = false; @@ -105,7 +105,7 @@ export default class BossAttack extends Attack { this.parent.isAttacking = true; this.runTimer.start(); (this.owner).animation.play("ATTACK", true); - this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; + this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1; break; case this.attacked: this.parent.isAttacking = false; @@ -129,7 +129,7 @@ export default class BossAttack extends Attack { this.parent.isAttacking = true; (this.owner).animation.play("ATTACK", true); this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5; - this.parent.direction = this.velocity >= 0 ? 1 : 0; + this.parent.direction = this.velocity >= 0 ? 1 : -1; this.parent.velocity.y = -800; break; case this.attacked: diff --git a/src/shattered_sword/AI/EnemyStates/BullAttack.ts b/src/shattered_sword/AI/EnemyStates/BullAttack.ts index 1914850..922b930 100644 --- a/src/shattered_sword/AI/EnemyStates/BullAttack.ts +++ b/src/shattered_sword/AI/EnemyStates/BullAttack.ts @@ -5,7 +5,7 @@ import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; import Attack from "./Attack"; import Timer from "../../../Wolfie2D/Timing/Timer"; -export default class TigerAttack extends Attack { +export default class BullAttack extends Attack { runTimer: Timer; onEnter(options: Record): void { @@ -14,18 +14,24 @@ export default class TigerAttack extends Attack { } update(deltaT: number): void { - if (this.runTimer.isStopped() && this.parent.isAttacking || !this.canWalk()) { + if ((this.runTimer.isStopped() && this.parent.isAttacking) || !this.canWalk()) { + this.parent.velocity.x = 0; this.emitter.fireEvent(this.attacked); } while (this.receiver.hasNextEvent()) { let event = this.receiver.getNextEvent().type; switch (event) { case this.charged: + if (this.hasCharged) { + break; + } + this.hasCharged = true; + console.log("charged") this.parent.isCharging = false; this.parent.isAttacking = true; this.runTimer.start(); (this.owner).animation.play("ATTACK", true); - this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : 0; + this.parent.direction = this.parent.getPlayerPosition().x - this.owner.position.x >= 0 ? 1 : -1; break; case this.attacked: this.parent.isAttacking = false; @@ -33,8 +39,10 @@ export default class TigerAttack extends Attack { break; } } - this.parent.velocity.x = this.parent.direction * 1000; - (this.owner).invertX = this.parent.direction === 1 ? true : false ; + if (this.parent.isAttacking) { + this.parent.velocity.x = this.parent.direction * 600; + (this.owner).invertX = this.parent.direction === 1 ? true : false; + } super.update(deltaT); } } \ No newline at end of file diff --git a/src/shattered_sword/AI/EnemyStates/TigerAttack.ts b/src/shattered_sword/AI/EnemyStates/TigerAttack.ts index 566e40d..2e378cb 100644 --- a/src/shattered_sword/AI/EnemyStates/TigerAttack.ts +++ b/src/shattered_sword/AI/EnemyStates/TigerAttack.ts @@ -25,7 +25,7 @@ export default class TigerAttack extends Attack { this.parent.isAttacking = true; (this.owner).animation.play("ATTACK", true); this.velocity = (this.parent.getPlayerPosition().x - this.owner.position.x)/1.5; - this.parent.direction = this.velocity >= 0 ? 1 : 0; + this.parent.direction = this.velocity >= 0 ? 1 : -1; this.parent.velocity.y = -800; break; case this.attacked: diff --git a/src/shattered_sword/Scenes/Forest.ts b/src/shattered_sword/Scenes/Forest.ts index 392423f..92b93d0 100644 --- a/src/shattered_sword/Scenes/Forest.ts +++ b/src/shattered_sword/Scenes/Forest.ts @@ -14,13 +14,7 @@ export default class Forest extends GameLevel { //load enemies this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json"); - - //can load enemy sprite here - //sprites obtained from cse380 sprite wesbite - this.load.spritesheet("remus_werewolf","shattered_sword_assets/spritesheets/remus_werewolf.json"); this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); - - //load music here } updateScene(deltaT: number): void { diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 035c03e..9eebaaa 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -43,6 +43,7 @@ import GameOver from "./GameOver"; import GameFinish from "./GameFinish"; import MainMenu from "./MainMenu"; import MapTemplate from "../Tools/DataTypes/MapTemplate"; +import BullAI from "../AI/BullAI"; // TODO /** @@ -911,11 +912,14 @@ export default class GameLevel extends Scene { }) break; - case "remus_werewolf": - this.addEnemy("remus_werewolf", enemy.position.scale(32), EnemyAI, { + case "Bull": + this.addEnemy("Bull", enemy.position.scale(32), BullAI, { player: this.player, health: 200, tilemap: "Main", + scale: 1.5, + size: new Vec2(30,18), + offset : new Vec2(0, 27), exp: 50, }) break; diff --git a/src/shattered_sword/Scenes/Greatwall.ts b/src/shattered_sword/Scenes/Greatwall.ts index 6c1593e..2da2795 100644 --- a/src/shattered_sword/Scenes/Greatwall.ts +++ b/src/shattered_sword/Scenes/Greatwall.ts @@ -23,12 +23,8 @@ export default class Greatwall extends GameLevel { this.load.tilemapFromObject("map", this.map); //load enemies - - //can load enemy sprite here - //sprites obtained from cse380 sprite wesbite - // this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); - - //load music here + this.load.spritesheet("Bull","shattered_sword_assets/spritesheets/Bull.json"); + this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); } protected goToNextLevel(): void { this.viewport.setZoomLevel(1); diff --git a/src/shattered_sword/Scenes/Porcelain.ts b/src/shattered_sword/Scenes/Porcelain.ts index 90134c3..af7195f 100644 --- a/src/shattered_sword/Scenes/Porcelain.ts +++ b/src/shattered_sword/Scenes/Porcelain.ts @@ -22,14 +22,6 @@ export default class Porcelain extends GameLevel { console.log(this.map); this.load.tilemapFromObject("map", this.map); this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json"); - - // //load enemies - // this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json"); - // this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.json"); - - // //can load enemy sprite here - // //sprites obtained from cse380 sprite wesbite - // this.load.spritesheet("remus_werewolf","shattered_sword_assets/spritesheets/remus_werewolf.json"); this.load.spritesheet("black_pudding","shattered_sword_assets/spritesheets/black_pudding.json"); //load music here