feat: add seed customizer

This commit is contained in:
Renge 2022-04-25 23:34:32 -04:00
parent 136ef0ca94
commit 973c22dc3f

View File

@ -15,10 +15,12 @@ import Tutorial from "./Tutorial";
import Porcelain from "./Porcelain"; import Porcelain from "./Porcelain";
import Greatwall from './Greatwall'; import Greatwall from './Greatwall';
import InputWrapper from "../Tools/InputWrapper"; import InputWrapper from "../Tools/InputWrapper";
import TextInput from "../../Wolfie2D/Nodes/UIElements/TextInput";
export default class Levels extends Scene { export default class Levels extends Scene {
private primary: Layer; private primary: Layer;
private seedInput: TextInput;
// TODO // TODO
loadScene(){} loadScene(){}
startScene(){ startScene(){
@ -28,12 +30,18 @@ export default class Levels extends Scene {
this.primary = this.addUILayer("primary"); this.primary = this.addUILayer("primary");
const tutorial = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y - 100), text: "Start Game"}); const seedHint = <Label>this.add.uiElement(UIElementType.LABEL, "primary", {position: new Vec2(center.x, center.y - 200), text: "Enter seed or leave it blank to randomly generate one"});
tutorial.size.set(200, 50); seedHint.textColor = Color.WHITE;
tutorial.borderWidth = 2;
tutorial.borderColor = Color.WHITE; this.seedInput = <TextInput>this.add.uiElement(UIElementType.TEXT_INPUT, "primary", {position: new Vec2(center.x, center.y - 150), text: ""})
tutorial.backgroundColor = Color.TRANSPARENT; this.seedInput.size.set(200, 50);
tutorial.onClickEventId = "start";
const start = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y - 100), text: "Start Game"});
start.size.set(200, 50);
start.borderWidth = 2;
start.borderColor = Color.WHITE;
start.backgroundColor = Color.TRANSPARENT;
start.onClickEventId = "start";
const porcelain = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y), text: "porcelain(Test)"}); const porcelain = this.add.uiElement(UIElementType.BUTTON, "primary", {position: new Vec2(center.x, center.y), text: "porcelain(Test)"});
porcelain.size.set(200, 50); porcelain.size.set(200, 50);
@ -70,7 +78,13 @@ export default class Levels extends Scene {
if(event.type === "start"){ if(event.type === "start"){
InputWrapper.randomSeed = Math.floor(Math.random() * 10000000000).toString();; if (this.seedInput.text) {
InputWrapper.randomSeed = this.seedInput.text;
this.seedInput.text = "";
}
else {
InputWrapper.randomSeed = Math.floor(Math.random() * 10000000000).toString();
}
let sceneOptions = { let sceneOptions = {
physics: { physics: {
groupNames: ["ground", "player", "enemies"], groupNames: ["ground", "player", "enemies"],