/** * Update panel text/data based on what the reason for ending the game is */ private void UpdatePanel(EndGame.Reason reason) { // do all common updates UpdatePanelCommon(); // do anything specific to the reason for ending the game switch (reason) { case EndGame.Reason.ManualQuit: titleText.text = "Quit?"; messageText.text = "Are you sure?"; confirmButton.SetActive(true); confirmButtonText.text = "Yes"; cancelButton.SetActive(true); cancelButtonText.text = "Go Back"; break; case EndGame.Reason.NoOffspring: titleText.text = "Game Over"; messageText.text = "All fish have died! Press button to restart. Thanks for playing!"; confirmButton.SetActive(true); confirmButtonText.text = "Restart"; cancelButton.SetActive(false); break; } }
/** * Constructor * * @param reason The reason for ending the game */ public EndState(EndGame.Reason reason) { this.reason = reason; }
/** * Handle end of game event */ private void OnEndOfGameEvent(EndGame.Reason reason) { UpdatePanel(reason); Activate(); }