//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, March 14, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using Snxxz.UI;
|
|
public class SpGetBehaviour
|
{
|
static int queueMax = 10;
|
static Queue<long> spQueue = new Queue<long>();
|
|
public static void Init()
|
{
|
PlayerDatas.Instance.spNewGetEvent += OnGetNewSp;
|
}
|
|
public static void UnInit()
|
{
|
PlayerDatas.Instance.spNewGetEvent += OnGetNewSp;
|
}
|
|
static void OnGetNewSp(long _sp)
|
{
|
if (!WindowCenter.Instance.IsOpen("SpGetWin"))
|
{
|
WindowCenter.Instance.Open<SpGetWin>(true);
|
}
|
|
if (spQueue.Count >= queueMax)
|
{
|
spQueue.Dequeue();
|
}
|
|
spQueue.Enqueue(_sp);
|
}
|
|
public static long GetSp()
|
{
|
if (spQueue.Count > 0)
|
{
|
return spQueue.Dequeue();
|
}
|
else
|
{
|
return 0;
|
}
|
}
|
|
public static void Clear()
|
{
|
spQueue.Clear();
|
}
|
|
}
|
|
namespace Snxxz.UI
|
{
|
|
public class SpGetWin : Window
|
{
|
[SerializeField] Transform m_ResetPoint;
|
|
float interval = 0.2f;
|
float nextShowTime = 0f;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
SpGetBehaviour.Clear();
|
SpFloatPool.RecycleAll();
|
}
|
|
protected override void OnAfterClose()
|
{
|
|
}
|
#endregion
|
|
protected override void LateUpdate()
|
{
|
base.LateUpdate();
|
|
if (Time.time > nextShowTime)
|
{
|
var sp = SpGetBehaviour.GetSp();
|
if (sp > 0)
|
{
|
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;
|
}
|
}
|
|
}
|
|
}
|
|
}
|