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.

62 lines
1.2 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class LighthouseLanding : MonoBehaviour
  5. {
  6. public bool switchedOff = false;
  7. private bool isTriggering = false;
  8. void Awake()
  9. {
  10. NotificationServer.register("statechange Searchlight", searchlightStateChanged);
  11. }
  12. void OnTriggerEnter(Collider other)
  13. {
  14. if (switchedOff)
  15. return;
  16. if (other.tag != "Player")
  17. return;
  18. if (Searchlight.state == Searchlight.SearchState.Chasing)
  19. return;
  20. if (isTriggering)
  21. return;
  22. isTriggering = true;
  23. NotificationServer.notify("show TakeoverButton");
  24. }
  25. void OnTriggerExit(Collider other)
  26. {
  27. if (switchedOff)
  28. return;
  29. if (other.tag != "Player")
  30. return;
  31. if (!isTriggering)
  32. return;
  33. isTriggering = false;
  34. NotificationServer.notify("hide TakeoverButton");
  35. }
  36. void searchlightStateChanged()
  37. {
  38. if (switchedOff)
  39. return;
  40. if (isTriggering && Searchlight.state == Searchlight.SearchState.Chasing)
  41. {
  42. isTriggering = false;
  43. NotificationServer.notify("hide TakeoverButton");
  44. }
  45. }
  46. public void switchOff()
  47. {
  48. switchedOff = true;
  49. NotificationServer.notify("hide TakeoverButton");
  50. NotificationServer.notify("play sfx", "assassination");
  51. NotificationServer.notify("switch off");
  52. }
  53. }