30 lines
924 B
C#
30 lines
924 B
C#
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;
|
|
|
|
private PlayerFun PlayerFun;
|
|
|
|
private void Start() {
|
|
Explodable = GetComponent<Explodable>();
|
|
PlayerFun = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerFun>();
|
|
}
|
|
|
|
public void Damage(float amount, Vector2 fromDirection) {
|
|
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(10 * amount), 100f, 100);
|
|
MaxHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
|
|
if (MaxHealth <= 0) {
|
|
MaxHealth = 0;
|
|
Explodable.Explode(true);
|
|
}
|
|
}
|
|
}
|
|
}
|