Commit f4eb9b16 authored by Domm29's avatar Domm29
Browse files

Merge branch 'mergeTemp'

# Conflicts:
#	.idea/.idea.seedling/.idea/contentModel.xml
#	.idea/.idea.seedling/.idea/workspace.xml
#	Assets/Prefabs/player.prefab
#	ProjectSettings/TagManager.asset
parents d5953702 2c4ad23a
This diff is collapsed.
......@@ -5,8 +5,9 @@ using UnityEngine;
public class Life : MonoBehaviour
{
private int life;
public int life;
public GameObject hud;// The Hud with the Health Bar
// Start is called before the first frame update
void Start()
{
......@@ -21,9 +22,13 @@ public class Life : MonoBehaviour
private void OnCollisionEnter2D(Collision2D other)
{
//Layer 30 is the Damage Hazad and 31 is Damage Enemy
if (other.gameObject.layer == 30 || other.gameObject.layer == 31)
{
life--;
hud.GetComponent<UI_Health>().LifeLost(life);
}
}
}
......@@ -11,6 +11,7 @@ public class UI_Health : MonoBehaviour
public Image leaf3;
public GameObject playerObject;
private GameObject hudCanvas;
private void Awake()
{
......@@ -26,30 +27,35 @@ public class UI_Health : MonoBehaviour
private void Update()
{
if (playerObject.GetComponent<Life>().life == 3)
{
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = true;
}
else if (playerObject.GetComponent<Life>().life == 2)
{
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = false;
}
else if (playerObject.GetComponent<Life>().life == 1)
{
leaf1.enabled = true;
leaf2.enabled = false;
leaf3.enabled = false;
}
else if (playerObject.GetComponent<Life>().life <= 0)
}
public void LifeLost(int lifeOfPlayer)
{
switch (lifeOfPlayer)
{
leaf1.enabled = false;
leaf2.enabled = false;
leaf3.enabled = false;
hudCanvas.GetComponent<UI_SceneManager>().ReloadScene();
case 3:
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = true;
break;
case 2:
leaf1.enabled = true;
leaf2.enabled = true;
leaf3.enabled = false;
break;
case 1:
leaf1.enabled = true;
leaf2.enabled = false;
leaf3.enabled = false;
break;
default:
leaf1.enabled = false;
leaf2.enabled = false;
leaf3.enabled = false;
hudCanvas.GetComponent<UI_SceneManager>().ReloadScene();
break;
}
}
}
......
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