//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Wednesday, March 14, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using Snxxz.UI; public class SpGetBehaviour { public static void Init() { PlayerDatas.Instance.spNewGetEvent += OnGetNewSp; } public static void UnInit() { PlayerDatas.Instance.spNewGetEvent += OnGetNewSp; } static void OnGetNewSp(long _sp) { if (!WindowCenter.Instance.CheckOpen()) { WindowCenter.Instance.Open(true); } var win = WindowCenter.Instance.Get(); win.OnGetNewSp(_sp); } } namespace Snxxz.UI { public class SpGetWin : Window { [SerializeField] Transform m_ResetPoint; float interval = 0.2f; float nextShowTime = 0f; int queueMax = 10; Queue spQueue = new Queue(); #region Built-in protected override void BindController() { } protected override void AddListeners() { } protected override void OnPreOpen() { } protected override void OnAfterOpen() { } protected override void OnPreClose() { spQueue.Clear(); SpFloatPool.RecycleAll(); } protected override void OnAfterClose() { } #endregion public void OnGetNewSp(long _sp) { if (spQueue.Count >= queueMax) { spQueue.Dequeue(); } spQueue.Enqueue(_sp); } protected override void LateUpdate() { base.LateUpdate(); if (Time.time > nextShowTime) { if (spQueue.Count > 0) { var sp = spQueue.Dequeue(); var spFloat = SpFloatPool.Require(); spFloat.gameObject.SetActive(true); spFloat.transform.SetParentEx(m_ResetPoint, Vector3.zero, Quaternion.identity, Vector3.one); spFloat.Begin(sp); nextShowTime = Time.time + interval; } } } } }