public IEnumerator InitGame(GameManager mode, WorldManager world) { TransitionController.instance.Transition(); AudioController.instance.ChangeMusic((int)(Random.Range(2, AudioController.instance.bgmClips.Length))); yield return(new WaitForSeconds(1.5f)); ScreenShake s = GameObject.Find("Camera").GetComponent <ScreenShake>(); s.ColorFade(s.day, 1); if (map) { DestroyImmediate(map.gameObject); } if (game) { DestroyImmediate(game.gameObject); } if (gameUI) { DestroyImmediate(gameUI.gameObject); } map = Instantiate(world, Vector3.zero, Quaternion.identity) as WorldManager; game = Instantiate(mode, Vector3.zero, Quaternion.identity) as GameManager; gameUI = Instantiate(gui, Vector3.zero, Quaternion.identity) as Canvas; }
IEnumerator ReturnToMainMenu() { TransitionController.instance.Transition(); AudioController.instance.ChangeMusic((int)(Random.Range(0, 2))); AudioController.instance.bgm.loop = true; yield return(new WaitForSeconds(1.0f)); //.instance.CloseCanvas(CanvasController.instance.pauseMenu); ScreenShake s = GameObject.Find("Camera").GetComponent <ScreenShake>(); s.ColorFade(s.sunset, 1); Destroy(map.gameObject); Destroy(gameUI.gameObject); Destroy(game.gameObject); map = null; gameUI = null; game = null; ObjectManager.Flush(); paused = false; //CanvasController.instance.gameUI = null; //CanvasController.instance.OpenCanvas(CanvasController.instance.mainMenu); }