From cef5e20697fe3e89d6e77e2195ed0ac796656094 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Fri, 15 Dec 2023 19:40:11 +0000
Subject: [PATCH] Added UI and health display
---
Assets/Scripts/Damageable.cs | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/Assets/Scripts/Damageable.cs b/Assets/Scripts/Damageable.cs
index 7901a04..d5ae844 100644
--- a/Assets/Scripts/Damageable.cs
+++ b/Assets/Scripts/Damageable.cs
@@ -4,12 +4,15 @@
public class Damageable : MonoBehaviour
{
+ // ONLY FOR DEBUG USE
+ [SerializeField]
+ private bool selfDamage = false;
Animator animator;
[SerializeField]
private int _maxHealth = 100;
[SerializeField]
- private int _health;
+ private int _health = 100;
[SerializeField]
private bool _isAlive = true;
[SerializeField]
@@ -27,7 +30,14 @@
get { return _health; }
set
{
- _health = value;
+ if (value > MaxHealth)
+ {
+ _health = MaxHealth;
+ }
+ else
+ {
+ _health = value;
+ }
if (value <= 0)
{
IsAlive = false;
@@ -46,7 +56,7 @@
private void Awake()
{
- Health = MaxHealth;
+ //Health = MaxHealth;
animator = GetComponent<Animator>();
}
private void Update()
@@ -63,6 +73,10 @@
timeSinceHit += Time.deltaTime;
}
}
+ if (selfDamage)
+ {
+ Hit(10);
+ }
}
public void Hit(int damage)
--
Gitblit v1.10.0