コード例 #1
0
    void Start()
    {
        WaitingUI.SetActive(false);
        ReadyUI.SetActive(false);
        InProgressUI.SetActive(false);
        GameOverUI.SetActive(false);

        ChangeState(State.Waiting);

        _cam = Camera.main.GetComponent <CameraHandler>();

        // Load the last played game mode
        if (PlayerPrefs.HasKey("GameMode"))
        {
            Debug.LogFormat("Got last played game mode: {0}", PlayerPrefs.GetInt("GameMode"));
            ModeChoice = (GameModeChoice)(PlayerPrefs.GetInt("GameMode"));
        }

        switch (ModeChoice)
        {
        case GameModeChoice.LastManStanding:
            _gameMode = new LMSMode();
            break;

        case GameModeChoice.DeathMatch:
            _gameMode = new DMMode(10);
            break;

        default:
            Debug.LogErrorFormat("Selected game mode does not exist! Doing LMS.");
            _gameMode = new LMSMode();
            break;
        }

        //Spawn points
        for (int i = 0; i < SpawnPoints.Length; i++)
        {
            _spawnPointsOrder.Add(i);
        }
        // random order spawnpoints
        for (int i = 0; i < _spawnPointsOrder.Count; i++)
        {
            int temp = _spawnPointsOrder[i];
            int rand = Random.Range(0, _spawnPointsOrder.Count);
            _spawnPointsOrder[i]    = _spawnPointsOrder[rand];
            _spawnPointsOrder[rand] = temp;
        }

        _players      = new Dictionary <int, PlayerController> ();
        PlayerKilled += _gameMode.PlayerKilled;
    }
コード例 #2
0
    void Start()
    {
        WaitingUI.SetActive(false);
        ReadyUI.SetActive(false);
        InProgressUI.SetActive(false);
        GameOverUI.SetActive(false);

        ChangeState(State.Waiting);

        _cam = Camera.main.GetComponent<CameraHandler>();

        // Load the last played game mode
        if (PlayerPrefs.HasKey("GameMode")) {
            Debug.LogFormat("Got last played game mode: {0}", PlayerPrefs.GetInt("GameMode"));
            ModeChoice = (GameModeChoice)(PlayerPrefs.GetInt("GameMode"));
        }

        switch(ModeChoice) {
        case GameModeChoice.LastManStanding:
            _gameMode = new LMSMode();
            break;
        case GameModeChoice.DeathMatch:
            _gameMode = new DMMode(10);
            break;
        default:
            Debug.LogErrorFormat("Selected game mode does not exist! Doing LMS.");
            _gameMode = new LMSMode();
            break;
        }

        //Spawn points
        for (int i = 0; i < SpawnPoints.Length; i++)
        {
            _spawnPointsOrder.Add(i);
        }
        // random order spawnpoints
        for (int i = 0; i < _spawnPointsOrder.Count; i++)
        {
            int temp = _spawnPointsOrder[i];
            int rand = Random.Range(0, _spawnPointsOrder.Count);
            _spawnPointsOrder[i] = _spawnPointsOrder[rand];
            _spawnPointsOrder[rand] = temp;
        }

        _players = new Dictionary<int, PlayerController> ();
        PlayerKilled += _gameMode.PlayerKilled;
    }
コード例 #3
0
 void Destroy()
 {
     PlayerKilled -= _gameMode.PlayerKilled;
 }
コード例 #4
0
 void Destroy()
 {
     PlayerKilled -= _gameMode.PlayerKilled;
 }