private IEnumerator _Logo() { SceneSystem.LoadScene(GameScene.logo); //在进入每个状态前重置控制信息 ResetGameMessage(); while (true) { //提前return,延迟一帧开始检测 yield return(0); if (GetGameMessage(GameMessage.Next)) { break; } } //不直接用嵌套,防止嵌套层数过深(是否有自动优化?没查到) StartCoroutine(_Start()); }
static IEnumerator Logo() { Cursor.visible = false; SceneSystem.LoadScene(SceneCode.logo); SceneSystem.ConfirmLoadScene(); yield return(0); ResetGameMessage(); while (true) { yield return(0); if (GetGameMessage(GameMessage.Next)) { break; } } StartCoroutine(StartMenu()); }
private IEnumerator _InGame() { yield return(new WaitForSeconds(SceneSystem.PopAndPushScene(_inGame))); ResetGameMessage(); while (true) { yield return(0); if (GetGameMessage(GameMessage.Return)) { StartCoroutine(_StartMenu()); yield break; } if (GetGameMessage(GameMessage.Exit)) { Application.Quit(); yield break; } } }
private IEnumerator _Lobby() { yield return(new WaitForSeconds(SceneSystem.PopAndPushScene(_lobby))); ResetGameMessage(); while (true) { yield return(0); if (GetGameMessage(GameMessage.Start)) { StartCoroutine(_InGame()); yield break; } if (GetGameMessage(GameMessage.Return)) { StartCoroutine(_StartMenu()); yield break; } } }
IEnumerator _Room() { yield return(SceneSystem.LoadScene(GameScene.room)); onGameReady?.Invoke(); yield return(0); ResetGameMessage(); while (true) { yield return(0); if (GetGameMessage(GameMessage.DisConnect)) { // 回到开始菜单 NetworkSystem.ShutdownServer(); StartCoroutine(_Lobby()); break; } } }
// 开始菜单 IEnumerator _StartMenu() { NetworkSystem.ShutdownClient(); yield return(SceneSystem.LoadScene(GameScene.startMenu)); yield return(0); InputSystem.ChangeState(new InputSystem.MoveState()); ResetGameMessage(); while (true) { yield return(0); if (GetGameMessage(GameMessage.Next)) { break; } } StartCoroutine(_Lobby()); }