/// <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); } } } }
/// <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); }
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; } }
/// <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); } } }