ShatteredSword/src/shattered_sword/Scenes/Tutorial.ts

56 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-04-04 03:23:10 -04:00
import Vec2 from "../../Wolfie2D/DataTypes/Vec2";
import RandomMapGenerator from "../Tools/RandomMapGenerator";
2022-04-04 03:23:10 -04:00
import GameLevel from "./GameLevel";
2022-04-24 22:26:35 -04:00
import SnakeAI from "../AI/SnakeAI";
import Porcelain from "./Porcelain";
2022-04-25 21:20:49 -04:00
import InputWrapper from "../Tools/InputWrapper";
2022-04-04 03:23:10 -04:00
export default class Tutorial extends GameLevel {
2022-04-04 03:23:10 -04:00
loadScene(): void {
2022-04-08 18:01:21 -04:00
super.loadScene();
2022-04-25 21:20:49 -04:00
this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", InputWrapper.randomSeed);
2022-04-13 18:56:35 -04:00
this.map = this.rmg.getMap();
this.load.tilemapFromObject("map", this.map);
//load enemies
2022-04-16 23:01:54 -04:00
this.load.spritesheet("Snake","shattered_sword_assets/spritesheets/Snake.json");
this.load.spritesheet("Tiger","shattered_sword_assets/spritesheets/Tiger.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");
2022-04-04 03:23:10 -04:00
//load music here
}
2022-04-21 13:46:09 -04:00
updateScene(deltaT: number): void {
super.updateScene(deltaT);
//spawn snake()
2022-04-25 22:54:26 -04:00
if(Math.random() < .0001 && this.gameStarted){
2022-04-21 13:46:09 -04:00
console.log("RANDOM SNAKE!");
2022-04-24 22:26:35 -04:00
this.addEnemy("Snake", this.player.position.clone().add(new Vec2(0,-320)), SnakeAI, {
2022-04-21 13:46:09 -04:00
player: this.player,
health: 50,
tilemap: "Main",
size: new Vec2(14,10),
offset : new Vec2(0, 22),
2022-04-21 13:46:09 -04:00
exp: 50,
})
}
}
protected goToNextLevel(): void {
2022-04-23 21:48:12 -04:00
this.viewport.setZoomLevel(1);
2022-04-23 21:54:28 -04:00
this.sceneManager.changeToScene(Porcelain);
}
protected playStartStory(): void {
if (!this.touchedStartCheckPoint) {
this.touchedStartCheckPoint = true;
this.storyLoader("shattered_sword_assets/jsons/level1story.json");
this.startTimer();
}
}
2022-04-04 03:23:10 -04:00
}