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.

57 lines
1.2 KiB

7 years ago
7 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class VictoryScript : MonoBehaviour
  5. {
  6. private bool isTriggering = false;
  7. void OnTriggerEnter(Collider other)
  8. {
  9. if (other.tag != "Player")
  10. return;
  11. if (Searchlight.state == Searchlight.SearchState.Chasing)
  12. return;
  13. if (isTriggering)
  14. return;
  15. isTriggering = true;
  16. NotificationServer.notify("show VictoryButton");
  17. NotificationServer.register("restart scene", restartScene);
  18. }
  19. void OnTriggerExit(Collider other)
  20. {
  21. if (other.tag != "Player")
  22. return;
  23. if (!isTriggering)
  24. return;
  25. isTriggering = false;
  26. NotificationServer.notify("hide VictoryButton");
  27. }
  28. void searchlightStateChanged()
  29. {
  30. if (isTriggering && Searchlight.state == Searchlight.SearchState.Chasing)
  31. {
  32. isTriggering = false;
  33. NotificationServer.notify("hide VictoryButton");
  34. }
  35. }
  36. public void victoryClicked()
  37. {
  38. NotificationServer.notify("hide VictoryButton");
  39. NotificationServer.notify("switch off", null);
  40. NotificationServer.notify("fade bgm");
  41. NotificationServer.notify("play sfx", "shipSpotted_2:0.5");
  42. NotificationServer.notify("show VictoryPanel");
  43. NotificationServer.notify("hide GameUI");
  44. }
  45. public void restartScene()
  46. {
  47. isTriggering = false;
  48. }
  49. }