BloodAndGore/Assets/Scripts/Enemies/Health.cs

30 lines
1.0 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2019-08-14 16:17:48 +02:00
using Saltosion.OneWeapon.Player;
using Saltosion.OneWeapon.Effects;
2019-08-14 16:17:48 +02:00
namespace Saltosion.OneWeapon.Enemies {
2019-08-14 22:20:54 +02:00
[RequireComponent(typeof(Explodable))]
2019-08-07 20:03:51 +02:00
public class Health : MonoBehaviour {
public float MaxHealth;
public float CurrentHealth;
private PlayerFun PlayerFun;
2019-08-14 22:20:54 +02:00
private Explodable Explodable;
private void Start() {
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
2019-08-14 22:20:54 +02:00
Explodable = GetComponent<Explodable>();
}
2019-08-14 21:31:58 +02:00
public void Damage(float amount, Vector2 fromDirection, bool applyPlayerDamageBoost) {
2019-08-04 20:09:00 +02:00
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
2019-08-14 21:31:58 +02:00
CurrentHealth -= amount * (1 + (applyPlayerDamageBoost ? PlayerFun.CurrentDamageBoost : 0.0f));
2019-08-14 22:20:54 +02:00
if (CurrentHealth <= 0) {
Explodable.Explode(true);
}
}
}
}