SceneEventGateLogic.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityGameFramework.Runtime;
  6. /// <summary>
  7. /// 场景组件 大门
  8. /// </summary>
  9. public class SceneEventGateLogic : MonoBehaviour
  10. {
  11. public bool isEntry = false;
  12. private void Awake()
  13. {
  14. }
  15. // Start is called before the first frame update
  16. void Start()
  17. {
  18. }
  19. public void OnTriggerEnter(Collider collider)
  20. {
  21. Role role = collider.GetComponent<Role>();
  22. if(role && role.IsTeamLeader)
  23. {
  24. isEntry = true;
  25. SceneEventAreaLockLogic areaLock;
  26. if (this.TryGetComponent<SceneEventAreaLockLogic>(out areaLock))
  27. {
  28. if(areaLock.IsUnlockDoor)
  29. {
  30. OpenDoor();
  31. }
  32. }
  33. }
  34. }
  35. public void OpenDoor()
  36. {
  37. if(isEntry)
  38. {
  39. Animator anim = this.GetComponent<Animator>();
  40. anim.Play("open");
  41. }
  42. }
  43. public void OnTriggerExit(Collider collider)
  44. {
  45. //Role role = collider.GetComponent<Role>();
  46. //if (role)
  47. //{
  48. // isEntry = false;
  49. // Animator anim = this.GetComponent<Animator>();
  50. // anim.Play("close");
  51. //}
  52. }
  53. public void EnableCollider()
  54. {
  55. }
  56. public void OnClickInteractive()
  57. {
  58. }
  59. }