From fd0977079ec2a07d7d63b032d19a0856fcb2b748 Mon Sep 17 00:00:00 2001 From: Renge Date: Sat, 7 May 2022 20:37:21 -0400 Subject: [PATCH] fix: rename Tutorial to Forest, fix player position; Feat: trigger for Greatwall --- .../jsons/forest_template.json | 2 +- .../jsons/greatwall_template.json | 9 +-- .../jsons/porcelain_template.json | 2 +- src/shattered_sword/Scenes/GameLevel.ts | 5 -- src/shattered_sword/Scenes/Greatwall.ts | 32 +++++++++ src/shattered_sword/Scenes/Levels.ts | 4 +- src/shattered_sword/Scenes/Porcelain.ts | 9 +++ src/shattered_sword/Scenes/Tutorial.ts | 66 ------------------- 8 files changed, 50 insertions(+), 79 deletions(-) delete mode 100644 src/shattered_sword/Scenes/Tutorial.ts diff --git a/dist/shattered_sword_assets/jsons/forest_template.json b/dist/shattered_sword_assets/jsons/forest_template.json index 44edb61..ec913d8 100644 --- a/dist/shattered_sword_assets/jsons/forest_template.json +++ b/dist/shattered_sword_assets/jsons/forest_template.json @@ -37,7 +37,7 @@ { "type": "player", "x": 5, - "y": 19 + "y": 17 } ], "startCheckPoint": [15, 15, 15, 15] diff --git a/dist/shattered_sword_assets/jsons/greatwall_template.json b/dist/shattered_sword_assets/jsons/greatwall_template.json index 1e6f7d5..79cc50a 100644 --- a/dist/shattered_sword_assets/jsons/greatwall_template.json +++ b/dist/shattered_sword_assets/jsons/greatwall_template.json @@ -29,10 +29,10 @@ { "type": "player", "x": 5, - "y": 11 + "y": 9 } - ] - + ], + "startCheckPoint": [30, 7, 1, 12] }, "exit": { "width": 33, @@ -52,7 +52,8 @@ "width": 3, "alt_tile": [0, 5] } - ] + ], + "endCheckPoint": [30, 7, 1, 12] }, "rooms": [ { diff --git a/dist/shattered_sword_assets/jsons/porcelain_template.json b/dist/shattered_sword_assets/jsons/porcelain_template.json index ad02e34..cf7fd87 100644 --- a/dist/shattered_sword_assets/jsons/porcelain_template.json +++ b/dist/shattered_sword_assets/jsons/porcelain_template.json @@ -39,7 +39,7 @@ { "type": "player", "x": 5, - "y": 10 + "y": 8 }, { "type": "Tiger", diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 50db651..5745b18 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -40,11 +40,6 @@ import Sprite from "../../Wolfie2D/Nodes/Sprites/Sprite"; import TextInput from "../../Wolfie2D/Nodes/UIElements/TextInput"; import { TiledTilemapData } from "../../Wolfie2D/DataTypes/Tilesets/TiledData"; import GameOver from "./GameOver"; -import Porcelain from "./Porcelain"; -import Tutorial from "./Tutorial"; -import Greatwall from "./Greatwall"; -import Snow from "./Snow"; -import Market from "./Market"; import MainMenu from "./MainMenu"; // TODO diff --git a/src/shattered_sword/Scenes/Greatwall.ts b/src/shattered_sword/Scenes/Greatwall.ts index 08bf944..0cfa88f 100644 --- a/src/shattered_sword/Scenes/Greatwall.ts +++ b/src/shattered_sword/Scenes/Greatwall.ts @@ -29,4 +29,36 @@ export default class Greatwall extends GameLevel { //load music here } + 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(Greatwall, {}, sceneOptions); + } + + protected playStartStory(): void { + if (!this.touchedStartCheckPoint) { + this.touchedStartCheckPoint = true; + this.storyLoader("shattered_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 6a43ab2..8427ff9 100644 --- a/src/shattered_sword/Scenes/Levels.ts +++ b/src/shattered_sword/Scenes/Levels.ts @@ -11,7 +11,7 @@ import Color from "../../Wolfie2D/Utils/Color"; import Layer from "../../Wolfie2D/Scene/Layer"; import Label from "../../Wolfie2D/Nodes/UIElements/Label"; import MainMenu from "./MainMenu"; -import Tutorial from "./Tutorial"; +import Forest from "./Forest"; import Porcelain from "./Porcelain"; import Greatwall from './Greatwall'; import Snow from './Snow'; @@ -114,7 +114,7 @@ export default class Levels extends Scene { ] } } - this.sceneManager.changeToScene(Tutorial, {}, sceneOptions); + this.sceneManager.changeToScene(Forest, {}, sceneOptions); } if(event.type === "porcelain"){ diff --git a/src/shattered_sword/Scenes/Porcelain.ts b/src/shattered_sword/Scenes/Porcelain.ts index c2258f0..5e7bbf8 100644 --- a/src/shattered_sword/Scenes/Porcelain.ts +++ b/src/shattered_sword/Scenes/Porcelain.ts @@ -57,4 +57,13 @@ export default class Porcelain extends GameLevel { 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/Tutorial.ts b/src/shattered_sword/Scenes/Tutorial.ts deleted file mode 100644 index 633395c..0000000 --- a/src/shattered_sword/Scenes/Tutorial.ts +++ /dev/null @@ -1,66 +0,0 @@ -import Vec2 from "../../Wolfie2D/DataTypes/Vec2"; -import RandomMapGenerator from "../Tools/RandomMapGenerator"; -import GameLevel from "./GameLevel"; -import SnakeAI from "../AI/SnakeAI"; -import Porcelain from "./Porcelain"; -import InputWrapper from "../Tools/InputWrapper"; - -export default class Tutorial extends GameLevel { - loadScene(): void { - super.loadScene(); - this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", InputWrapper.randomSeed); - this.map = this.rmg.getMap(); - this.load.tilemapFromObject("map", this.map); - - //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 { - super.updateScene(deltaT); - - //spawn snake() - if(Math.random() < .0001 && this.gameStarted){ - console.log("RANDOM SNAKE!"); - this.addEnemy("Snake", this.player.position.clone().add(new Vec2(0,-320)), SnakeAI, { - player: this.player, - health: 50, - tilemap: "Main", - size: new Vec2(14,10), - offset : new Vec2(0, 22), - exp: 50, - }) - } - } - - 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(Porcelain, {}, sceneOptions); - } - - protected playStartStory(): void { - if (!this.touchedStartCheckPoint) { - this.touchedStartCheckPoint = true; - this.storyLoader("shattered_sword_assets/jsons/level1story.json"); - this.startTimer(); - } - } -} \ No newline at end of file