//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, March 14, 2018
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class SpFloat : MonoBehaviour
|
{
|
|
[SerializeField] ScreenMoveTo m_MoveTo;
|
[SerializeField] UIAlphaTween m_AlphaTween;
|
|
[SerializeField] Text m_Experience;
|
|
long spBuf = 0;
|
|
public void Begin(long _sp)
|
{
|
if (spBuf != _sp)
|
{
|
spBuf = _sp;
|
m_Experience.text = StringUtility.Contact("+SP", _sp);
|
}
|
|
m_MoveTo.Begin(OnFloatEnd);
|
m_Experience.color = m_Experience.color.SetA(1f);
|
m_AlphaTween.SetStartState();
|
m_AlphaTween.Play();
|
}
|
|
private void OnFloatEnd()
|
{
|
SpFloatPool.Recycle(this);
|
}
|
|
}
|
|
|
public class SpFloatPool
|
{
|
static GameObjectPoolManager.GameObjectPool pool = null;
|
|
public static SpFloat Require()
|
{
|
if (pool == null)
|
{
|
var prefab = UILoader.LoadPrefab("SpFloat");
|
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
}
|
|
if (pool != null)
|
{
|
var instance = pool.Request();
|
var spFloat = instance.GetComponent<SpFloat>();
|
spFloat.enabled = true;
|
return spFloat;
|
}
|
else
|
{
|
return null;
|
}
|
}
|
|
public static void Recycle(SpFloat _float)
|
{
|
pool.Release(_float.gameObject);
|
_float.enabled = false;
|
}
|
|
public static void RecycleAll()
|
{
|
if (pool != null)
|
{
|
pool.ReleaseAll();
|
}
|
}
|
|
public static void Clear()
|
{
|
if (pool != null)
|
{
|
pool = null;
|
}
|
}
|
|
|
}
|
|
}
|