//// Start is called before the first frame update //void Start() //{ //} //// Update is called once per frame //void Update() //{ //} public void GameOver(GameOverReasons reason) { if (onGameOver != null) { onGameOver(); } gameBeingPlayed = false; hud.SetActive(false); gameOverScreen.SetActive(true); string msg = (reason == GameOverReasons.PlayerDead) ? "You lost." : "YOU WON!!"; gameOverScreen.SetGameOverScreen(msg, currScore.ToString()); }
public static void GameOver(GameOverReasons reason) { gameOver = true; gameOverReason = reason; if (score > highScore) { highScore = score; PlayerPrefs.SetInt(highScoreString, highScore); } Rigidbody rb = player.GetComponent <Rigidbody>(); if (rb != null) { rb.constraints = RigidbodyConstraints.None; Vector2 vec = Random.insideUnitCircle; rb.AddForceAtPosition(new Vector3(vec.x, 0, vec.y) * 25, player.transform.position + Vector3.up * 1.8f); } }
private void OnGameOver(object sender, GameOverReasons reason) { _gameCicle.Pause = true; _ballController.Stop(); string windowBody = string.Empty; string[] buttonTexts = null; ButtonCommands[] buttonCommands = null; switch (reason) { case GameOverReasons.Time: windowBody = "У вас закончилось время!"; buttonTexts = new string[] { "Заново", "Закончить игру" }; buttonCommands = new ButtonCommands[] { ButtonCommands.Retry, ButtonCommands.Close }; break; case GameOverReasons.LoseBall: windowBody = "Вы проиграли. Попробовать снова?"; buttonTexts = new string[] { "Заново", "Закончить игру" }; buttonCommands = new ButtonCommands[] { ButtonCommands.Retry, ButtonCommands.Close }; break; case GameOverReasons.Win: windowBody = "Поздравляем! Вы выиграли. Следующий уровень?"; buttonTexts = new string[] { "Следующий", "Закончить игру" }; buttonCommands = new ButtonCommands[] { ButtonCommands.Next, ButtonCommands.Close }; break; } var dialog = UIManager.Show(WindowID.Dialog, windowBody, buttonTexts, buttonCommands); dialog.WindowClosed += OnDialogClosed; void OnDialogClosed(object dialogSender, ButtonCommands closeResult) { dialog.WindowClosed -= OnDialogClosed; switch (closeResult) { case ButtonCommands.Close: #if UNITY_EDITOR EditorApplication.isPlaying = false; #else Application.Quit(); #endif break; case ButtonCommands.Next: _gameModel.NextLevel(); break; case ButtonCommands.Retry: _gameModel.GoToStart(); break; } } }