IGameState currentState;//当前状态 public GameStateManager() { gameStates = new Dictionary <GameStateTypeEnum, IGameState>(); IGameState gameState; gameState = new LoginState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new UserState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new LobbyState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new RoomState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new HeroState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new LoadingState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new PlayState(); gameStates.Add(gameState.GetStateType(), gameState); gameState = new OverState(); gameStates.Add(gameState.GetStateType(), gameState); }
public void OnEvent(FEvent evt) { switch ((GameEventEnum)evt.GetEventId()) { case GameEventEnum.GameEvent_Loading: { GameStateTypeEnum stateType = (GameStateTypeEnum)evt.GetParam("NextState"); LoadingState lState = GameStateManager.Instance.getState(GameStateTypeEnum.GS_Loading) as LoadingState; lState.SetNextState(stateType); lState.SetFrontScenes(View.EScenesType.EST_Play); SetStateTo(GameStateTypeEnum.GS_Loading); } break; case GameEventEnum.GameEvent_IntoRoom: { LoadingState lState = GameStateManager.Instance.getState(GameStateTypeEnum.GS_Loading) as LoadingState; lState.SetNextState(GameStateTypeEnum.GS_Room); lState.SetFrontScenes(View.EScenesType.EST_Play); SetStateTo(GameStateTypeEnum.GS_Loading); } break; case GameEventEnum.GameEvent_IntoLobby: { LoadingState lState = GameStateManager.Instance.getState(GameStateTypeEnum.GS_Loading) as LoadingState; lState.SetNextState(GameStateTypeEnum.GS_Lobby); lState.SetFrontScenes(View.EScenesType.EST_Play); SetStateTo(GameStateTypeEnum.GS_Loading); } break; } }
private void SdkLogOff() { GameMethod.LogOutToLogin(); LoadingState lState = GameStateManager.Instance.getState(GameStateTypeEnum.GS_Loading) as LoadingState; lState.SetNextState(GameStateTypeEnum.GS_Login); lState.SetFrontScenes(View.EScenesType.EST_Play); SetStateTo(GameStateTypeEnum.GS_Loading); }
public void OnEvent(FEvent evt) { switch ((GameEventEnum)evt.GetEventId()) { case GameEventEnum.GameEvent_IntoRoom: { //获取当前状态 LoadingState lState = GameStateManager.Instance.getState(GameStateTypeEnum.GS_Loading) as LoadingState; lState.SetNextState(GameStateTypeEnum.GS_Room); lState.SetFrontScenes(View.EScenesType.EST_Play); SetStateTo(GameStateTypeEnum.GS_Loading); } break; } }
public void OnEvent(FEvent evt) { switch ((GameEventEnum)evt.GetEventId()) { case GameEventEnum.GameEvent_IntoRoom: //创建房间(自定义) SetStateTo(GameStateTypeEnum.GS_Room); break; case GameEventEnum.GameEvent_IntoHero: //英雄选择 GameStateManager.Instance.ChangeGameStateTo(GameStateTypeEnum.GS_Hero); break; case GameEventEnum.GameEvent_Loading: //加载状态 GameStateTypeEnum stateType = (GameStateTypeEnum)evt.GetParam("NextState"); LoadingState lState = GameStateManager.Instance.getState(GameStateTypeEnum.GS_Loading) as LoadingState; lState.SetNextState(stateType); lState.SetFrontScenes(View.EScenesType.EST_Login); SetStateTo(GameStateTypeEnum.GS_Loading); break; } }