Commit 981f4252 authored by LasseKau's avatar LasseKau
Browse files

restart button, still wip

-
parent 8eb7f300
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public GameObject deathPanel;
private bool pauseGame = false;
// Start is called before the first frame update
void Start()
{
deathPanel.SetActive(false);
}
public void gameOver()
{
deathPanel.SetActive(true);
ToggleTime();
}
private void ToggleTime()
{
pauseGame = !pauseGame;
if (pauseGame)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: 15afbb716a7c4bd4c905c478975ec481
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class PlayerHealth : MonoBehaviour
{
......@@ -10,6 +12,7 @@ public class PlayerHealth : MonoBehaviour
private int MaxHealth = 100;
[SerializeField]
private int health = 100;
//public GameManager manager;
// Start is called before the first frame update
......@@ -62,7 +65,11 @@ public class PlayerHealth : MonoBehaviour
if(health <= 0)
{
Debug.Log("U ded");
GameObject MasterUI = GameObject.Find("MasterUI");
UIManager MainUI = MasterUI.GetComponent<UIManager>();
MainUI.gameOver();
}
} else if (lifeUpdate > 0)
{
health += lifeUpdate;
......
......@@ -7,15 +7,44 @@ public class UIManager : MonoBehaviour
{
public GameObject PlayerUI;
public GameObject PausePanel;
public GameObject DeathPanel;
private bool pauseGame = false;
private void Start()
{
PlayerUI.SetActive(true);
PausePanel.SetActive(false);
DeathPanel.SetActive(false);
}
private void OnDisable()
{
// Save some stuff.
}
public void gameOver()
{
DeathPanel.SetActive(true);
ToggleTime();
}
private void ToggleTime()
{
pauseGame = !pauseGame;
if (pauseGame)
{
Time.timeScale = 0;
}
else
{
Time.timeScale = 1;
}
}
public void Retry()
{
ToggleTime();
SceneManager.LoadScene("TestScene");
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment