BattleZoneGate.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using GameWorld;
  3. using UnityEngine;
  4. [RequireComponent(typeof(SpineAnimation))]
  5. public class BattleZoneGate : BaseBehaviour
  6. {
  7. private void Awake()
  8. {
  9. this.animator = base.GetComponent<Animator>();
  10. this.box = base.GetComponent<Collider2D>();
  11. this.box.enabled = false;
  12. }
  13. private void OnEnable()
  14. {
  15. EventManager.RegisterEvent<HitWallArgs>("HitWall", new EventManager.FBEventHandler<HitWallArgs>(this.HitWall), EventManager.ListenerQueue.Game);
  16. }
  17. private void OnDisable()
  18. {
  19. EventManager.UnregisterEvent<HitWallArgs>("HitWall", new EventManager.FBEventHandler<HitWallArgs>(this.HitWall), EventManager.ListenerQueue.Game);
  20. }
  21. private bool HitWall(string name, object sender, HitWallArgs msg)
  22. {
  23. float x = msg.who.transform.position.x;
  24. float diameter = 1f;
  25. bool flag = MathfX.isInMiddleRange(x, base.transform.position.x, diameter);
  26. if (flag && this.isAppearing)
  27. {
  28. this.animator.Play("Hit");
  29. }
  30. return true;
  31. }
  32. public void Appear()
  33. {
  34. this.animator.Play("Open");
  35. this.isAppearing = true;
  36. }
  37. public void DisAppear()
  38. {
  39. this.animator.Play("DisAppear");
  40. this.isAppearing = false;
  41. }
  42. public Transform positionCamera;
  43. public Transform playerLimitPos;
  44. public BattleZoneGate.GateType type;
  45. private Animator animator;
  46. private float lastCameraX;
  47. private float lastPlayerX;
  48. private bool isAppearing;
  49. private Collider2D box;
  50. public enum GateType
  51. {
  52. Left = 1,
  53. Right,
  54. None = 0
  55. }
  56. }