55 lines
891 B
C#
55 lines
891 B
C#
using UnityEngine;
|
|
|
|
public class ExplosionPlatformActivator : MonoBehaviour
|
|
{
|
|
public GameObject Effect;
|
|
|
|
public float TimeDelay;
|
|
|
|
public float DefaultRepeatTime = 5f;
|
|
|
|
public float NearRepeatTime = 3f;
|
|
|
|
private float currentTime;
|
|
|
|
private float currentRepeatTime;
|
|
|
|
private bool canUpdate;
|
|
|
|
private void Start()
|
|
{
|
|
currentRepeatTime = DefaultRepeatTime;
|
|
Invoke("Init", TimeDelay);
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
canUpdate = true;
|
|
Effect.SetActive(true);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (canUpdate && !(Effect == null))
|
|
{
|
|
currentTime += Time.deltaTime;
|
|
if (currentTime > currentRepeatTime)
|
|
{
|
|
currentTime = 0f;
|
|
Effect.SetActive(false);
|
|
Effect.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider coll)
|
|
{
|
|
currentRepeatTime = NearRepeatTime;
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
currentRepeatTime = DefaultRepeatTime;
|
|
}
|
|
}
|