Exemplo n.º 1
0
    public void ChangeGameState(GameState state)
    {
        CurrentGameState = state;
        switch (state)
        {
        case GameState.PRE_GAME:
            GameStats.ClearAllStats();

            if (BoltNetwork.isServer)
            {
                CurrentPlayerStatIndex = ServerConnectionEventListener.IndexMap.GetIndexForPlayer(CurrentUserName);
                Debug.Log("CurrentPlayerStatIndex=" + CurrentPlayerStatIndex);
                GameStats.CreateNewStringStat("Player");
                var map = ServerConnectionEventListener.IndexMap;
                for (int i = 0; i < map.PlayerCount; i++)
                {
                    GameStats.SetStringStat(i, "Player", map.GetPlayerNameForIndex(i));
                }
                if (gameMode.UsesTeams)
                {
                    GameStats.CreateNewIntegerStat("Team");
                    var lookup = Lobby.GetTeamLookup();
                    foreach (var pair in lookup)
                    {
                        GameStats.SetIntegerStat(pair.Key, "Team", pair.Value);
                    }
                }
                gameMode.OnPreGame();
            }
            else
            {
                CurrentPlayerStatIndex = Lobby.GetStatIndexForPlayer(CurrentUserName);
            }
            break;

        case GameState.IN_GAME:
            if (BoltNetwork.isServer)
            {
                gameMode.OnGameStart();
            }
            break;
        }
        if (BoltNetwork.isServer)
        {
            ServerSideData.UpdateZeusData();
        }
    }