2019-08-04 19:08:13 +02:00
|
|
|
|
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-04 19:08:13 +02:00
|
|
|
|
|
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 {
|
2019-08-04 19:08:13 +02:00
|
|
|
|
public float MaxHealth;
|
|
|
|
|
public float CurrentHealth;
|
|
|
|
|
|
2019-08-04 19:48:26 +02:00
|
|
|
|
private PlayerFun PlayerFun;
|
2019-08-14 22:20:54 +02:00
|
|
|
|
private Explodable Explodable;
|
2019-08-04 19:48:26 +02:00
|
|
|
|
|
2019-08-04 19:08:13 +02:00
|
|
|
|
private void Start() {
|
2019-08-04 19:48:26 +02:00
|
|
|
|
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
|
2019-08-14 22:20:54 +02:00
|
|
|
|
Explodable = GetComponent<Explodable>();
|
2019-08-04 19:08:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
2019-08-22 21:50:50 +02:00
|
|
|
|
public void Damage(float amount, Vector2 fromDirection, bool causedByPlayerAttack) {
|
2019-08-14 23:27:14 +02:00
|
|
|
|
DebrisLauncher.Splatter(DebrisType.Blood, transform.position, -fromDirection, (int)(amount), 100f, 100);
|
2019-08-22 21:50:50 +02:00
|
|
|
|
CurrentHealth -= amount * (1 + (causedByPlayerAttack ? PlayerFun.CurrentDamageBoost : 0.0f));
|
2019-08-14 22:20:54 +02:00
|
|
|
|
if (CurrentHealth <= 0) {
|
2019-08-22 21:50:50 +02:00
|
|
|
|
Explodable.Explode(true, causedByPlayerAttack);
|
2019-08-14 22:20:54 +02:00
|
|
|
|
}
|
2019-08-04 19:08:13 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|