public GameSession(PlayerCharacterData character, LevelData level) { m_mainCharacter = new PlayerCharacter(character, this); m_level = new LevelSession(level); m_state = EGameSessionSate.PreGame; m_result = new GameSessionResult(); }
protected bool InitState( State target, params object[] args) { switch (target) { case State.Menu: OnMenuHandler?.Invoke(true); _state = target; return(true); case State.CharacterSelection: GameSession.Instance.SelectedLevelIndex = 0; OnCharacterSelectHandler?.Invoke(true); _state = target; return(true); case State.Podium: if (RoundSession.Instance != null) { RoundSession.Instance.Destroy(); } if (LevelSession.Instance != null) { LevelSession.Instance.Destroy(); } Podium.Instance.gameObject.SetActive(true); OnPodiumHandler?.Invoke(); _state = target; return(true); case State.FinalPodium: if (RoundSession.Instance != null) { RoundSession.Instance.Destroy(); } if (LevelSession.Instance != null) { LevelSession.Instance.Destroy(); } Podium.Instance.gameObject.SetActive(true); OnFinalPodiumHandler?.Invoke(); _state = target; return(true); case State.LevelSelection: if (RoundSession.Instance != null) { RoundSession.Instance.Destroy(); } if (LevelSession.Instance != null) { LevelSession.Instance.Destroy(); } OnLevelSelectHandler?.Invoke(true); GameSession.Instance.SelectedLevelIndex = 0; _state = target; foreach (Level level in _levels) { if (level == null) { continue; } level.gameObject.SetActive(true); level.OnLevelSelect(); } return(true); case State.InitRound: Podium.Instance.Clear(); foreach (var player in GameSession.Instance.Players) { if (player == null) { continue; } Podium.Instance.Add( player, CharacterLibrary.Instance.Characters[player.CharacterId]); } Podium.Instance.gameObject.SetActive(false); foreach (Level level in _levels) { if (level == null) { continue; } level.gameObject.SetActive(false); } if (CustomNetworkManager.IsServer) { //LevelSession.Instance = null; //LevelRoun if (RoundSession.Instance != null) { RoundSession.Instance.Destroy(); } if (LevelSession.Instance != null) { LevelSession.Instance.Destroy(); } LevelSession.Create(); RoundSession.Create( CountDown, Settings.RoundTime.Integer, CountdownTime, IntermissionTime, GameSession.Instance._roundIndex); } Threading.CoroutineBarrier.Wait( this, () => { OnRoundInitHandler?.Invoke(); SetState(State.Round); RoundSession.Instance.StartIntermisison(); }, () => RoundSession.Instance != null && RoundSession.Instance.IsClientStarted, () => LevelSession.Instance != null && LevelSession.Instance.IsClientStarted ); _state = target; return(true); case State.Round: OnRoundHandler?.Invoke(); Announcement.Instance.RoundIndex = RoundSession.Instance.Index; _state = target; return(true); case State.Score: _state = target; return(true); default: return(false); } }