1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-29 03:24:30 +00:00
gravity-fusion/Assets/Components/Disappear.cs

36 lines
745 B
C#
Raw Normal View History

2019-10-06 15:44:41 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Disappear : MonoBehaviour
{
2019-10-07 11:44:26 +00:00
protected float _health;
2019-10-06 15:44:41 +00:00
protected Particle particle;
2019-10-07 11:44:26 +00:00
public float Health {
get {
return _health;
}
}
2019-10-06 15:44:41 +00:00
protected void Awake() {
particle = GetComponent<Particle>();
}
2019-10-06 17:04:47 +00:00
protected void Start() {
2019-10-06 15:44:41 +00:00
ResetTimer();
}
public void ResetTimer() {
2019-10-07 11:44:26 +00:00
_health = 1f;
2019-10-06 15:44:41 +00:00
}
2019-10-06 17:04:47 +00:00
protected void Update() {
2019-10-07 11:44:26 +00:00
_health -= Mathf.Pow(particle.gameController.particleDurationConstant, particle.gameController.maxTierPresent - particle.Tier - 4) * Time.deltaTime;
2019-10-06 15:44:41 +00:00
2019-10-07 11:44:26 +00:00
if(_health < 0) {
2019-10-06 15:44:41 +00:00
Destroy(this.gameObject);
}
}
}