fix: make randomseed static

This commit is contained in:
Renge 2022-04-25 21:20:49 -04:00
parent eff4d44bfb
commit ffa6650093
6 changed files with 10 additions and 7 deletions

View File

@ -126,7 +126,6 @@ export default class GameLevel extends Scene {
protected pauseSubmit: Label;
protected pauseCheatText: Label;
protected randomSeed: number;
protected rmg: RandomMapGenerator;
protected map: TiledTilemapData;
@ -175,8 +174,6 @@ export default class GameLevel extends Scene {
this.load.spritesheet("test_dummy","shattered_sword_assets/spritesheets/test_dummy.json")
this.enemies = new Array();
this.battleManager = new BattleManager();
this.randomSeed = Math.floor(Math.random() * 10000000000);
}
unloadScene(): void {
@ -572,7 +569,7 @@ export default class GameLevel extends Scene {
//seed label
//worldsize.x doesnt work how i want it to
this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(70, Math.floor(this.viewport.getHalfSize().y*2 - 30)), text: "Seed: "+ this.randomSeed });
this.seedLabel = <Label> this.add.uiElement(UIElementType.LABEL, "UI",{position: new Vec2(70, Math.floor(this.viewport.getHalfSize().y*2 - 30)), text: "Seed: "+ InputWrapper.randomSeed });
this.seedLabel.size.set(200, 50);
this.seedLabel.setHAlign(HAlign.LEFT);
this.seedLabel.textColor = Color.BLACK;

View File

@ -11,11 +11,12 @@ import { Statuses } from "../sword_enums";
import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB";
import EnemyAI from "../AI/EnemyAI";
import BattlerAI from "../AI/BattlerAI";
import InputWrapper from "../Tools/InputWrapper";
export default class Greatwall extends GameLevel {
loadScene(): void {
super.loadScene();
this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/greatwall_template.json", this.randomSeed);
this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/greatwall_template.json", InputWrapper.randomSeed);
this.map = this.rmg.getMap();
console.log(this.map);
this.load.tilemapFromObject("map", this.map);

View File

@ -14,6 +14,7 @@ import MainMenu from "./MainMenu";
import Tutorial from "./Tutorial";
import Porcelain from "./Porcelain";
import Greatwall from './Greatwall';
import InputWrapper from "../Tools/InputWrapper";
export default class Levels extends Scene {
@ -69,6 +70,7 @@ export default class Levels extends Scene {
if(event.type === "start"){
InputWrapper.randomSeed = Math.floor(Math.random() * 10000000000).toString();;
let sceneOptions = {
physics: {
groupNames: ["ground", "player", "enemies"],

View File

@ -11,11 +11,12 @@ import { Statuses } from "../sword_enums";
import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB";
import EnemyAI from "../AI/EnemyAI";
import BattlerAI from "../AI/BattlerAI";
import InputWrapper from "../Tools/InputWrapper";
export default class Porcelain extends GameLevel {
loadScene(): void {
super.loadScene();
this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/porcelain_template.json", this.randomSeed);
this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/porcelain_template.json", InputWrapper.randomSeed);
this.map = this.rmg.getMap();
console.log(this.map);
this.load.tilemapFromObject("map", this.map);

View File

@ -3,11 +3,12 @@ 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", this.randomSeed);
this.rmg = new RandomMapGenerator("shattered_sword_assets/jsons/forest_template.json", InputWrapper.randomSeed);
this.map = this.rmg.getMap();
this.load.tilemapFromObject("map", this.map);

View File

@ -3,6 +3,7 @@ import {GameState} from "../sword_enums";
export default class InputWrapper {
private static gameState: GameState = GameState.GAMING;
static randomSeed: string;
static isUpPressed(): boolean {
if (InputWrapper.gameState != GameState.GAMING) {