2019-08-04 19:08:13 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Saltosion.OneWeapon {
|
|
|
|
|
[RequireComponent(typeof(Explodable))]
|
|
|
|
|
public class ExplodableHealth : MonoBehaviour {
|
|
|
|
|
public float MaxHealth;
|
|
|
|
|
public float CurrentHealth;
|
|
|
|
|
|
|
|
|
|
private Explodable Explodable;
|
|
|
|
|
|
2019-08-04 19:48:26 +02:00
|
|
|
|
private PlayerFun PlayerFun;
|
|
|
|
|
|
2019-08-04 19:08:13 +02:00
|
|
|
|
private void Start() {
|
|
|
|
|
Explodable = GetComponent<Explodable>();
|
2019-08-04 19:48:26 +02:00
|
|
|
|
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
|
2019-08-04 19:08:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Damage(float amount, Vector2 fromDirection) {
|
|
|
|
|
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(10 * amount), 100f, 100);
|
2019-08-04 19:48:26 +02:00
|
|
|
|
MaxHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
|
2019-08-04 19:08:13 +02:00
|
|
|
|
if (MaxHealth <= 0) {
|
|
|
|
|
MaxHealth = 0;
|
|
|
|
|
Explodable.Explode(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|