diff --git a/Assets/Scripts/Enemy/EnemyAnimationHandler.cs b/Assets/Scripts/Enemy/EnemyAnimationHandler.cs index f763da9..7d8a397 100644 --- a/Assets/Scripts/Enemy/EnemyAnimationHandler.cs +++ b/Assets/Scripts/Enemy/EnemyAnimationHandler.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; +using UnityEngine.AI; public class EnemyAnimationHandler : MonoBehaviour { @@ -15,6 +16,9 @@ public class EnemyAnimationHandler : MonoBehaviour } void EnemyDie() { + GetComponent().enabled = false; + GetComponent().enabled = false; + StartCoroutine(AnimationDie()); } diff --git a/Assets/Scripts/Enemy/EnemyPathFinding.cs b/Assets/Scripts/Enemy/EnemyPathFinding.cs index 89e318a..e521546 100644 --- a/Assets/Scripts/Enemy/EnemyPathFinding.cs +++ b/Assets/Scripts/Enemy/EnemyPathFinding.cs @@ -29,6 +29,7 @@ public class EnemyPathFinding : MonoBehaviour Vector2 dir = closestTarget.position - transform.position; if (Physics2D.Raycast(transform.position, dir.normalized, ropeDistCheck, ropeCheckMask)) return; + agent.SetDestination(closestTarget.position); } diff --git a/Assets/Scripts/Player/HealthComponent.cs b/Assets/Scripts/Player/HealthComponent.cs index 15435da..dc4b7bb 100644 --- a/Assets/Scripts/Player/HealthComponent.cs +++ b/Assets/Scripts/Player/HealthComponent.cs @@ -6,6 +6,7 @@ using UnityUtils; public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver { + [SerializeField] private bool onlyCallZeroHealthOnce = true; [SerializeField] float maxHealth = 100; [SerializeField] float damageTickDelay = 0.25f; @@ -26,6 +27,8 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver [SerializeField] float squezeDamageScalor = 1f; + bool alreadyReachedZero = false; + void Awake() { currentHealth = maxHealth; @@ -62,12 +65,19 @@ public class HealthComponent : MonoBehaviour, ISquezeDamageReceiver accumulatedDamageInTick += damage; if (currentHealth <= 0) { + if (alreadyReachedZero && onlyCallZeroHealthOnce) return; + + alreadyReachedZero = true; // Make sure to flush accumulated when dying if (accumulatedDamageInTick > 1f) OnHealthChangeAtPos?.Invoke(transform.position.Add(y: 2f), accumulatedDamageInTick); OnHealthZero?.Invoke(); - BloodComputeShader.Instance.createBlood(transform.position, (int)(maxHealth *maxHealth * BloodComputeShader.Instance.scoreMult), maxHealth / 8.0f); + + int blood = (int)(maxHealth * 100.0f * BloodComputeShader.Instance.scoreMult); + + BloodComputeShader.Instance.createBlood(transform.position, blood/2, maxHealth / 8.0f); + BloodComputeShader.Instance.createBlood(transform.position, blood / 2, maxHealth / 8.0f); } }