diff --git a/Assets/Scenes/Reparation.unity b/Assets/Scenes/Reparation.unity index 3d9170e..75b32df 100644 --- a/Assets/Scenes/Reparation.unity +++ b/Assets/Scenes/Reparation.unity @@ -597,7 +597,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: ee9ab2a2c8115bf449c61728aee6099d, type: 3} propertyPath: m_LocalPosition.y - value: 15.92215 + value: 16.1 objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: ee9ab2a2c8115bf449c61728aee6099d, type: 3} propertyPath: m_LocalPosition.z @@ -654,7 +654,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: 7e868a49e1cfe56428ce4704afc2ee8a, type: 3} propertyPath: m_LocalPosition.y - value: 16.305462 + value: 16.4 objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: 7e868a49e1cfe56428ce4704afc2ee8a, type: 3} propertyPath: m_LocalPosition.z @@ -2439,7 +2439,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: 8cab0fc9be2d12741a4e26984b05ffdb, type: 3} propertyPath: m_LocalPosition.y - value: 11.359894 + value: 11.8 objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: 8cab0fc9be2d12741a4e26984b05ffdb, type: 3} propertyPath: m_LocalPosition.z @@ -6757,7 +6757,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: d86e05db9db58774e9a8b15bf72e7a08, type: 3} propertyPath: m_LocalPosition.y - value: 16.466646 + value: 16.6 objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: d86e05db9db58774e9a8b15bf72e7a08, type: 3} propertyPath: m_LocalPosition.z @@ -26800,7 +26800,7 @@ Transform: m_GameObject: {fileID: 1522474813} serializedVersion: 2 m_LocalRotation: {x: -0.17842343, y: -0, z: -0, w: 0.9839538} - m_LocalPosition: {x: -2.67, y: -5.96, z: -25.12} + m_LocalPosition: {x: -2.67, y: -5.59, z: -25.12} m_LocalScale: {x: 2.486358, y: 1, z: 2.9054} m_ConstrainProportionsScale: 0 m_Children: [] @@ -30632,7 +30632,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: 6dbd51e7d3a3e82438c922e2b8870d37, type: 3} propertyPath: m_LocalPosition.y - value: 16.518383 + value: 16.6 objectReference: {fileID: 0} - target: {fileID: -5819118886272102141, guid: 6dbd51e7d3a3e82438c922e2b8870d37, type: 3} propertyPath: m_LocalPosition.z diff --git a/Assets/Scripts/Health.cs b/Assets/Scripts/Health.cs index 0134d61..820ea4c 100644 --- a/Assets/Scripts/Health.cs +++ b/Assets/Scripts/Health.cs @@ -13,6 +13,8 @@ public class Health : MonoBehaviour public Text healthText; + private Coroutine _damageOverTimeCoroutine; + private void Start() { damageValues.Add(50); @@ -27,6 +29,8 @@ private void OnTriggerEnter(Collider other) if (other.CompareTag("Chelicerate")) { TakeDamage(); + + _damageOverTimeCoroutine ??= StartCoroutine(DamageOverTime(3f, 0.5f)); } if (!other.CompareTag("Kit") || !(health < 100f)) return; @@ -35,6 +39,13 @@ private void OnTriggerEnter(Collider other) Destroy(other.gameObject); } + private void OnTriggerExit(Collider other) + { + if (!other.CompareTag("Chelicerate") || _damageOverTimeCoroutine == null) return; + StopCoroutine(_damageOverTimeCoroutine); + _damageOverTimeCoroutine = null; + } + private void TakeDamage() { if (damageValues.Count > 0) @@ -61,6 +72,24 @@ private void TakeDamage() } } + private IEnumerator DamageOverTime(float damageAmount, float interval) + { + while (true) + { + health -= damageAmount; + health = Mathf.Max(health, 0f); + + if (health <= 0) + { + Die(); + break; + } + + UpdateHealthUI(); + yield return new WaitForSeconds(interval); + } + } + private IEnumerator Heal(float duration) { var targetHealth = Mathf.Min(health + 50f, 100f); @@ -89,5 +118,6 @@ private void UpdateHealthUI() private void Die() { // Handle death logic here + Debug.Log("Player died!"); } }