You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

77 lines
1.6 KiB

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);
NotificationServer.register("restart scene", restartScene);
}
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;
}
public void restartScene()
{
switchedOff = false;
}
}