您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

117 行
2.6 KiB

  1. using System;
  2. using System.Diagnostics;
  3. using SUISS.Core;
  4. using Tweening;
  5. using UnityEngine;
  6. namespace SUISSEngine
  7. {
  8. public class GridTileIcon : MonoBehaviour
  9. {
  10. //[DebuggerBrowsable(DebuggerBrowsableState.Never)]
  11. public event GridTileIcon.GridTileIconDestroyedEventHandler GridTileIconDestroyedEvent;
  12. private void FireGridTileIconDestroyedEvent()
  13. {
  14. if (this.GridTileIconDestroyedEvent != null)
  15. {
  16. this.GridTileIconDestroyedEvent(this);
  17. }
  18. }
  19. public int Priority
  20. {
  21. get
  22. {
  23. return this._priority;
  24. }
  25. }
  26. protected virtual void Start()
  27. {
  28. if (SingletonMonobehaviour<OverlayManager>.Instance.InteractionDisabled)
  29. {
  30. this.OnIconHidden();
  31. }
  32. }
  33. private void OnDestroy()
  34. {
  35. this.FireGridTileIconDestroyedEvent();
  36. }
  37. public virtual void Show()
  38. {
  39. this.TryStopTweener();
  40. base.gameObject.SetActive(true);
  41. this._tweener.FinishedPlaying += this.OnShowTweenerFinishedPlaying;
  42. this._tweener.Play();
  43. }
  44. public virtual void Hide()
  45. {
  46. this.TryStopTweener();
  47. this._tweener.FinishedPlaying += this.OnHideTweenerFinishedPlaying;
  48. this._tweener.PlayReverse();
  49. }
  50. public virtual void Remove()
  51. {
  52. this.TryStopTweener();
  53. this._tweener.FinishedPlaying += this.OnRemoveTweenerFinishedPlaying;
  54. this._tweener.PlayReverse();
  55. }
  56. protected virtual void OnIconShown()
  57. {
  58. }
  59. protected virtual void OnIconHidden()
  60. {
  61. base.gameObject.SetActive(false);
  62. }
  63. protected virtual void OnIconRemoved()
  64. {
  65. UnityEngine.Object.Destroy(base.gameObject);
  66. }
  67. private void TryStopTweener()
  68. {
  69. if (this._tweener.IsPlaying)
  70. {
  71. this._tweener.FinishedPlaying -= this.OnShowTweenerFinishedPlaying;
  72. this._tweener.FinishedPlaying -= this.OnHideTweenerFinishedPlaying;
  73. this._tweener.FinishedPlaying -= this.OnRemoveTweenerFinishedPlaying;
  74. this._tweener.Stop();
  75. }
  76. }
  77. private void OnShowTweenerFinishedPlaying(Tweener tweener)
  78. {
  79. tweener.FinishedPlaying -= this.OnShowTweenerFinishedPlaying;
  80. this.OnIconShown();
  81. }
  82. private void OnHideTweenerFinishedPlaying(Tweener tweener)
  83. {
  84. tweener.FinishedPlaying -= this.OnHideTweenerFinishedPlaying;
  85. this.OnIconHidden();
  86. }
  87. private void OnRemoveTweenerFinishedPlaying(Tweener tweener)
  88. {
  89. tweener.FinishedPlaying -= this.OnRemoveTweenerFinishedPlaying;
  90. this.OnIconRemoved();
  91. }
  92. [SerializeField]
  93. private int _priority;
  94. [SerializeField]
  95. protected Tweener _tweener;
  96. public delegate void GridTileIconDestroyedEventHandler(GridTileIcon icon);
  97. }
  98. }