public void LoadLevel() { int levelIndex = GameProgression.CurrentLevelIndex; LevelSpecification levelSpec = levelSequence.Levels[levelIndex]; int gameNumber = TutorialManager.GetGameCount(); ++gameNumber; PlayerPrefs.SetInt(TutorialManager.GAME_COUNT_PREFS_KEY, gameNumber); if (gameNumber <= fixedLevelStartData.Levels.Length) { Level = SetUpFixedLevelStart(fixedLevelStartData.Levels[gameNumber - 1]); } else { Level = new LevelGenerator(levelSpec).GenerateValidLevel(); } Simulator simulator = new Simulator(Level.Board, levelSpec); if (gameNumber <= fixedLevelStartData.Levels.Length) { simulator.SetFixedCracks(fixedLevelStartData.Levels[gameNumber - 1].CrackedTiles); } predictionEditor.Initialize(simulator, Level.Board); boardRenderer.RenderInitial(Level.Board); playback.Initialize(simulator); }
public void StartScanning() { GameCreation.ResetBoard(); LevelSpecification level = GetComponent <LoadLevelBehaviour>().LevelSpecification; PlatformGenerator.PlatformRequirements = level.PlatformRequirements; PlatformGenerator.StartPlaneTracking(); }
private void OnLevelLoaded(LevelSpecification level) { Debug.Log(">>> Level is loaded :)"); // LevelSpecification = LevelSpecification.LoadDebug(level.Id); LevelSpecification = level; Debug.Log(">>> Level JSON: " + LevelSpecification.ToJSON()); Camera.enabled = true; GetComponent <ScanLevelBehaviour>().StartScanning(); }
override public void LoadNewLevel(int levelNo) { GameCreation.ResetBoard(); if (GetLevelFromServer) { LevelSpecificationRequester.Get(this, levelNo, OnLevelLoaded); } else { OnLevelLoaded(LevelSpecification.LoadDebug()); } }
public Simulator(Board initialBoard, LevelSpecification levelSpec) { board = initialBoard; this.levelSpec = levelSpec; colorCount = levelSpec.InitialColorCount; CracksPerChain = levelSpec.InitialCracksPerChain; if (TutorialManager.Instance) { TutorialManager.Instance.TutorialReady += OnTutorialReady; } // TODO: We probably want more control over the seed... rng = new Random(Time.frameCount); }
public void BuildGame(LevelSpecification level) { // Build board Debug.Log(">>> Building board from level " + level.ToJSON()); ResetBoard(); board = Instantiate(BoardPrefab, transform).GetComponent <PlatformBoardBehaviour>(); board.Build(level.PlatformRequirements[0]); // Locate board elements Debug.Log(">>> Board built, locating elements"); arpb2 = board.LocateElement(MainCharacterPrefab, level.Origin.Coordinate).GetComponent <MainCharacterBehaviour>(); arpb2.ResetPoints(); arpb2.Orientation = level.Origin.Orientation; if (level.Collectibles != null) { foreach (Collectible collectibe in level.Collectibles) { board.LocateElement(EnergyCellPrefab, collectibe.Coordinate); } } List <GameObject> pads = new List <GameObject>(); if (level.Pads != null) { foreach (Pad pad in level.Pads) { GameObject teleportPad = board.LocateElement(TeleportPadPrefab, pad.Coordinate); pads.Add(teleportPad); } pads[0].GetComponent <CustomTeleporter>().destinationPad[0] = pads[1].transform; pads[1].GetComponent <CustomTeleporter>().destinationPad[0] = pads[0].transform; } board.LocateElement(FlagPrefab, level.Destination.Coordinate); GetComponent <GameControllerBehaviour>().Board = board; GetComponent <GameControllerBehaviour>().ARPB2 = arpb2; Debug.Log(">>> All elements located"); }
public LevelGenerator(LevelSpecification levelSpec) { this.levelSpec = levelSpec; rng = new Random(Time.frameCount); }
private void OnLevelLoaded(LevelSpecification level) { LevelSpecification = level; level.PlatformRequirements[0].Platform = new DebugPlatform(); GameCreation.BuildGame(level); }
private void OnLevelSpecificationRetrieved(LevelSpecification level) { LevelSpecification = level; Finish(); OnLevelLoaded?.Invoke(level); }