fix: add Forest

This commit is contained in:
Renge 2022-05-07 20:53:32 -04:00
parent fd0977079e
commit a906d19842

View File

@ -0,0 +1,75 @@
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 Forest 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();
}
}
protected playEndStory() {
if (!this.touchedEndCheckPoint) {
this.touchedEndCheckPoint = true;
this.storyLoader("shattered_sword_assets/jsons/story.json");
this.endTimer();
this.levelEnded = true;
}
}
}