BloodAndGore/Assets/Scripts/Enemies/Health.cs

30 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Saltosion.OneWeapon.Player;
using Saltosion.OneWeapon.Effects;
namespace Saltosion.OneWeapon.Enemies {
[RequireComponent(typeof(Explodable))]
public class Health : MonoBehaviour {
public float MaxHealth;
public float CurrentHealth;
private PlayerFun PlayerFun;
private Explodable Explodable;
private void Start() {
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
Explodable = GetComponent<Explodable>();
}
public void Damage(float amount, Vector2 fromDirection, bool applyPlayerDamageBoost) {
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
CurrentHealth -= amount * (1 + (applyPlayerDamageBoost ? PlayerFun.CurrentDamageBoost : 0.0f));
if (CurrentHealth <= 0) {
Explodable.Explode(true);
}
}
}
}