Files
2026-03-17 18:10:00 +02:00

64 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DroneTrigger : MonoBehaviour
{
public LightWave wave1;
public LightWave wave2;
public DroneMovement droneMovement;
public float droneSpeed = 40f;
public float davidSpeed = 10f;
public float davidSimDelay = 0.5f;
private bool _fired = false;
public void Reset() { _fired = false; }
void Update()
{
if (_fired) return;
if (transform.position.z >= 0f)
{
_fired = true;
droneMovement.StopMoving();
bool isSimulation = GameManager.Instance != null && GameManager.Instance.isSimulation;
bool isView2 = GameManager.Instance != null && GameManager.Instance.isView2;
if (isView2)
StartCoroutine(LaunchView2());
else if (isSimulation)
StartCoroutine(LaunchSim());
else
StartCoroutine(LaunchReal());
}
}
IEnumerator LaunchSim()
{
float delay = davidSimDelay / (droneSpeed / davidSpeed);
wave1.StartWave();
wave1.SetDroneText(true, isSimulation: true, simDelay: delay);
yield return new WaitForSeconds(delay);
wave2.StartWave();
wave2.SetDroneText(false, isSimulation: true, simDelay: delay);
}
IEnumerator LaunchReal()
{
wave1.StartWave();
wave1.SetDroneText(true, isSimulation: false, simDelay: 0);
wave2.StartWave();
wave2.SetDroneText(false, isSimulation: false, simDelay: 0);
yield return null;
}
IEnumerator LaunchView2()
{
wave1.StartWave();
wave2.StartWave();
wave1.showBothTextsAtOnce = true;
wave1.wave2ref = wave2;
wave1.ShowTextForBoth();
yield return new WaitForSeconds(0.1f);
}
}