using System.Collections; using System.Collections.Generic; using UnityEngine; public class LighthouseLanding : MonoBehaviour { public bool switchedOff = false; private bool isTriggering = false; static private Transform lastTriggered; void Awake() { NotificationServer.register("statechange Searchlight", searchlightStateChanged); NotificationServer.register("switch off", switchBeamOff); } void OnTriggerEnter(Collider other) { if (switchedOff) return; if (other.tag != "Player") return; if (Searchlight.state == Searchlight.SearchState.Chasing) return; if (isTriggering) return; isTriggering = true; NotificationServer.notify("show TakeoverButton"); lastTriggered = transform; } void OnTriggerExit(Collider other) { if (switchedOff) return; if (other.tag != "Player") return; if (!isTriggering) return; isTriggering = false; NotificationServer.notify("hide TakeoverButton"); } void searchlightStateChanged() { if (switchedOff) return; if (isTriggering && Searchlight.state == Searchlight.SearchState.Chasing) { isTriggering = false; NotificationServer.notify("hide TakeoverButton"); } } public void switchOff() { NotificationServer.notify("hide TakeoverButton"); NotificationServer.notify("play sfx", "assassination:0.75"); NotificationServer.notify("switch off", lastTriggered.parent.gameObject); } public void switchBeamOff(object _) { if (transform == lastTriggered) switchedOff = true; } }