Пример #1
0
    /// <summary>
    /// Switches level options
    /// </summary>
    public void NextLevel()
    {
        if (LevelOptions.NextLevel != null)
        {
            _levelGamescore = 0;
            LevelOptions    = LevelOptions.NextLevel;
            Spawner.GetComponent <EnemySpawner>().SetLevelSettings(LevelOptions);


            Spawner.SetActive(false);
            PlayerObject.SetActive(false);
            if (StartGameBtn != null && !StartGameBtn.activeSelf)
            {
                StartGameBtn.SetActive(true);
            }
            if (ControlsUI != null)
            {
                ControlsUI.SetActive(true);
            }
            if (WinnerUI != null)
            {
                if (NextTargetUI != null)
                {
                    NextTargetUI.GetComponent <Text>().text = LevelOptions.Score.ToString();
                    WinnerUI.SetActive(true);
                }
            }
        }
    }
Пример #2
0
 /// <summary>
 /// Restart button click event listener. Starts game
 /// </summary>
 public void Restart()
 {
     ControlsUI.SetActive(false);
     WinnerUI.SetActive(false);
     PlayerObject.GetComponent <Player>().Restart();
     Spawner.GetComponent <EnemySpawner>().Restart();
     BackgroundUI.GetComponent <Image>().sprite = LevelOptions.Background;
     StartGameBtn.SetActive(false);
     if (_playerDead)
     {
         GameOverUI.SetActive(false);
         _playerDead = false;
     }
     OnHealthsUpdate(PlayerObject.GetComponent <Player>().hPoints);
 }
Пример #3
0
 public void OnGameStart()
 {
     if (StartGameBtn.InvokeRequired)
     {
         StartGameBtn.Invoke(new MethodInvoker(delegate {
             LeaveRoomBtn.Enabled = false;
             LeaveRoomBtn.Visible = false;
             StartGameBtn.Enabled = false;
             StartGameBtn.Visible = false;
         }));
     }
     else
     {
         LeaveRoomBtn.Enabled = false;
         LeaveRoomBtn.Visible = false;
         StartGameBtn.Enabled = false;
         StartGameBtn.Visible = false;
     }
 }
Пример #4
0
    /// <summary>
    /// OnPlayerDead event listener
    /// </summary>
    private void GameOver()
    {
        if (!_playerDead)
        {
            _playerDead = true;
            if (StartGameBtn != null && !StartGameBtn.activeSelf)
            {
                StartGameBtn.SetActive(true);
            }

            if (GameOverUI != null)
            {
                GameOverUI.SetActive(true);
            }

            if (ControlsUI != null)
            {
                ControlsUI.SetActive(true);
            }
        }
    }