fix: make randomseed static
This commit is contained in:
parent
eff4d44bfb
commit
ffa6650093
|
@ -126,7 +126,6 @@ export default class GameLevel extends Scene {
|
||||||
protected pauseSubmit: Label;
|
protected pauseSubmit: Label;
|
||||||
protected pauseCheatText: Label;
|
protected pauseCheatText: Label;
|
||||||
|
|
||||||
protected randomSeed: number;
|
|
||||||
protected rmg: RandomMapGenerator;
|
protected rmg: RandomMapGenerator;
|
||||||
protected map: TiledTilemapData;
|
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.load.spritesheet("test_dummy","shattered_sword_assets/spritesheets/test_dummy.json")
|
||||||
this.enemies = new Array();
|
this.enemies = new Array();
|
||||||
this.battleManager = new BattleManager();
|
this.battleManager = new BattleManager();
|
||||||
|
|
||||||
this.randomSeed = Math.floor(Math.random() * 10000000000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unloadScene(): void {
|
unloadScene(): void {
|
||||||
|
@ -572,7 +569,7 @@ export default class GameLevel extends Scene {
|
||||||
|
|
||||||
//seed label
|
//seed label
|
||||||
//worldsize.x doesnt work how i want it to
|
//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.size.set(200, 50);
|
||||||
this.seedLabel.setHAlign(HAlign.LEFT);
|
this.seedLabel.setHAlign(HAlign.LEFT);
|
||||||
this.seedLabel.textColor = Color.BLACK;
|
this.seedLabel.textColor = Color.BLACK;
|
||||||
|
|
|
@ -11,11 +11,12 @@ import { Statuses } from "../sword_enums";
|
||||||
import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB";
|
import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB";
|
||||||
import EnemyAI from "../AI/EnemyAI";
|
import EnemyAI from "../AI/EnemyAI";
|
||||||
import BattlerAI from "../AI/BattlerAI";
|
import BattlerAI from "../AI/BattlerAI";
|
||||||
|
import InputWrapper from "../Tools/InputWrapper";
|
||||||
|
|
||||||
export default class Greatwall extends GameLevel {
|
export default class Greatwall extends GameLevel {
|
||||||
loadScene(): void {
|
loadScene(): void {
|
||||||
super.loadScene();
|
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();
|
this.map = this.rmg.getMap();
|
||||||
console.log(this.map);
|
console.log(this.map);
|
||||||
this.load.tilemapFromObject("map", this.map);
|
this.load.tilemapFromObject("map", this.map);
|
||||||
|
|
|
@ -14,6 +14,7 @@ import MainMenu from "./MainMenu";
|
||||||
import Tutorial from "./Tutorial";
|
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";
|
||||||
|
|
||||||
|
|
||||||
export default class Levels extends Scene {
|
export default class Levels extends Scene {
|
||||||
|
@ -69,6 +70,7 @@ export default class Levels extends Scene {
|
||||||
|
|
||||||
|
|
||||||
if(event.type === "start"){
|
if(event.type === "start"){
|
||||||
|
InputWrapper.randomSeed = Math.floor(Math.random() * 10000000000).toString();;
|
||||||
let sceneOptions = {
|
let sceneOptions = {
|
||||||
physics: {
|
physics: {
|
||||||
groupNames: ["ground", "player", "enemies"],
|
groupNames: ["ground", "player", "enemies"],
|
||||||
|
|
|
@ -11,11 +11,12 @@ import { Statuses } from "../sword_enums";
|
||||||
import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB";
|
import AABB from "../../Wolfie2D/DataTypes/Shapes/AABB";
|
||||||
import EnemyAI from "../AI/EnemyAI";
|
import EnemyAI from "../AI/EnemyAI";
|
||||||
import BattlerAI from "../AI/BattlerAI";
|
import BattlerAI from "../AI/BattlerAI";
|
||||||
|
import InputWrapper from "../Tools/InputWrapper";
|
||||||
|
|
||||||
export default class Porcelain extends GameLevel {
|
export default class Porcelain extends GameLevel {
|
||||||
loadScene(): void {
|
loadScene(): void {
|
||||||
super.loadScene();
|
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();
|
this.map = this.rmg.getMap();
|
||||||
console.log(this.map);
|
console.log(this.map);
|
||||||
this.load.tilemapFromObject("map", this.map);
|
this.load.tilemapFromObject("map", this.map);
|
||||||
|
|
|
@ -3,11 +3,12 @@ import RandomMapGenerator from "../Tools/RandomMapGenerator";
|
||||||
import GameLevel from "./GameLevel";
|
import GameLevel from "./GameLevel";
|
||||||
import SnakeAI from "../AI/SnakeAI";
|
import SnakeAI from "../AI/SnakeAI";
|
||||||
import Porcelain from "./Porcelain";
|
import Porcelain from "./Porcelain";
|
||||||
|
import InputWrapper from "../Tools/InputWrapper";
|
||||||
|
|
||||||
export default class Tutorial extends GameLevel {
|
export default class Tutorial extends GameLevel {
|
||||||
loadScene(): void {
|
loadScene(): void {
|
||||||
super.loadScene();
|
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.map = this.rmg.getMap();
|
||||||
this.load.tilemapFromObject("map", this.map);
|
this.load.tilemapFromObject("map", this.map);
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import {GameState} from "../sword_enums";
|
||||||
|
|
||||||
export default class InputWrapper {
|
export default class InputWrapper {
|
||||||
private static gameState: GameState = GameState.GAMING;
|
private static gameState: GameState = GameState.GAMING;
|
||||||
|
static randomSeed: string;
|
||||||
|
|
||||||
static isUpPressed(): boolean {
|
static isUpPressed(): boolean {
|
||||||
if (InputWrapper.gameState != GameState.GAMING) {
|
if (InputWrapper.gameState != GameState.GAMING) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user