From b59dc3e5853dbe4502a13b2da4ea286040fe0007 Mon Sep 17 00:00:00 2001 From: Renge Date: Sat, 23 Apr 2022 22:34:17 -0400 Subject: [PATCH] feat: added keys for buff --- src/main.ts | 4 ++- src/shattered_sword/Scenes/GameLevel.ts | 40 ++++++----------------- src/shattered_sword/Scenes/GameOver.ts | 2 ++ src/shattered_sword/Tools/InputWrapper.ts | 22 +++++++++---- 4 files changed, 31 insertions(+), 37 deletions(-) diff --git a/src/main.ts b/src/main.ts index e472016..dd1fd35 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,7 +27,9 @@ import WeaponTypeRegistry from "./shattered_sword/Registry/WeaponTypeRegistry"; {name: "inventory", keys: ["i","b"]}, {name: "pause", keys: ["escape"]}, {name: "tab", keys: ["tab"]}, - {name: "spawn", keys: ["q"]} //debug feature to test enemy spawning, press q to spawn enemy at current location + {name: "buff1", keys: ["1"]}, + {name: "buff2", keys: ["2"]}, + {name: "buff3", keys: ["3"]} ], useWebGL: false, // Tell the game we want to use webgl showDebug: false // Whether to show debug messages. You can change this to true if you want diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index ba24e2e..a56300c 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -418,6 +418,16 @@ export default class GameLevel extends Scene { } } + if (InputWrapper.isBuff1JustPresed()) { + this.emitter.fireEvent("buff1"); + } + if (InputWrapper.isBuff2JustPresed()) { + this.emitter.fireEvent("buff2"); + } + if (InputWrapper.isBuff3JustPresed()) { + this.emitter.fireEvent("buff3"); + } + //update health UI let playerAI = (this.player.ai); this.healthLabel.text = "Health: "+ Math.round(playerAI.CURRENT_HP) +'/' + Math.round(playerAI.MAX_HP +playerAI.CURRENT_BUFFS.hp); @@ -462,36 +472,6 @@ export default class GameLevel extends Scene { const baseViewportSize = this.viewport.getHalfSize().scaled(2); //check position of player this.playerFalloff(viewportCenter, baseViewportSize); - - // Update player safe position - // if (this.player.onGround) { - // this.playerSpawn = this.player.position.clone(); - // } - - //TODO - this is for testing - /* - if(InputWrapper.isSpawnJustPressed()){ - console.log("trying to spawn enemy"); - this.addEnemy("test_dummy",this.player.position,{player: this.player, - health :100, - tilemap: "Main", - //actions:actions, - goal: Statuses.REACHED_GOAL, - actions: [new AttackAction(3, [Statuses.IN_RANGE], [Statuses.REACHED_GOAL]), - new Move(2, [], [Statuses.IN_RANGE], {inRange: 60})], - status : [Statuses.CAN_RETREAT, Statuses.CAN_BERSERK], - weapon : this.createWeapon("knife") - }); - } - */ - - // if (InputWrapper.isInventoryJustPressed()) { - // console.log("LoadingStory"); - // this.storyLoader("shattered_sword_assets/jsons/story.json"); - // } - - - } // TODO put UI changes in here diff --git a/src/shattered_sword/Scenes/GameOver.ts b/src/shattered_sword/Scenes/GameOver.ts index 9cf3627..f33c6fa 100644 --- a/src/shattered_sword/Scenes/GameOver.ts +++ b/src/shattered_sword/Scenes/GameOver.ts @@ -3,12 +3,14 @@ import Label from "../../Wolfie2D/Nodes/UIElements/Label"; import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes"; import Scene from "../../Wolfie2D/Scene/Scene"; import Color from "../../Wolfie2D/Utils/Color"; +import { GameState } from "../sword_enums"; import InputWrapper from "../Tools/InputWrapper"; import MainMenu from "./MainMenu"; export default class GameOver extends Scene { startScene() { + InputWrapper.setState(GameState.PAUSE); const center = this.viewport.getCenter(); this.addUILayer("primary"); diff --git a/src/shattered_sword/Tools/InputWrapper.ts b/src/shattered_sword/Tools/InputWrapper.ts index 8545fc4..d19b576 100644 --- a/src/shattered_sword/Tools/InputWrapper.ts +++ b/src/shattered_sword/Tools/InputWrapper.ts @@ -103,15 +103,25 @@ export default class InputWrapper { return false; } - static isSpawnJustPressed(): boolean { - if (InputWrapper.gameState != GameState.GAMING) { + static isBuff1JustPresed(): boolean{ + if (InputWrapper.gameState != GameState.BUFF) { return false; } - - if (Input.isJustPressed("spawn")) { - return true; + return Input.isJustPressed("buff1"); + } + + static isBuff2JustPresed(): boolean{ + if (InputWrapper.gameState != GameState.BUFF) { + return false; } - return false; + return Input.isJustPressed("buff2"); + } + + static isBuff3JustPresed(): boolean{ + if (InputWrapper.gameState != GameState.BUFF) { + return false; + } + return Input.isJustPressed("buff3"); } static isPauseJustPressed(): boolean {