2022-04-02 00:26:17 -04:00
|
|
|
|
2022-03-31 20:52:05 -04:00
|
|
|
import Scene from "../../Wolfie2D/Scene/Scene";
|
2022-04-02 00:26:17 -04:00
|
|
|
import ConfigManager from "../Tools/ConfigManager";
|
|
|
|
import SaveManager from "../Tools/SaveManager";
|
|
|
|
import Vec2 from "../../Wolfie2D/DataTypes/Vec2";
|
|
|
|
import { GameEventType } from "../../Wolfie2D/Events/GameEventType";
|
|
|
|
import AnimatedSprite from "../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
|
|
|
|
import Button from "../../Wolfie2D/Nodes/UIElements/Button";
|
|
|
|
import { UIElementType } from "../../Wolfie2D/Nodes/UIElements/UIElementTypes";
|
|
|
|
import Color from "../../Wolfie2D/Utils/Color";
|
|
|
|
import Layer from "../../Wolfie2D/Scene/Layer";
|
|
|
|
import Label from "../../Wolfie2D/Nodes/UIElements/Label";
|
|
|
|
import MainMenu from "./MainMenu";
|
2022-04-04 03:23:10 -04:00
|
|
|
import Tutorial from "./Tutorial";
|
2022-04-25 19:31:33 -04:00
|
|
|
import Porcelain from "./Porcelain";
|
|
|
|
import Greatwall from './Greatwall';
|
2022-04-02 00:26:17 -04:00
|
|
|
|
2022-03-31 20:52:05 -04:00
|
|
|
|
|
|
|
export default class Levels extends Scene {
|
2022-04-02 00:26:17 -04:00
|
|
|
private primary: Layer;
|
2022-03-31 20:52:05 -04:00
|
|
|
// TODO
|
2022-04-02 00:26:17 -04:00
|
|
|
loadScene(){}
|
|
|
|
startScene(){
|
|
|
|
const center = this.viewport.getCenter();
|
|
|
|
|
|
|
|
// The main menu
|
|
|
|
this.primary = this.addUILayer("primary");
|
|
|
|
|
|
|
|
|
2022-04-21 15:07:06 -04:00
|
|
|
const tutorial = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y - 50), text: "tutorial "});
|
2022-04-04 03:23:10 -04:00
|
|
|
tutorial.size.set(200, 50);
|
|
|
|
tutorial.borderWidth = 2;
|
|
|
|
tutorial.borderColor = Color.WHITE;
|
|
|
|
tutorial.backgroundColor = Color.TRANSPARENT;
|
|
|
|
tutorial.onClickEventId = "tutorial";
|
|
|
|
|
2022-04-21 15:07:06 -04:00
|
|
|
const porcelain = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y), text: "porcelain"});
|
2022-04-20 19:26:21 -04:00
|
|
|
porcelain.size.set(200, 50);
|
|
|
|
porcelain.borderWidth = 2;
|
|
|
|
porcelain.borderColor = Color.WHITE;
|
|
|
|
porcelain.backgroundColor = Color.TRANSPARENT;
|
|
|
|
porcelain.onClickEventId = "porcelain";
|
2022-04-02 00:26:17 -04:00
|
|
|
|
2022-04-25 19:31:33 -04:00
|
|
|
const greatwall = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y + 50), text: "greatwall"});
|
|
|
|
greatwall.size.set(200, 50);
|
|
|
|
greatwall.borderWidth = 2;
|
|
|
|
greatwall.borderColor = Color.WHITE;
|
|
|
|
greatwall.backgroundColor = Color.TRANSPARENT;
|
|
|
|
greatwall.onClickEventId = "greatwall";
|
|
|
|
|
|
|
|
const back = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y + 100), text: "Back"});
|
2022-04-02 00:26:17 -04:00
|
|
|
back.size.set(200, 50);
|
|
|
|
back.borderWidth = 2;
|
|
|
|
back.borderColor = Color.WHITE;
|
|
|
|
back.backgroundColor = Color.TRANSPARENT;
|
|
|
|
back.onClickEventId = "back";
|
|
|
|
|
2022-04-04 03:23:10 -04:00
|
|
|
this.receiver.subscribe("tutorial");
|
2022-04-20 19:26:21 -04:00
|
|
|
this.receiver.subscribe("porcelain");
|
2022-04-25 19:31:33 -04:00
|
|
|
this.receiver.subscribe("greatwall");
|
2022-04-02 00:26:17 -04:00
|
|
|
this.receiver.subscribe("back");
|
|
|
|
}
|
|
|
|
|
|
|
|
updateScene(){
|
|
|
|
while(this.receiver.hasNextEvent()){
|
|
|
|
let event = this.receiver.getNextEvent();
|
|
|
|
|
|
|
|
console.log(event);
|
|
|
|
|
2022-04-04 03:23:10 -04:00
|
|
|
|
|
|
|
if(event.type === "tutorial"){
|
2022-04-19 01:32:58 -04:00
|
|
|
let sceneOptions = {
|
|
|
|
physics: {
|
|
|
|
groupNames: ["ground", "player", "enemies"],
|
|
|
|
collisions:
|
|
|
|
[
|
|
|
|
[0, 1, 1],
|
|
|
|
[1, 0, 0],
|
|
|
|
[1, 0, 0]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.sceneManager.changeToScene(Tutorial, {}, sceneOptions);
|
2022-04-04 03:23:10 -04:00
|
|
|
}
|
|
|
|
|
2022-04-20 19:26:21 -04:00
|
|
|
if(event.type === "porcelain"){
|
|
|
|
let sceneOptions = {
|
|
|
|
physics: {
|
|
|
|
groupNames: ["ground", "player", "enemies"],
|
|
|
|
collisions:
|
|
|
|
[
|
|
|
|
[0, 1, 1],
|
|
|
|
[1, 0, 0],
|
|
|
|
[1, 0, 0]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.sceneManager.changeToScene(Porcelain, {}, sceneOptions);
|
2022-04-02 00:26:17 -04:00
|
|
|
}
|
2022-04-25 19:31:33 -04:00
|
|
|
|
|
|
|
if(event.type === "greatwall"){
|
|
|
|
let sceneOptions = {
|
|
|
|
physics: {
|
|
|
|
groupNames: ["ground", "player", "enemies"],
|
|
|
|
collisions:
|
|
|
|
[
|
|
|
|
[0, 1, 1],
|
|
|
|
[1, 0, 0],
|
|
|
|
[1, 0, 0]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.sceneManager.changeToScene(Greatwall, {}, sceneOptions);
|
|
|
|
}
|
|
|
|
|
2022-04-02 00:26:17 -04:00
|
|
|
if(event.type === "back"){
|
|
|
|
this.sceneManager.changeToScene(MainMenu, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-31 20:52:05 -04:00
|
|
|
}
|