HUD Arbeiten begonnen, ChangeHealthScript neu erstellt, neue und alte Methoden eingebaut
This commit is contained in:
File diff suppressed because it is too large
Load Diff
57
Assets/Scripts/Player/ChangeHealth.cs
Normal file
57
Assets/Scripts/Player/ChangeHealth.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using static UnityEngine.EventSystems.EventTrigger;
|
||||||
|
|
||||||
|
public class ChangeHealth : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] GameObject panel;
|
||||||
|
[SerializeField] GameObject gameOverSceen;
|
||||||
|
|
||||||
|
|
||||||
|
[Header("UI and HUD")]
|
||||||
|
|
||||||
|
[SerializeField] TMP_Text energyHUD;
|
||||||
|
[SerializeField] TMP_Text healthHUD;
|
||||||
|
|
||||||
|
InventoryScript inventory;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
inventory = panel.GetComponent<InventoryScript>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
energyHUD.text = inventory.Energy.ToString();
|
||||||
|
healthHUD.text = inventory.Health.ToString();
|
||||||
|
|
||||||
|
gameOverSceen.SetActive(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
if (inventory.Health <= 0)
|
||||||
|
{
|
||||||
|
Die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetHit()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void Die()
|
||||||
|
{
|
||||||
|
gameOverSceen.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void NewChance()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
2
Assets/Scripts/Player/ChangeHealth.cs.meta
Normal file
2
Assets/Scripts/Player/ChangeHealth.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8336b8f8234487443af56cbe19330e6e
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class InventoryScript : MonoBehaviour
|
public class InventoryScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[Header("Variables")]
|
||||||
//Energy
|
//Energy
|
||||||
[SerializeField] int energy = 10;
|
[SerializeField] int energy = 10;
|
||||||
|
|
||||||
@@ -23,6 +27,7 @@ public class InventoryScript : MonoBehaviour
|
|||||||
public int Health { get => health; set => health = value; }
|
public int Health { get => health; set => health = value; }
|
||||||
public int Gems { get => gems; set => gems = value; }
|
public int Gems { get => gems; set => gems = value; }
|
||||||
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user