|
- using System;
- using CIG;
- using CIG.Translation;
- using CIGEnums;
- using SUISS.Core;
- using SUISSEngine;
- using Tweening;
- using UnityEngine;
-
- public class CIGBuySign : MonoBehaviour
- {
- protected void Awake()
- {
- this._currencyAnimationSource.Init(this._currencyAnimationObject);
- }
-
- protected virtual void OnGridTileStatusChanged(GridTile.Status oldStatus)
- {
- if (this == null)
- {
- return;
- }
- if (this.chest != null && this.sign != null)
- {
- this.chest.sortingOrder = this.sign.sortingOrder + 1;
- }
- }
-
- public void Buy(PlingType type, string currencyType, decimal value)
- {
- if (!this._haveChest)
- {
- return;
- }
- SingletonMonobehaviour<CIGGameState>.Instance.UnprocessedChestGold += value;
- if (this.sign != null)
- {
- this.sign.enabled = false;
- }
- Action collect = this.CollectAction(type, currencyType, value, this.chestGO, this._chestTweener);
- BoxCollider2D collider = null;
- if (this.chestGO != null)
- {
- collider = this.chestGO.GetComponent<BoxCollider2D>();
- }
- if (collider != null)
- {
- this.chestGO.transform.parent = base.transform.parent;
- collider.enabled = true;
- Timer timer = null;
- timer = SingletonMonobehaviour<TimerManager>.Instance.CreateClockTimer(DateTimeKind.Utc, TimeSpan.FromSeconds(15.0), delegate()
- {
- if (collider != null)
- {
- collider.enabled = false;
- }
- if (timer != null)
- {
- timer.Cancel();
- }
- collect();
- });
- Clickable.Instance(this.chestGO).OnClickEvent += delegate(GameObject target)
- {
- if (collider != null)
- {
- collider.enabled = false;
- }
- if (timer != null)
- {
- timer.Cancel();
- }
- collect();
- };
- }
- else
- {
- collect();
- }
- }
-
- public void EnableChest()
- {
- this.chestGO.SetActive(true);
- this._haveChest = true;
- }
-
- private Action CollectAction(PlingType type, string currencyType, decimal value, GameObject chestGO, Tweener chestTweener)
- {
- return delegate()
- {
- if (value > 0m && SingletonMonobehaviour<CIGGameState>.IsAvailable)
- {
- SingletonMonobehaviour<CIGGameState>.Instance.UnprocessedChestGold -= value;
- SingletonMonobehaviour<CIGGameState>.Instance.EarnCurrencies(new Currencies(currencyType, value), this._currencyAnimationObject);
- if (chestGO != null)
- {
- Pling pling = this._plingManager.Show(type, Vector3.zero, Clip.Ping);
- ILocalizedString value2 = Localization.Integer(value);
- if (type == PlingType.Cash_Green || type == PlingType.Cash_Red)
- {
- pling.ShowWithParticles(value2, ParticleType.CashFountain);
- }
- else
- {
- pling.Show(value2);
- }
- }
- }
- if (chestTweener)
- {
- chestTweener.Play();
- }
- else if (chestGO != null)
- {
- UnityEngine.Object.Destroy(chestGO);
- }
- };
- }
-
- public GameObject chestGO;
-
- public SpriteRenderer sign;
-
- public SpriteRenderer chest;
-
- [SerializeField]
- private Tweener _chestTweener;
-
- [SerializeField]
- private PlingManager _plingManager;
-
- [SerializeField]
- private CurrencyAnimationSource _currencyAnimationSource;
-
- protected bool _haveChest;
-
- private object _currencyAnimationObject = new object();
- }
|