using System; using CIG.Extensions; using SUISSEngine; using UnityEngine; using UnityEngine.UI; namespace CIG { public class BalloonView : GridTileIcon { protected virtual void OnDestroy() { if (this._balloon != null) { this._balloon.CollectedEvent -= this.OnCollected; this._balloon = null; } this.CancelInvoke(new Action(this.Expire)); } public virtual void Init(Balloon balloon) { this._balloon = balloon; this._balloon.CollectedEvent += this.OnCollected; this.Invoke(new Action(this.Expire), this._balloon.TotalDurationInSeconds, false); } public virtual void OnBalloonClicked() { if (!this._hasCollected) { this._balloon.Collect(); this._hasCollected = true; } } protected void ResetExpirationTimer() { this.CancelInvoke(new Action(this.Expire)); this.Invoke(new Action(this.Expire), this._balloon.TotalDurationInSeconds, false); } private void Expire() { this._balloon.Expire(); } private void OnCollected(Balloon balloon) { balloon.CollectedEvent -= this.OnCollected; this.CancelInvoke(new Action(this.Expire)); } [SerializeField] private Button _button; protected Balloon _balloon; protected bool _hasCollected; } }