LocalWind.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using UnityEngine;
  3. public class LocalWind : MonoBehaviour, IBlowee, ILevelItem
  4. {
  5. protected virtual void Start()
  6. {
  7. }
  8. public virtual Vector2 GetDir(IBlowable blowable, Vector2 pos)
  9. {
  10. return Vector2.zero;
  11. }
  12. public virtual float GetPower(IBlowable blowable, Vector2 pos)
  13. {
  14. return this.power;
  15. }
  16. public virtual float GetMaxAccelSqr()
  17. {
  18. return 0f;
  19. }
  20. public virtual void ParserIntegrator(Integrator integrator)
  21. {
  22. }
  23. public virtual GameObject GetGO()
  24. {
  25. return base.gameObject;
  26. }
  27. public virtual bool SelfFilter()
  28. {
  29. return false;
  30. }
  31. private void OnTriggerEnter2D(Collider2D other)
  32. {
  33. if (this.SelfFilter())
  34. {
  35. return;
  36. }
  37. if (this.filteredTags.Length > 0)
  38. {
  39. foreach (string tag in this.filteredTags)
  40. {
  41. if (other.CompareTag(tag))
  42. {
  43. return;
  44. }
  45. }
  46. }
  47. Component component = other.GetComponent(typeof(IBlowable));
  48. if (component != null)
  49. {
  50. IBlowable blowable = (IBlowable)component;
  51. blowable._OnWindEnter(this);
  52. }
  53. }
  54. private void OnTriggerExit2D(Collider2D other)
  55. {
  56. if (this.SelfFilter())
  57. {
  58. return;
  59. }
  60. if (this.filteredTags.Length > 0)
  61. {
  62. foreach (string tag in this.filteredTags)
  63. {
  64. if (other.CompareTag(tag))
  65. {
  66. return;
  67. }
  68. }
  69. }
  70. Component component = other.GetComponent(typeof(IBlowable));
  71. if (component != null)
  72. {
  73. IBlowable blowable = (IBlowable)component;
  74. blowable._OnWindExit(this);
  75. }
  76. }
  77. public virtual void OnReset()
  78. {
  79. }
  80. public virtual void OnPause(bool isPause)
  81. {
  82. }
  83. public virtual void OnEntertBlock(ILevelBlock block)
  84. {
  85. }
  86. public virtual void OnLeaveBlock(ILevelBlock block)
  87. {
  88. }
  89. public virtual void OnPickingTime(float time)
  90. {
  91. }
  92. public float power;
  93. public string[] filteredTags;
  94. public float maxHeroYSpeed;
  95. public float minHeroYSpeed;
  96. }