Example #1
0
 public override void Attached()
 {
     GameManager.instance.Lobby = this;
     if (BoltNetwork.isServer)
     {
         ServerSideData.UpdateZeusData();
     }
 }
Example #2
0
    private void DrawServerMenu()
    {
        GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
        GUILayout.Label("Lobby Password:"******"Apply new Password"))
        {
            ServerSideData.Password = tempPassword;
            ServerSideData.UpdateZeusData();
        }
        GUI.enabled = true;
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Game mode:");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        int newGameModeIndex = GUILayout.SelectionGrid(selectedGameMode, GameModeManager.GameModeNames, 1);

        if (newGameModeIndex != selectedGameMode)
        {
            selectedGameMode = newGameModeIndex;
            IGameMode newGameMode = GameModeManager.GameModes[selectedGameMode];
            GameManager.instance.gameMode = newGameMode;
            updateMapList(GameModeManager.GameModeNames[selectedGameMode]);
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Label("Map:");
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        selectedMap = GUILayout.SelectionGrid(selectedMap, humanReadableMapList, 1);
        GUILayout.EndHorizontal();

        DrawTeamChangeButtons();
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Start Game"))
        {
            string sceneName = "ingame_" + mapList[selectedMap] + "_" + GameManager.instance.gameMode.GetType().Name;
            Debug.Log("loading scene \"" + sceneName + "\"");
            BoltNetwork.LoadScene(sceneName);
        }
        GUILayout.EndHorizontal();
    }
Example #3
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();
        }
    }