Fix enemies not dying
This commit is contained in:
parent
bdb0790629
commit
a24880784a
@ -6,9 +6,12 @@ namespace Saltosion.OneWeapon {
|
||||
public class Explodable : MonoBehaviour {
|
||||
public GameObject[] BodypartPrefabs;
|
||||
public bool DebugExplode = false;
|
||||
[Tooltip("This only applies if this GameObject also has the Health component.")]
|
||||
public bool KillOnZeroHealth = true;
|
||||
|
||||
private CameraFX CameraFX;
|
||||
private PlayerFun PlayerFun;
|
||||
private Health Health;
|
||||
|
||||
private void Start() {
|
||||
foreach (GameObject Obj in BodypartPrefabs) {
|
||||
@ -22,6 +25,7 @@ namespace Saltosion.OneWeapon {
|
||||
|
||||
CameraFX = Camera.main.GetComponent<CameraFX>();
|
||||
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
|
||||
Health = GetComponent<Health>();
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
@ -29,6 +33,10 @@ namespace Saltosion.OneWeapon {
|
||||
DebugExplode = false;
|
||||
Explode(false);
|
||||
}
|
||||
|
||||
if (Health != null && Health.CurrentHealth <= 0 && KillOnZeroHealth) {
|
||||
Explode(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void Explode(bool destroyGameObject) {
|
||||
|
@ -15,10 +15,7 @@ namespace Saltosion.OneWeapon {
|
||||
|
||||
public void Damage(float amount, Vector2 fromDirection) {
|
||||
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
|
||||
MaxHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
|
||||
if (MaxHealth <= 0) {
|
||||
MaxHealth = 0;
|
||||
}
|
||||
CurrentHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user