|
- using System;
- using System.Diagnostics;
- using SUISSEngine;
- using Tweening;
- using UnityEngine;
- using UnityEngine.UI;
-
- namespace CIG
- {
- public class FlyingCurrency : MonoBehaviour
- {
- //[DebuggerBrowsable(DebuggerBrowsableState.Never)]
- public event FlyingCurrency.FinishedPlayingEventHandler FinishedPlayingEvent;
-
- private void FireFinishedPlayingEvent()
- {
- if (this.FinishedPlayingEvent != null)
- {
- this.FinishedPlayingEvent(this);
- }
- }
-
- protected void Awake()
- {
- this._tweener.FinishedPlaying += this.OnFinishedPlaying;
- }
-
- protected void OnDestroy()
- {
- this._tweener.FinishedPlaying -= this.OnFinishedPlaying;
- }
-
- public virtual void PlayAnimation(CurrencyValue currency, Vector3 startPosition)
- {
- this._currency = currency;
- if (this._tweener.IsPlaying)
- {
- UnityEngine.Debug.LogWarningFormat("'{0}' Animation is already playing! - Doing nothing.", new object[]
- {
- this._currency.Currency
- });
- return;
- }
- base.transform.position = startPosition;
- this._tweener.Play();
- }
-
- public CurrencyTweenHelper CurrencyTweenHelper
- {
- get
- {
- return this._currencyTweenHelper;
- }
- }
-
- private void OnFinishedPlaying(Tweener tweener)
- {
- if (this._currencyTweenHelper != null)
- {
- this._currencyTweenHelper.FlyingCurrencyFinishedPlaying(this._currency);
- }
- this.FireFinishedPlayingEvent();
- if (this._particleSystem != null)
- {
- this._currencyImage.enabled = false;
- UnityEngine.Object.Destroy(base.gameObject, this._particleSystem.main.duration);
- }
- else
- {
- UnityEngine.Object.Destroy(base.gameObject);
- }
- }
-
- [SerializeField]
- protected Image _currencyImage;
-
- [SerializeField]
- private Tweener _tweener;
-
- [SerializeField]
- [Tooltip("(Optional)")]
- private CurrencyTweenHelper _currencyTweenHelper;
-
- [SerializeField]
- [Tooltip("(Optional)")]
- private ParticleSystem _particleSystem;
-
- private CurrencyValue _currency;
-
- public delegate void FinishedPlayingEventHandler(FlyingCurrency flyingCurrency);
- }
- }
|