BloodAndGore/Assets/Scripts/ExplodableHealth.cs

30 lines
919 B
C#
Raw Normal View History

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) {
2019-08-04 20:09:00 +02:00
BloodLauncher.Splatter(transform.position, -fromDirection, (int)(amount), 100f, 100);
MaxHealth -= amount * (1 + PlayerFun.CurrentDamageBoost);
if (MaxHealth <= 0) {
MaxHealth = 0;
Explodable.Explode(true);
}
}
}
}