public void Reset() { //Needs to be called when we are returning to the main menu Destroy(GameManager._GAMEMANAGER.gameObject); _EndRoundUI = null; UnityEngine.SceneManagement.SceneManager.LoadScene("AlexTestMainMenu"); Destroy(this.gameObject); }
void Awake() { AButton.color = new Color(1, 1, 1, 0); if (_EndRoundUI != null) { Destroy(this); } else { DontDestroyOnLoad(this); _EndRoundUI = this; } this.gameObject.SetActive(false); }
// Update is called once per frame void Update() { if (gameState == GameState.MainMenu) { } if (gameState == GameState.CountdownStart) { countDownTextObject = GameObject.FindGameObjectWithTag("CountdownText").GetComponent <Text>(); StartCoroutine(CountdownStart(countdownTimerLength)); foreach (Player player in _players.Values) { if (player.joined) { player.ship.GetComponent <ShipController>().enabled = false; } } gameState = GameState.Countdown; } if (gameState == GameState.CoinGameModeStart) { endRoundUI = EndRoundScreen._EndRoundUI; bool[] playersInGame = new bool[4]; playersInGame [0] = _players [1].joined; playersInGame [1] = _players [2].joined; playersInGame [2] = _players [3].joined; playersInGame [3] = _players [4].joined; endRoundUI.GiveMeInformationYum(winsNeeded, playersInGame); gameTimeTextObject = GameObject.FindGameObjectWithTag("GameTimeText").GetComponent <Text>(); StartCoroutine(CoinGameModeStart(roundTime)); gameState = GameState.CoinGameMode; } if (gameState == GameState.CoinGameMode) { if (Input.GetKeyDown(KeyCode.Alpha1)) { KillPlayer(_players[1].ship); } if (Input.GetKeyDown(KeyCode.Alpha2)) { KillPlayer(_players[2].ship); } if (Input.GetKeyDown(KeyCode.Alpha3)) { KillPlayer(_players[3].ship); } if (Input.GetKeyDown(KeyCode.Alpha4)) { KillPlayer(_players[4].ship); } if (Time.timeSinceLevelLoad > 8.1) { foreach (Player player in _players.Values) { if (player.joined) { player.ship.GetComponent <ShipController>().enabled = true; } } } } if (gameState == GameState.EndOfRoundResults) { if (endRoundUI.uiStillOnScreen == false) { endResults(); } } if (gameState == GameState.EndOfGameResultsStart) { } if (gameState == GameState.EndOfGameResults) { if (InputManager.IsSubmitPressed) { UnityEngine.SceneManagement.SceneManager.LoadScene("resultsScene"); _players[1].color = PlayerColor.Yellow; _players[2].color = PlayerColor.Red; _players[3].color = PlayerColor.Blue; _players[4].color = PlayerColor.Green; gameState = GameState.MainMenu; } } }