private IEnumerator ChangeStateCoroutine(GameState newState) { switch (state) { case GameState.Menu: { MenuUI.GetComponent <CanvasGroup>().interactable = false; yield return(StartCoroutine(Fade(MenuFade, MenuFade.color, Color.black))); MenuUI.SetActive(false); MenuCamera.enabled = false; break; } case GameState.SelectWeapon: { SelectionUI.GetComponent <CanvasGroup>().interactable = false; yield return(StartCoroutine(Fade(SelectionFade, SelectionFade.color, Color.black))); SelectionUI.SetActive(false); SelectionCamera.enabled = false; break; } case GameState.InGame: { // Game doesn't really need, may delete GameUI.GetComponent <CanvasGroup>().interactable = false; yield return(StartCoroutine(Fade(GameFade, GameFade.color, Color.black))); GameUI.SetActive(false); GameCamera.enabled = false; break; } case GameState.End: { yield return(StartCoroutine(Fade(EndFade, EndFade.color, Color.black))); EndCamera.enabled = false; storyModel.Reset(); break; } } state = newState; Color clear = new Color(0, 0, 0, 0); switch (state) { case GameState.Menu: { MenuCamera.enabled = true; yield return(StartCoroutine(Fade(MenuFade, MenuFade.color, clear))); MenuUI.SetActive(true); MenuUI.GetComponent <CanvasGroup>().interactable = true; Cursor.lockState = CursorLockMode.None; Cursor.visible = true; //storyMode = false; only 1 mode break; } case GameState.SelectWeapon: { SelectionCamera.enabled = true; yield return(StartCoroutine(Fade(SelectionFade, SelectionFade.color, clear))); SelectionUI.SetActive(true); SelectionUI.GetComponent <CanvasGroup>().interactable = true; if (storyMode) { storyView.SetEntry(storyModel.GetCurrentNarration()); selectionView.Unlock(storyModel.GetChapter()); } Cursor.lockState = CursorLockMode.None; Cursor.visible = true; break; } case GameState.InGame: { GameCamera.enabled = true; yield return(StartCoroutine(Fade(GameFade, GameFade.color, clear))); GameUI.SetActive(true); GameUI.GetComponent <CanvasGroup>().interactable = true; Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false; playing = true; break; } case GameState.End: { EndCamera.enabled = true; yield return(StartCoroutine(Fade(EndFade, EndFade.color, clear))); StartCoroutine(WaitTillReadEnd()); break; } } }