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.

36 lines
927 B

4 years ago
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Objective : MonoBehaviour
  5. {
  6. private List<PlayerController> onObjective = new List<PlayerController>();
  7. private GameStateController GameState;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. GameState = FindObjectOfType<GameStateController>();
  12. }
  13. private void OnTriggerEnter(Collider other)
  14. {
  15. PlayerController horse = other.GetComponent<PlayerController>();
  16. if (horse != null)
  17. onObjective.Add(horse);
  18. }
  19. private void OnTriggerExit(Collider other)
  20. {
  21. PlayerController horse = other.GetComponent<PlayerController>();
  22. if (horse != null)
  23. onObjective.Remove(horse);
  24. }
  25. // Update is called once per frame
  26. void Update()
  27. {
  28. if(onObjective.Count >= 1)
  29. GameState.WinState();
  30. }
  31. }