//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, April 16, 2019 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class DungeonCollectItemSuccWin : Window { [SerializeField] Transform m_Container; [SerializeField] Text m_GainRemind; bool displaying = false; Clock clock = null; Queue displayItems = new Queue(); #region Built-in protected override void BindController() { } protected override void AddListeners() { } protected override void OnPreOpen() { displaying = false; m_Container.SetActive(false); displayItems.Clear(); DTCA718_tagMCCollectAwardItemInfo.onCollectSucc += OnCollectSucc; } protected override void OnAfterOpen() { } protected override void OnPreClose() { DTCA718_tagMCCollectAwardItemInfo.onCollectSucc -= OnCollectSucc; if (clock != null) { Clock.Stop(clock); clock = null; } } protected override void OnAfterClose() { } #endregion private void OnCollectSucc(HA718_tagMCCollectAwardItemInfo package) { for (int i = 0; i < package.Count; i++) { var item = new Item() { id = (int)package.AwardItemList[i].ItemID, count = package.AwardItemList[i].Count, }; displayItems.Enqueue(item); } if (!displaying) { DisplayCollectSucc(); } } void DisplayCollectSucc() { if (displayItems.Count > 0) { m_Container.SetActive(true); var item = displayItems.Dequeue(); var config = ItemConfig.Get(item.id); if (config != null) { m_GainRemind.text = Language.Get("DungeonCollectSucc", item.count, config.ItemName); } if (clock != null) { Clock.Stop(clock); clock = null; } clock = Clock.AlarmAfter(2, DisplayCollectSucc); } else { m_Container.SetActive(false); displaying = false; } } } }