This commit is contained in:
parent
c829d04a19
commit
89028df5c2
|
@ -376,6 +376,8 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
bloodRegen: 1
|
||||||
|
regen: 1000
|
||||||
onlyCallZeroHealthOnce: 1
|
onlyCallZeroHealthOnce: 1
|
||||||
maxHealth: 100
|
maxHealth: 100
|
||||||
damageTickDelay: 0.25
|
damageTickDelay: 0.25
|
||||||
|
|
|
@ -292,6 +292,8 @@ MonoBehaviour:
|
||||||
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
m_Script: {fileID: 11500000, guid: 1fdfc885f1a69704b893825cf9e616ba, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
bloodRegen: 1
|
||||||
|
regen: 1000
|
||||||
onlyCallZeroHealthOnce: 1
|
onlyCallZeroHealthOnce: 1
|
||||||
maxHealth: 100
|
maxHealth: 100
|
||||||
damageTickDelay: 0.25
|
damageTickDelay: 0.25
|
||||||
|
|
|
@ -7,6 +7,9 @@ using System.Collections;
|
||||||
|
|
||||||
public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
||||||
{
|
{
|
||||||
|
public bool bloodRegen = false;
|
||||||
|
public float regen = 1000;
|
||||||
|
|
||||||
[SerializeField] private bool onlyCallZeroHealthOnce = true;
|
[SerializeField] private bool onlyCallZeroHealthOnce = true;
|
||||||
[SerializeField] float maxHealth = 100;
|
[SerializeField] float maxHealth = 100;
|
||||||
|
|
||||||
|
@ -80,6 +83,14 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
||||||
|
|
||||||
void Update()
|
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 (currentDamageTick < Time.time)
|
||||||
{
|
{
|
||||||
if (accumulatedDamageInTick < 1f) return;
|
if (accumulatedDamageInTick < 1f) return;
|
||||||
|
@ -103,7 +114,10 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver
|
||||||
|
|
||||||
public void TakeDamage(float damage)
|
public void TakeDamage(float damage)
|
||||||
{
|
{
|
||||||
|
if (damage == 0f) return;
|
||||||
|
|
||||||
currentHealth -= damage;
|
currentHealth -= damage;
|
||||||
|
currentHealth = Mathf.Clamp(currentHealth, 0f, getMaxHealth());
|
||||||
OnHealthChange?.Invoke(currentHealth + damage, currentHealth);
|
OnHealthChange?.Invoke(currentHealth + damage, currentHealth);
|
||||||
|
|
||||||
accumulatedDamageInTick += damage;
|
accumulatedDamageInTick += damage;
|
||||||
|
|
Loading…
Reference in New Issue