CameraBorderTrigger.cs 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using CIS;
  3. using UnityEngine;
  4. public class CameraBorderTrigger : MonoBehaviour
  5. {
  6. private void Awake()
  7. {
  8. this.myTrans = base.transform;
  9. }
  10. private void Start()
  11. {
  12. this.cameraTrans = SingletonMonoBehaviourClass<SHICameraController>.instance.transform;
  13. }
  14. private void Update()
  15. {
  16. if (this.entered)
  17. {
  18. return;
  19. }
  20. if (this.towards == CameraBorderTrigger.Towards.right && this.cameraTrans.position.x + this.cameraWidth / 2f > this.myTrans.position.x && this.handler != null)
  21. {
  22. this.entered = true;
  23. this.handler._onTriggerEnter2D(PlayerControllerDemo.Instance.GetComponent<Collider2D>());
  24. }
  25. }
  26. private Transform myTrans;
  27. private float cameraWidth = 1920f;
  28. private float cameraHight = 1080f;
  29. private Transform cameraTrans;
  30. private CameraBorderTrigger.Towards towards;
  31. public ColliderTriggerHandler handler;
  32. public bool entered;
  33. public enum Towards
  34. {
  35. right,
  36. left,
  37. up,
  38. down
  39. }
  40. }