reset managers on death/home go
This commit is contained in:
parent
4baa667b4e
commit
504c967f45
|
@ -43,6 +43,16 @@ public class GameManager : MonoBehaviour
|
|||
health = startHealth;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
foreach (var go in GameObject.FindObjectsByType<GameObject>(FindObjectsSortMode.None))
|
||||
{
|
||||
if (go != null && go != this.gameObject)
|
||||
Destroy(go);
|
||||
}
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
MoneyManager.OnShopSelected += m_OnTowerShopSelected;
|
||||
|
|
|
@ -24,6 +24,7 @@ public class PlayerHealth : MonoBehaviour
|
|||
{
|
||||
gameOver.SetActive(true);
|
||||
yield return new WaitForSecondsRealtime(5f);
|
||||
GameManager.Instance.Reset();
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ public class SwitchScene : MonoBehaviour
|
|||
{
|
||||
public void SwitchToScene(string scene)
|
||||
{
|
||||
GameManager.Instance.Reset();
|
||||
SceneManager.LoadScene(scene);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue