private void OnGarageCreationStageChanged(CreationStage creationStage, CreationStage prevStage) { if (creationStage == CreationStage.Canceled || creationStage == CreationStage.Confirmed) { ChangeState(GameState.Gameplay); } }
private void OnCreationStageChanged(CreationStage creationStage, CreationStage previousStage) { if (creationStage == CreationStage.Canceled || creationStage == CreationStage.Confirmed) { AkSoundEngine.StopAll(); SceneManager.LoadScene(0); } }
private void ChangeStage(CreationStage creationStage) { CreationStage previousStage = currentStage; currentStage = creationStage; if (onCreationStageChanged != null) { onCreationStageChanged(creationStage, previousStage); } }
// Destroy the current version of the world private IEnumerator ClearWorld() { stage = CreationStage.destruction; SetProgress(0.0f); yield return(null); // ~~~ end frame // Clear beacons from late start LateStartCall = null; // Get list of pickups remaining PickupItem[] pickups = FindObjectsOfType <PickupItem>(); // Calculate total grids in world int gridCount = world.width / 10 * world.height / 10; // Set remaining operations to pickups + grid destruction int operations = pickups.Length + gridCount + 1; // Get grids from world Grid[,] grids = instantiatedWorldScript.grids; int cleared = 0; // Destroy grids foreach (Grid g in grids) { if (g != null) { Destroy(g.gameObject); cleared++; SetProgress((float)cleared / operations); yield return(null); } } // Destroy world Destroy(instantiatedWorld.gameObject); SetProgress((float)(cleared + 1) / operations); yield return(null); // ~~~ end frame // Destroy any left-over pickups if (pickups.Length > 0) { for (int i = 0; i < pickups.Length; ++i) { Destroy(pickups[i].gameObject); SetProgress((operations - pickups.Length + i + 1) / operations); yield return(null); // ~~~ end frame } } yield return(new WaitForSeconds(0.3f)); }
void UpdateLoadScreen(CreationStage stage, float progress) { progress = Mathf.Clamp(progress, 0.0f, 1.0f); // If onto a new stage change text if (stage != currentStage) { BitWorldKnowledge knowledge = BitWorldKnowledge.Instance; switch (stage) { case CreationStage.destruction: dialogue.color = knowledge.AirColourByWavelength[Wavelength.I]; progressBarImage.color = knowledge.AirColourByWavelength[Wavelength.VU]; dialogue.text = "Leaving previous area"; break; case CreationStage.creation: dialogue.color = knowledge.AirColourByWavelength[Wavelength.V]; progressBarImage.color = knowledge.AirColourByWavelength[Wavelength.IU]; dialogue.text = "Finding new test"; break; case CreationStage.initialisation: dialogue.color = knowledge.AirColourByWavelength[Wavelength.U]; progressBarImage.color = knowledge.AirColourByWavelength[Wavelength.IV]; dialogue.text = "Finalising details"; break; default: dialogue.text = "See you space cowboy!"; break; } } // Update progress bar progressBar.sizeDelta = new Vector2(progressBarGoal * progress, progressBar.sizeDelta.y); //progressBar.sizeDelta = new Vector2((self.rect.width - progressBarGoal) * (1.0f - progress), progressBar.sizeDelta.y); // Update % text percentage.text = ((int)(progress * 100)).ToString(); // Save new values currentProgress = progress; currentStage = stage; }
// Call when level completed private IEnumerator NextLevelCoroutine() { // Show loading screen LoadingBar.Instance?.ShowLoadingScreen(); // Reset loading stages creationProgress = new float[] { 0.0f, 0.0f, 0.0f }; // If a world exists destroy it and advance level iterator if (instantiatedWorld != null) { // Clear world yield return(StartCoroutine(ClearWorld())); // Clear input delegates InputManager.Instance.ResetManager(); // Advance level ++currentLevel; } // If the final level has been completed if (currentLevel == levels.Count) { SceneManager.LoadScene("Completed"); yield break; } // Select world png world = levels[currentLevel]; // Load new world yield return(StartCoroutine(MakeWorld())); // Initialise new world yield return(StartCoroutine(InitialiseWorld())); // Hide loading screen LoadingBar.Instance?.HideLoadingScreen(); stage = CreationStage.finished; yield return(null); BWCamera.Instance.GoToPlayer(); }
// Function for making the world private IEnumerator MakeWorld() { stage = CreationStage.creation; SetProgress(0.0f); yield return(null); BWCamera.Instance.ViewLoad(world.width / 10, world.height / 10); int gridCount = world.width / 10 * world.height / 10; int totalWork = world.width * world.height + gridCount; // The instantiated world prefab. Saving this allows easy parenting. instantiatedWorld = Instantiate(gridWorld, new Vector3(0, 0, 0), Quaternion.identity); // The world script attached to the prefab. Saving this prevents "GetComponent<>" instantiatedWorldScript = instantiatedWorld.GetComponent <World>(); // Spawn in the neccessary grids before moving on to bits MakeGrids(); // Update ui with 1/11th progress SetProgress((float)gridCount / totalWork); yield return(null); Color32 mapPixel; // Go through pixel by pixel and use their colours to populate the world for (int x = 0; x < world.width; ++x) { for (int y = 0; y < world.height; ++y) { // Get a pixel from the world map to be tested mapPixel = world.GetPixel(x, y); FindColour(x, y, mapPixel); } SetProgress((float)(gridCount + (x + 1) * world.height) / totalWork); yield return(null); } yield return(new WaitForSeconds(0.3f)); }
// Initialise all the bits (replaced Start()) private IEnumerator InitialiseWorld() { stage = CreationStage.initialisation; SetProgress(0.0f); yield return(null); Grid[,] grids = instantiatedWorldScript.grids; int gridCount = world.width / 10 * world.height / 10; int initialised = 0; foreach (Grid g in grids) { if (g != null) { g.InitialiseBits(); initialised++; SetProgress((float)initialised / gridCount); yield return(null); } } LateStartCall(); yield return(new WaitForSeconds(0.3f)); }
private void ChangeStage(CreationStage stage, CreationStage previousStage) { actionTitleText.text = stageMessages.First(sm => sm.stage == stage).message; switch (shipCreator.currentStage) { case (CreationStage.CreateName): break; case (CreationStage.SelectRoom): { if (previousStage == CreationStage.PlaceSystem) { RotatePlaceSystem(shipCreator.GetCurrentEditRotation()); } shipNameInputField.transform.parent.gameObject.SetActive(false); ResetRoomSelection(); ReengageRoomSelection(); break; } case (CreationStage.SelectSystem): { RoomName currentRoom = shipCreator.GetCurrentEditRoom(); RegisterNewRoomDisplayText(currentRoom); if (roomToAttachedSystem.ContainsKey(currentRoom)) { Destroy(roomToAttachedSystem[currentRoom]); roomToAttachedSystem.Remove(currentRoom); } ChangeRoomText(curEditIndexDisplayTable, shipCreator.GetCurrentEditRoom().ToString(), false); ReengageSystemSelection(); break; } case (CreationStage.PlaceSystem): { shipCreator.HideAllSystems(); RoomName currentRoom = shipCreator.GetCurrentEditRoom(); SystemName currentSystem = shipCreator.GetCurrentEditSystem(); currentPlacementSystem = shipCreator.CreateSampleSystem(currentSystem); roomToAttachedSystem.Add(currentRoom, currentPlacementSystem); ChangeSystemText(curEditIndexDisplayTable, currentSystem, false); break; } case (CreationStage.Finished): if (previousStage == CreationStage.PlaceSystem) { RotatePlaceSystem(shipCreator.GetCurrentEditRotation()); } ResetRoomSelection(); break; case (CreationStage.Confirmed): if (previousStage == CreationStage.PlaceSystem) { RotatePlaceSystem(shipCreator.GetCurrentEditRotation()); } ResetRoomSelection(); ResetPlacedSystems(); break; case (CreationStage.Canceled): ResetRoomSelection(); ResetPlacedSystems(); break; } }