Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
e1e2fd9069
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<PlayerInput>();
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue