Exemple #1
0
    /// <summary> Starts the specified GameMode </summary>
    /// <param name="_gameModeType"> Which Game Mode to start </param>
    public void StartGame(GameMode.GameModeTypes _gameModeType)
    {
        // Create GameMode
        switch (_gameModeType)
        {
        case GameMode.GameModeTypes.Original:                           gameMode = gameObject.AddComponent <GameModeOriginal>();                 break;

        case GameMode.GameModeTypes.Arcade:                                     gameMode = gameObject.AddComponent <GameModeArcade>();                   break;

        case GameMode.GameModeTypes.PVPLocal_Continuous:        gameMode = gameObject.AddComponent <GameModePVPContinuous>();    break;

        case GameMode.GameModeTypes.PVPLocal_Race:                      gameMode = gameObject.AddComponent <GameModePVPRace>();                  break;

        default: throw new UnityException("Unhandled Game Mode Type " + _gameModeType);
        }

        startingLevel = gameMode.GetStartingLevel();

        // Set viewing positions (camera, ground, etc)
        ViewLayout viewLayout;

        switch (gameMode.NumPlayers)
        {
        case 1: viewLayout = viewLayout1Tower; break;

        case 2: viewLayout = viewLayout2Towers; break;

        default: throw new UnityException("Unhandled tower layout for '" + gameMode.NumPlayers + "' towers");
        }
        TowerCamera.instance.SetLayout(viewLayout);
        GroundController.instance.SetLayout(viewLayout);

        // Clear current players
        if (players != null)
        {
            for (int i = 0; i < players.Length; ++i)
            {
                players[i].Destroy();
                players[i] = null;
            }
        }

        // Create new players
        players = new Player[gameMode.NumPlayers];
        for (int i = 0; i < players.Length; ++i)
        {
            players[i] = new Player("Player " + (i + 1), controllerTypes[i], towerPrefab, viewLayout.towerPositions[i], startingLevel, gameMode.StartingLevelProgress);
        }

        // Update background visuals
        RefreshEnvironment(startingLevel);

        SetGameState(GameStates.Gameplay);
    }
Exemple #2
0
 /// <summary> Starts the specified game </summary>
 /// <param name="_gameMode"> Game mode to start </param>
 void StartGameMode(GameMode.GameModeTypes _gameMode)
 {
     GameMaster.instance.StartGame(_gameMode);
     UIMaster.instance.GameplayStarted();
 }