From 5da79c3bf06cad77924494268113627526fdb549 Mon Sep 17 00:00:00 2001 From: Renge Date: Mon, 9 May 2022 13:06:46 -0400 Subject: [PATCH] feat: add end --- src/shattered_sword/Scenes/End.ts | 53 ++++++++++++++++++++++++++++ src/shattered_sword/Scenes/Levels.ts | 23 ++++++++++++ src/shattered_sword/Scenes/Start.ts | 4 --- 3 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 src/shattered_sword/Scenes/End.ts diff --git a/src/shattered_sword/Scenes/End.ts b/src/shattered_sword/Scenes/End.ts new file mode 100644 index 0000000..dcc9fb9 --- /dev/null +++ b/src/shattered_sword/Scenes/End.ts @@ -0,0 +1,53 @@ +import Vec2 from "../../Wolfie2D/DataTypes/Vec2"; +import RandomMapGenerator from "../Tools/RandomMapGenerator"; +import GameLevel from "./GameLevel"; +import InputWrapper from "../Tools/InputWrapper"; +import Forest from "./Forest"; + +export default class End extends GameLevel { + loadScene(): void { + super.loadScene(); + this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/castle_template.json", InputWrapper.randomSeed); + this.map = this.rmg.getMap(); + this.load.tilemapFromObject("map", this.map); + + //load enemies + } + + updateScene(deltaT: number): void { + super.updateScene(deltaT); + } + + protected goToNextLevel(): void { + this.viewport.setZoomLevel(1); + let sceneOptions = { + physics: { + groupNames: ["ground", "player", "enemies"], + collisions: + [ + [0, 1, 1], + [1, 0, 0], + [1, 0, 0] + ] + } + } + this.sceneManager.changeToScene(Forest, {}, sceneOptions); + } + + protected playStartStory(): void { + if (!this.touchedStartCheckPoint) { + this.touchedStartCheckPoint = true; + this.storyLoader("shattered_sword_assetsshattered_sword_assets/jsons/level1story.json"); + this.startTimer(); + } + } + + protected playEndStory() { + if (!this.touchedEndCheckPoint) { + this.touchedEndCheckPoint = true; + this.storyLoader("shattered_sword_assets/jsons/story.json"); + this.endTimer(); + this.levelEnded = true; + } + } +} \ No newline at end of file diff --git a/src/shattered_sword/Scenes/Levels.ts b/src/shattered_sword/Scenes/Levels.ts index 686048f..06ef0ea 100644 --- a/src/shattered_sword/Scenes/Levels.ts +++ b/src/shattered_sword/Scenes/Levels.ts @@ -17,6 +17,7 @@ import Porcelain from "./Porcelain"; import Greatwall from './Greatwall'; import Snow from './Snow'; import Market from './Market'; +import End from './End' import InputWrapper from "../Tools/InputWrapper"; import TextInput from "../../Wolfie2D/Nodes/UIElements/TextInput"; @@ -243,6 +244,28 @@ export default class Levels extends Scene { this.sceneManager.changeToScene(Market, {}, sceneOptions); } + if(event.type === "end"){ + if (this.seedInput.text) { + InputWrapper.randomSeed = this.seedInput.text; + this.seedInput.text = ""; + } + else { + InputWrapper.randomSeed = Math.floor(Math.random() * 10000000000).toString(); + } + let sceneOptions = { + physics: { + groupNames: ["ground", "player", "enemies"], + collisions: + [ + [0, 1, 1], + [1, 0, 0], + [1, 0, 0] + ] + } + } + this.sceneManager.changeToScene(End, {}, sceneOptions); + } + if(event.type === "back"){ this.sceneManager.changeToScene(MainMenu, {}); } diff --git a/src/shattered_sword/Scenes/Start.ts b/src/shattered_sword/Scenes/Start.ts index f7274d7..aaaa77f 100644 --- a/src/shattered_sword/Scenes/Start.ts +++ b/src/shattered_sword/Scenes/Start.ts @@ -14,10 +14,6 @@ export default class Start extends GameLevel { //load enemies } - updateScene(deltaT: number): void { - super.updateScene(deltaT); - } - protected goToNextLevel(): void { this.viewport.setZoomLevel(1); let sceneOptions = {