From a0c086149a944d2f1488498b286187045386a2ae Mon Sep 17 00:00:00 2001 From: Piegames <14054505+piegamesde@users.noreply.github.com> Date: Tue, 24 Apr 2018 17:48:22 +0200 Subject: [PATCH] Respawn with R --- Assets/Scripts/Entities/Player.cs | 6 +++++- Assets/Scripts/UIController.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Entities/Player.cs b/Assets/Scripts/Entities/Player.cs index d439235..0fe565d 100644 --- a/Assets/Scripts/Entities/Player.cs +++ b/Assets/Scripts/Entities/Player.cs @@ -24,7 +24,11 @@ public class Player : Mob { SetAttack(s); } - void Update() { + void Update() { + if (Input.GetAxis("Reset") > 0) + { + GameController.instance.GetUI().Restart(); + } if ( Time.timeSinceLevelLoad >= nextAttackTime && attack != null) { if ( Input.GetAxis("Fire") > 0 ) { attack.Attack(); diff --git a/Assets/Scripts/UIController.cs b/Assets/Scripts/UIController.cs index 63d0af3..7dada41 100644 --- a/Assets/Scripts/UIController.cs +++ b/Assets/Scripts/UIController.cs @@ -32,7 +32,7 @@ public class UIController : MonoBehaviour void Update() { if (Input.GetAxis("Reset") > 0 && GameController.instance.GameEnded()) { - LoadSceneByIndex(firstSceneIndex); + Restart(); } } @@ -44,6 +44,10 @@ public class UIController : MonoBehaviour pauseMenu.SetActive(false); } + public void Restart() { + LoadSceneByIndex(firstSceneIndex); + } + public void LoadSceneByIndex(int index) { Debug.Log("Loaded scene " + index); SceneManager.LoadScene(index);