diff --git a/dist/shattered_sword_assets/jsons/forest_template.json b/dist/shattered_sword_assets/jsons/forest_template.json index 383d6c8..f3960bf 100644 --- a/dist/shattered_sword_assets/jsons/forest_template.json +++ b/dist/shattered_sword_assets/jsons/forest_template.json @@ -52,7 +52,7 @@ "possibility": 1 } ], - "checkPoint": [5, 19, 5, 5] + "startCheckPoint": [25, 19, 5, 5] }, "exit": { "width": 30, @@ -76,7 +76,8 @@ "width": 3, "alt_tile": [0, 478] } - ] + ], + "endCheckPoint": [20, 16, 5, 5] }, "rooms": [ { diff --git a/dist/shattered_sword_assets/spritesheets/Hiro.json b/dist/shattered_sword_assets/spritesheets/Hiro.json index 3a09703..5f66021 100644 --- a/dist/shattered_sword_assets/spritesheets/Hiro.json +++ b/dist/shattered_sword_assets/spritesheets/Hiro.json @@ -3,7 +3,7 @@ "spriteSheetImage": "Hiro.png", "spriteWidth": 64, "spriteHeight": 64, - "columns": 7, + "columns": 8, "rows": 7, "durationType": "time", "animations": [ @@ -75,12 +75,12 @@ ] }, { - "name": "JUMP", + "name": "JUMP2", "repeat": false, "frames": [ { "index": 30, - "duration": 10 + "duration": 5 }, { "index": 31, @@ -96,12 +96,12 @@ }, { "index": 30, - "duration": 10 + "duration": 5 } ] }, { - "name": "JUMP_RIGHT", + "name": "JUMP", "repeat": false, "frames": [ { @@ -303,6 +303,32 @@ "duration": 10 } ] + }, + { + "name": "DASH", + "repeat": false, + "frames": [ + { + "index": 46, + "duration": 5 + }, + { + "index": 47, + "duration": 5 + }, + { + "index": 48, + "duration": 5 + }, + { + "index": 49, + "duration": 5 + }, + { + "index": 50, + "duration": 10 + } + ] } ] } \ No newline at end of file diff --git a/dist/shattered_sword_assets/spritesheets/Hiro.png b/dist/shattered_sword_assets/spritesheets/Hiro.png index 4fd5a90..5406695 100644 Binary files a/dist/shattered_sword_assets/spritesheets/Hiro.png and b/dist/shattered_sword_assets/spritesheets/Hiro.png differ 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 fa527f7..6f11526 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -39,6 +39,8 @@ import { TiledTilemapData } from "../../Wolfie2D/DataTypes/Tilesets/TiledData"; import AttackAction from "../AI/EnemyActions/AttackAction"; import Move from "../AI/EnemyActions/Move"; import GameOver from "./GameOver"; +import Porcelain from "./Porcelain"; +import Tutorial from "./Tutorial"; // TODO /** @@ -99,36 +101,45 @@ export default class GameLevel extends Scene { protected gameStateStack: Stack; // Story - private storytextLabel: Label; - private storyLayer: Layer; - private story: Story; - private storyProgress: number; - private storySprites: Array; - private storyBGMs: Array; - private currentSpeaker: string; - private currentContent: string; + protected storytextLabel: Label; + protected storyLayer: Layer; + protected story: Story; + protected storyProgress: number; + protected storySprites: Array; + protected storyBGMs: Array; + protected currentSpeaker: string; + protected currentContent: string; //buffs layer - buffLayer: Layer; - buffButton1 : Button; - buffLabel1 : Label; - buffButton2 : Button; - buffLabel2 : Label; - buffButton3 : Button; - buffLabel3: Label; - buffs: Array; + protected buffLayer: Layer; + protected buffButton1 : Button; + protected buffLabel1 : Label; + protected buffButton2 : Button; + protected buffLabel2 : Label; + protected buffButton3 : Button; + protected buffLabel3: Label; + protected buffs: Array; //pause layer - pauseLayer: Layer; - pauseText: Label; - pauseInput: TextInput; - pauseSubmit: Label; - pauseCheatText: Label; + protected pauseLayer: Layer; + protected pauseText: Label; + protected pauseInput: TextInput; + protected pauseSubmit: Label; + protected pauseCheatText: Label; protected randomSeed: number; protected rmg: RandomMapGenerator; protected map: TiledTilemapData; + protected startCheckPoint: Rect; + protected endCheckPoint: Rect; + protected touchedStartCheckPoint: boolean = false; + protected touchedEndCheckPoint: boolean = false; + protected static gameTimer: number = 0; + protected gameStarted: boolean = false; + protected timerLable: Label; + protected levelEnded: boolean = false; + startpos: Vec2; loadScene(): void { //can load player sprite here @@ -198,8 +209,10 @@ export default class GameLevel extends Scene { this.subscribeToEvents(); this.addUI(); - const checkPoint = this.rmg.getCheckPoint(); - this.addLevelEnd(new Vec2(checkPoint[0], checkPoint[1]), new Vec2(checkPoint[2], checkPoint[3])); + let startCheckPoint = this.rmg.getStartCheckPoint(); + this.startCheckPoint = this.addCheckPoint(new Vec2(startCheckPoint[0], startCheckPoint[1]), new Vec2(startCheckPoint[2], startCheckPoint[3]), "startStory", "startTimer"); + let endCheckPoint = this.rmg.getEndCheckPoint(); + this.endCheckPoint = this.addCheckPoint(new Vec2(endCheckPoint[0], endCheckPoint[1]), new Vec2(endCheckPoint[2], endCheckPoint[3]), "endStory", "nextLevel"); // Create an enemies array // Send the player and enemies to the battle manager @@ -250,7 +263,30 @@ export default class GameLevel extends Scene { updateScene(deltaT: number){ - + if (this.gameStateStack.peek() === GameState.GAMING) { + if (this.gameStarted) { + GameLevel.gameTimer += deltaT; + this.timerLable.textColor = Color.BLACK; + } + else { + this.timerLable.textColor = Color.RED; + } + let minutes = Math.floor(GameLevel.gameTimer / 60); + if (minutes >= 10) { + this.timerLable.text = minutes.toString(); + } + else { + this.timerLable.text = "0" + minutes.toString(); + } + let seconds = Math.floor(GameLevel.gameTimer % 60); + if (seconds >= 10) { + this.timerLable.text += ":" + seconds.toString(); + } + else { + this.timerLable.text += ":0" + seconds.toString(); + } + } + // Handle events and update the UI if needed while(this.receiver.hasNextEvent()){ let event = this.receiver.getNextEvent(); @@ -321,9 +357,23 @@ export default class GameLevel extends Scene { this.respawnPlayer(); } else{ //no more lives + this.viewport.setZoomLevel(1); this.sceneManager.changeToScene(GameOver, {}); + InputWrapper.enableInput(); } break; + case "startStory": + this.playStartStory(); + break; + case "endStory": + this.playEndStory(); + break; + case "startTimer": + this.startTimer(); + break; + case "nextLevel": + this.goToNextLevel(); + break; } } @@ -366,6 +416,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); @@ -398,7 +458,7 @@ export default class GameLevel extends Scene { // this.expLabel.sizeToText(); //update level ui - this.playerLevelLabel.text = "lv." + playerAI.level; + this.playerLevelLabel.text = "Lv." + playerAI.level; //update lives ui this.livesCountLabel.text = "Lives: " + playerAI.lives; @@ -410,36 +470,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 @@ -501,6 +531,10 @@ export default class GameLevel extends Scene { this.receiver.subscribe("buff2"); this.receiver.subscribe("buff3"); this.receiver.subscribe("cheat"); + this.receiver.subscribe("startStory"); + this.receiver.subscribe("startTimer"); + this.receiver.subscribe("endStory"); + this.receiver.subscribe("nextLevel"); } // TODO - @@ -543,8 +577,12 @@ export default class GameLevel extends Scene { - this.playerLevelLabel =