using System; using System.Collections; using Spine.Unity; using UnityEngine; public class SnoutCoinShopPopup : MonoBehaviour { public GameObject BestValueRibbon { get { return this.m_bestValueRibbon; } } public GameObject MostPopularRibbon { get { return this.m_mostPopularRibbon; } } public static bool DialogOpen { get { return SnoutCoinShopPopup.s_dialogOpen; } } private void Start() { this.m_playingAnimation = false; this.m_hugePackAnimation.timeScale = float.MaxValue; this.m_hugePackAnimation.AnimationState.AddAnimation(0, "SafeIdle", false, 0f); this.m_hugePackAnimation.AnimationState.End += this.OnAnimationEnd; this.m_largePackAnimation.timeScale = float.MaxValue; this.m_largePackAnimation.AnimationState.AddAnimation(0, "BarrelIdle", false, 0f); this.m_largePackAnimation.AnimationState.End += this.OnAnimationEnd; this.m_mediumPackAnimation.timeScale = float.MaxValue; this.m_mediumPackAnimation.AnimationState.AddAnimation(0, "CoinPillar_Idle", false, 0f); this.m_mediumPackAnimation.AnimationState.End += this.OnAnimationEnd; this.m_smallPackAnimation.timeScale = float.MaxValue; this.m_smallPackAnimation.AnimationState.AddAnimation(0, "PiggieBankIdle", false, 0f); this.m_smallPackAnimation.AnimationState.End += this.OnAnimationEnd; this.m_ultimatePackAnimation.AnimationState.AddAnimation(0, "Shower_Idle", true, 0f); base.StartCoroutine(this.PlayRandomAnimation(2f)); } private void OnEnable() { this.m_bestValueRibbon.SetActive(false); this.m_mostPopularRibbon.SetActive(false); this.ShowOfferBanner(false); this.UpdatePrices(null); SnoutCoinShopPopup.s_dialogOpen = true; EventManager.Send(new UIEvent(UIEvent.Type.OpenedSnoutCoinShop)); } private void OnDisable() { SnoutCoinShopPopup.s_dialogOpen = false; EventManager.Send(new UIEvent(UIEvent.Type.ClosedSnoutCoinShop)); } private void OnDestroy() { this.m_hugePackAnimation.AnimationState.End -= this.OnAnimationEnd; this.m_largePackAnimation.AnimationState.End -= this.OnAnimationEnd; this.m_mediumPackAnimation.AnimationState.End -= this.OnAnimationEnd; this.m_smallPackAnimation.AnimationState.End -= this.OnAnimationEnd; } public void ShowOfferBanner(bool show) { if (this.m_offerBanner != null) { this.m_offerBanner.SetActive(show); } } public GameObject AddRibbon(ShopRibbon ribbon) { Transform transform = base.transform.Find("Items/" + ribbon.itemId); if (!transform) { return null; } string text = string.Empty; GameObject original = null; ShopRibbon.Ribbon ribbonType = ribbon.ribbonType; if (ribbonType != ShopRibbon.Ribbon.BestValue) { if (ribbonType == ShopRibbon.Ribbon.MostPopular) { text = "MostPopularRibbon"; original = this.m_mostPopularRibbon; } } else { text = "BestValueRibbon"; original = this.m_bestValueRibbon; } if (string.IsNullOrEmpty(text)) { return null; } Transform transform2 = transform.Find(text); GameObject gameObject = null; if (transform2 != null) { gameObject = UnityEngine.Object.Instantiate(original); gameObject.name = text; gameObject.transform.parent = transform2; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localScale = Vector3.one; gameObject.SetActive(true); } return gameObject; } public void UpdatePrices(Shop _shop = null) { if (_shop != null) { this.shop = _shop; } if (this.shop == null) { return; } bool show = false; PurchaseInfo[] componentsInChildren = base.gameObject.GetComponentsInChildren(); foreach (PurchaseInfo purchaseInfo in componentsInChildren) { Button component = purchaseInfo.GetComponent