您不能選擇超過 %s 個話題 話題必須以字母或數字為開頭,可包含連接號 ('-') 且最長為 35 個字
 
 
 

93 行
2.1 KiB

  1. using System;
  2. using System.Diagnostics;
  3. using SUISSEngine;
  4. using Tweening;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. namespace CIG
  8. {
  9. public class FlyingCurrency : MonoBehaviour
  10. {
  11. //[DebuggerBrowsable(DebuggerBrowsableState.Never)]
  12. public event FlyingCurrency.FinishedPlayingEventHandler FinishedPlayingEvent;
  13. private void FireFinishedPlayingEvent()
  14. {
  15. if (this.FinishedPlayingEvent != null)
  16. {
  17. this.FinishedPlayingEvent(this);
  18. }
  19. }
  20. protected void Awake()
  21. {
  22. this._tweener.FinishedPlaying += this.OnFinishedPlaying;
  23. }
  24. protected void OnDestroy()
  25. {
  26. this._tweener.FinishedPlaying -= this.OnFinishedPlaying;
  27. }
  28. public virtual void PlayAnimation(CurrencyValue currency, Vector3 startPosition)
  29. {
  30. this._currency = currency;
  31. if (this._tweener.IsPlaying)
  32. {
  33. UnityEngine.Debug.LogWarningFormat("'{0}' Animation is already playing! - Doing nothing.", new object[]
  34. {
  35. this._currency.Currency
  36. });
  37. return;
  38. }
  39. base.transform.position = startPosition;
  40. this._tweener.Play();
  41. }
  42. public CurrencyTweenHelper CurrencyTweenHelper
  43. {
  44. get
  45. {
  46. return this._currencyTweenHelper;
  47. }
  48. }
  49. private void OnFinishedPlaying(Tweener tweener)
  50. {
  51. if (this._currencyTweenHelper != null)
  52. {
  53. this._currencyTweenHelper.FlyingCurrencyFinishedPlaying(this._currency);
  54. }
  55. this.FireFinishedPlayingEvent();
  56. if (this._particleSystem != null)
  57. {
  58. this._currencyImage.enabled = false;
  59. UnityEngine.Object.Destroy(base.gameObject, this._particleSystem.main.duration);
  60. }
  61. else
  62. {
  63. UnityEngine.Object.Destroy(base.gameObject);
  64. }
  65. }
  66. [SerializeField]
  67. protected Image _currencyImage;
  68. [SerializeField]
  69. private Tweener _tweener;
  70. [SerializeField]
  71. [Tooltip("(Optional)")]
  72. private CurrencyTweenHelper _currencyTweenHelper;
  73. [SerializeField]
  74. [Tooltip("(Optional)")]
  75. private ParticleSystem _particleSystem;
  76. private CurrencyValue _currency;
  77. public delegate void FinishedPlayingEventHandler(FlyingCurrency flyingCurrency);
  78. }
  79. }