2025-09-01 05:03:00 +05:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class CubeClash_ShockZone : MonoBehaviour
|
|
|
|
{
|
2025-09-04 12:13:13 +05:00
|
|
|
[Header("Timing")]
|
2025-09-01 05:03:00 +05:00
|
|
|
public float chargeTime = 2f;
|
|
|
|
public float activeTime = 2f;
|
2025-09-04 12:13:13 +05:00
|
|
|
|
|
|
|
[Header("Lifetime")]
|
|
|
|
[Tooltip("Destroy this ShockZone after this many seconds from spawn.")]
|
|
|
|
public float autoDestroyAfter = 5f; // default 5s
|
|
|
|
|
2025-09-01 05:03:00 +05:00
|
|
|
private float timer;
|
|
|
|
private bool active = false;
|
|
|
|
|
2025-09-04 12:13:13 +05:00
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
// Auto-destroy the whole object after N seconds
|
|
|
|
if (autoDestroyAfter > 0f)
|
|
|
|
Destroy(gameObject, autoDestroyAfter);
|
|
|
|
}
|
|
|
|
|
2025-09-01 05:03:00 +05:00
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
timer += Time.deltaTime;
|
|
|
|
|
|
|
|
if (!active && timer >= chargeTime)
|
|
|
|
{
|
|
|
|
active = true;
|
|
|
|
timer = 0f;
|
|
|
|
}
|
|
|
|
else if (active && timer >= activeTime)
|
|
|
|
{
|
|
|
|
active = false;
|
|
|
|
timer = 0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerStay(Collider other)
|
|
|
|
{
|
|
|
|
if (active && other.CompareTag("Zibu"))
|
|
|
|
{
|
|
|
|
Destroy(other.gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|