diff --git a/Assets/Resources/Player1.prefab b/Assets/Resources/Player1.prefab index 5f4bf7f..138063f 100644 --- a/Assets/Resources/Player1.prefab +++ b/Assets/Resources/Player1.prefab @@ -376,6 +376,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + bloodRegen: 1 + regen: 1000 onlyCallZeroHealthOnce: 1 maxHealth: 100 damageTickDelay: 0.25 diff --git a/Assets/Resources/Player2.prefab b/Assets/Resources/Player2.prefab index 9c61484..4fe358c 100644 --- a/Assets/Resources/Player2.prefab +++ b/Assets/Resources/Player2.prefab @@ -292,6 +292,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3} m_Name: m_EditorClassIdentifier: + bloodRegen: 1 + regen: 1000 onlyCallZeroHealthOnce: 1 maxHealth: 100 damageTickDelay: 0.25 diff --git a/Assets/Scripts/Player/HealthComponent.cs b/Assets/Scripts/Player/HealthComponent.cs index 0dee386..e110192 100644 --- a/Assets/Scripts/Player/HealthComponent.cs +++ b/Assets/Scripts/Player/HealthComponent.cs @@ -7,6 +7,9 @@ using System.Collections; public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver { + public bool bloodRegen = false; + public float regen = 1000; + [SerializeField] private bool onlyCallZeroHealthOnce = true; [SerializeField] float maxHealth = 100; @@ -80,6 +83,14 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver void Update() { + // blod regen + if (bloodRegen) + { + PlayerInput playerInput = GetComponent(); + float bloodAccumalted = playerInput.PlayerNum == 1 ? BloodComputeShader.Instance.mop1Clean : BloodComputeShader.Instance.mop2Clean; + TakeDamage(-bloodAccumalted / regen); + } + if (currentDamageTick < Time.time) { if (accumulatedDamageInTick < 1f) return; @@ -103,7 +114,10 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver public void TakeDamage(float damage) { + if (damage == 0f) return; + currentHealth -= damage; + currentHealth = Mathf.Clamp(currentHealth, 0f, getMaxHealth()); OnHealthChange?.Invoke(currentHealth + damage, currentHealth); accumulatedDamageInTick += damage;