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

30 lines
649 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-06 17:04:47 +00:00
public float health;
2019-10-06 15:44:41 +00:00
protected Particle particle;
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-06 17:04:47 +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-06 22:21:35 +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-06 17:04:47 +00:00
if(health < 0) {
2019-10-06 15:44:41 +00:00
Destroy(this.gameObject);
}
}
}