- using System;
- using System.Diagnostics;
- using SUISS.Core;
- using Tweening;
- using UnityEngine;
-
- namespace SUISSEngine
- {
- public class GridTileIcon : MonoBehaviour
- {
- //[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- public event GridTileIcon.GridTileIconDestroyedEventHandler GridTileIconDestroyedEvent;
-
- private void FireGridTileIconDestroyedEvent()
- {
- if (this.GridTileIconDestroyedEvent != null)
- {
- this.GridTileIconDestroyedEvent(this);
- }
- }
-
- public int Priority
- {
- get
- {
- return this._priority;
- }
- }
-
- protected virtual void Start()
- {
- if (SingletonMonobehaviour<OverlayManager>.Instance.InteractionDisabled)
- {
- this.OnIconHidden();
- }
- }
-
- private void OnDestroy()
- {
- this.FireGridTileIconDestroyedEvent();
- }
-
- public virtual void Show()
- {
- this.TryStopTweener();
- base.gameObject.SetActive(true);
- this._tweener.FinishedPlaying += this.OnShowTweenerFinishedPlaying;
- this._tweener.Play();
- }
-
- public virtual void Hide()
- {
- this.TryStopTweener();
- this._tweener.FinishedPlaying += this.OnHideTweenerFinishedPlaying;
- this._tweener.PlayReverse();
- }
-
- public virtual void Remove()
- {
- this.TryStopTweener();
- this._tweener.FinishedPlaying += this.OnRemoveTweenerFinishedPlaying;
- this._tweener.PlayReverse();
- }
-
- protected virtual void OnIconShown()
- {
- }
-
- protected virtual void OnIconHidden()
- {
- base.gameObject.SetActive(false);
- }
-
- protected virtual void OnIconRemoved()
- {
- UnityEngine.Object.Destroy(base.gameObject);
- }
-
- private void TryStopTweener()
- {
- if (this._tweener.IsPlaying)
- {
- this._tweener.FinishedPlaying -= this.OnShowTweenerFinishedPlaying;
- this._tweener.FinishedPlaying -= this.OnHideTweenerFinishedPlaying;
- this._tweener.FinishedPlaying -= this.OnRemoveTweenerFinishedPlaying;
- this._tweener.Stop();
- }
- }
-
- private void OnShowTweenerFinishedPlaying(Tweener tweener)
- {
- tweener.FinishedPlaying -= this.OnShowTweenerFinishedPlaying;
- this.OnIconShown();
- }
-
- private void OnHideTweenerFinishedPlaying(Tweener tweener)
- {
- tweener.FinishedPlaying -= this.OnHideTweenerFinishedPlaying;
- this.OnIconHidden();
- }
-
- private void OnRemoveTweenerFinishedPlaying(Tweener tweener)
- {
- tweener.FinishedPlaying -= this.OnRemoveTweenerFinishedPlaying;
- this.OnIconRemoved();
- }
-
- [SerializeField]
- private int _priority;
-
- [SerializeField]
- protected Tweener _tweener;
-
- public delegate void GridTileIconDestroyedEventHandler(GridTileIcon icon);
- }
- }
|