From e6f1cbcf3996e04e00af42eea16f2e64dc7ee34b Mon Sep 17 00:00:00 2001 From: OfficialCHenry Date: Tue, 19 Apr 2022 02:16:29 -0400 Subject: [PATCH] added gaining shield on hit --- .../spritesheets/Hiro.json | 4 +-- .../spritesheets/Hiro1.json | 27 ------------------ .../spritesheets/Hiro1.png | Bin 819 -> 0 bytes src/shattered_sword/AI/EnemyStates/Patrol.ts | 7 ++++- .../GameSystems/BattleManager.ts | 5 ++++ .../Player/PlayerController.ts | 20 ++++++------- .../Player/PlayerStates/Walk.ts | 2 +- src/shattered_sword/Scenes/GameLevel.ts | 1 - 8 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 dist/shattered_sword_assets/spritesheets/Hiro1.json delete mode 100644 dist/shattered_sword_assets/spritesheets/Hiro1.png diff --git a/dist/shattered_sword_assets/spritesheets/Hiro.json b/dist/shattered_sword_assets/spritesheets/Hiro.json index d5b285f..bc3ec3f 100644 --- a/dist/shattered_sword_assets/spritesheets/Hiro.json +++ b/dist/shattered_sword_assets/spritesheets/Hiro.json @@ -212,11 +212,11 @@ "frames": [ { "index": 0, - "duration": 50 + "duration": 500 }, { "index": 39, - "duration": 50 + "duration": 500 } ] }, diff --git a/dist/shattered_sword_assets/spritesheets/Hiro1.json b/dist/shattered_sword_assets/spritesheets/Hiro1.json deleted file mode 100644 index f593278..0000000 --- a/dist/shattered_sword_assets/spritesheets/Hiro1.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "Hiro", - "spriteSheetImage": "Hiro.png", - "spriteWidth": 32, - "spriteHeight": 32, - "columns": 1, - "rows": 1, - "durationType": "time", - "animations": [ - { - "name": "IDLE", - "frames": [ {"index": 0, "duration": 540} ] - }, - { - "name": "JUMP", - "frames":[ {"index": 0, "duration": 32}] - }, - { - "name": "WALK", - "frames": [ {"index": 0, "duration": 540} ] - }, - { - "name": "FALL", - "frames": [ {"index": 0, "duration": 540} ] - } - ] -} \ No newline at end of file diff --git a/dist/shattered_sword_assets/spritesheets/Hiro1.png b/dist/shattered_sword_assets/spritesheets/Hiro1.png deleted file mode 100644 index 729338f5d8e9d5eda2b61c75a0d21604ac7354b6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 819 zcmV-31I+x1P)Px%?MXyIR9JTCjBQ+Qqp; zM~8Op9=Zsb90I{1gLdd7C`ct%IYe73l%{x)T)YnTd%kz~?(SXEKLqaHz3=^h_r3SN zdr3i4p1tbPb*j9b(v6E#;(-Xns5Ar5+<}{TyhH(>z3Lg2CK@G^w{_Cf{Cea3FfoXB zN0wop%9u<^jgpDA3r8D73xLd3rXmyo6tfJMJr@A9Kw<${hIyNlv;2PJ{4ih|CjwEy zXaUf5)Z405%rXGreTrFz>RDF;i3A{Xl`%;NK-G8c!ht(*Q_LSEnr}|d!n!%p8c;|6 zcmPO;nKw!%H!o(HGT7ht>~jskza0`bJ=L==s%Kq31pxq-Vcy>QZ|yHx8Cz%6bsH3;a9a$yZytzn8zSjQ!pH8GumvY1IL7FwxL% zeF}{$KYbYh$>qkAXMhHvG>WEUh4An{SG<0q^!Np?uYV~4l-p3$;JAgsaf_Re6;k{M z022%AftZPfb*W!>e~T~3!~psE=ji=7!uRIe$TyA~BTPCYdH`_MdWYVX0^6abZDGA9|8Ci^2n5jY{**yyHmyKF-uQh-i+E1D0XZ$x2k@$H;FEKsLAJ?*x5>C=(Pj^r4if-GK{n z0TO_*+zw2I1iMp%vD}UX2tAUC): void { //this.currentPath = this.getNextPath(); - (this.owner).animation.play("IDLE", true); + //if(!(this.owner).animation.isPlaying("DYING")){ + //(this.owner).animation.queue("IDLE", true); + //} + //else{ + (this.owner).animation.playIfNotAlready("IDLE", true); + //} } handleInput(event: GameEvent): void { } diff --git a/src/shattered_sword/GameSystems/BattleManager.ts b/src/shattered_sword/GameSystems/BattleManager.ts index ba62595..fa55b93 100644 --- a/src/shattered_sword/GameSystems/BattleManager.ts +++ b/src/shattered_sword/GameSystems/BattleManager.ts @@ -20,6 +20,10 @@ export default class BattleManager { if (weapon.hits(enemy.owner)) { enemy.damage(weapon.type.damage + weapon.EXTRA_DAMAGE); //console.log("enemy took dmg"); + + //TODO - test shield, + //add checking for each onhit buff here + (this.players[0]).addShield(1); } } } @@ -28,6 +32,7 @@ export default class BattleManager { for (let player of this.players) { if (weapon.hits(player.owner)) { (player).damage(weapon.type.damage, user); + } } } diff --git a/src/shattered_sword/Player/PlayerController.ts b/src/shattered_sword/Player/PlayerController.ts index 313430f..65c433c 100644 --- a/src/shattered_sword/Player/PlayerController.ts +++ b/src/shattered_sword/Player/PlayerController.ts @@ -72,10 +72,8 @@ export default class PlayerController extends StateMachineAI implements BattlerA CURRENT_DEF: number = 100; CURRENT_EXP : number = 0; MAX_EXP : number = 100; - //shield buff CURRENT_SHIELD : number =0; MAX_SHIELD : number = 20; - invincible : boolean = false; tilemap: OrthogonalTilemap; @@ -85,7 +83,6 @@ export default class PlayerController extends StateMachineAI implements BattlerA airjumps:number = 0; private lookDirection: Vec2; - /** A list of items in the game world */ private items: Array; @@ -110,20 +107,21 @@ export default class PlayerController extends StateMachineAI implements BattlerA //shield absorbs the damage and sends dmg back to attacker if(this.CURRENT_SHIELD > 0){ let newshield = Math.max(0, this.CURRENT_SHIELD - damage ); //calculate the new shield value - (attacker._ai).damage(this.CURRENT_SHIELD - newshield); //damage the attacker the dmg taken to shield + if( attacker !== undefined){ + (attacker._ai).damage(this.CURRENT_SHIELD - newshield); //damage the attacker the dmg taken to shield + } this.CURRENT_SHIELD = newshield; //update shield value } else{ //i frame here PlayerController.invincibilityTimer.start(); this.invincible = true; - - (this.owner).animation.playIfNotAlready("HURT", false); + //console.log("hurt anim"); + (this.owner).animation.play("HURT" ); this.CURRENT_HP -= damage; if(this.CURRENT_HP <= 0){ - this.emitter.fireEvent(Player_Events.PLAYER_KILLED); - (this.owner).animation.playIfNotAlready("DYING", false); - (this.owner).animation.queue("DEAD", false); + (this.owner).animation.play("DYING"); + (this.owner).animation.queue("DEAD", true, Player_Events.PLAYER_KILLED); } } @@ -236,7 +234,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA //this.addBuff( {type:BuffType.HEALTH, value:1} ); //i frame timer - PlayerController.invincibilityTimer = new Timer(400); + PlayerController.invincibilityTimer = new Timer(2000); } initializePlatformer(): void { @@ -285,7 +283,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA //testing the attacks here, may be moved to another place later if(InputWrapper.isAttackJustPressed()){ let item = this.inventory.getItem(); - (this.owner).animation.playIfNotAlready("ATTACK", true); + (this.owner).animation.play("ATTACK", true); //TODO - get proper look direction this.lookDirection.x = (this.owner).invertX ? -1 : 1; // If there is an item in the current slot, use it diff --git a/src/shattered_sword/Player/PlayerStates/Walk.ts b/src/shattered_sword/Player/PlayerStates/Walk.ts index e00b116..af79454 100644 --- a/src/shattered_sword/Player/PlayerStates/Walk.ts +++ b/src/shattered_sword/Player/PlayerStates/Walk.ts @@ -13,7 +13,7 @@ export default class Walk extends OnGround { update(deltaT: number): void { - //console.log("walking anim"); + console.log("walking anim"); this.owner.animation.playIfNotAlready("WALK", true); let dir = this.getInputDirection(); diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 92048f3..3b8374b 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -718,7 +718,6 @@ export default class GameLevel extends Scene { } if(typeof enemy != undefined && typeof player != undefined){ //damage the player - console.log("player collision damage"); (this.player._ai).damage(10); //10 collision dmg for now }