// 联机大厅 IEnumerator _Lobby() { NetworkSystem.LaunchClient(); yield return(SceneSystem.LoadScene(GameScene.lobby)); yield return(0); ResetGameMessage(); while (true) { yield return(0); if (GetGameMessage(GameMessage.Return)) { // 回到开始菜单 StartCoroutine(_StartMenu()); break; } if (GetGameMessage(GameMessage.Connect)) { StartCoroutine(_Room()); break; } } }
// 游戏开始 private IEnumerator _Start() { SceneSystem.LoadScene(Setting.gameSceneMap[GameScene.startMenu]); onGameStart?.Invoke(); yield return(0); }
// 游戏开始 private IEnumerator _Start() { SceneSystem.LoadScene(GameScene.startScene); InputSystem.ChangeState(new InputSystem.MoveState()); onGameStart?.Invoke(); yield return(0); }
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()); }
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()); }