//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, September 28, 2017
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using System.Collections.Generic;
|
|
namespace vnxbqy.UI
|
{
|
|
public class HeadUpQuestSignPool
|
{
|
|
static Dictionary<int, GameObjectPoolManager.GameObjectPool> pools = new Dictionary<int, GameObjectPoolManager.GameObjectPool>();
|
|
public static HeadUpQuestSign Require(HeadUpQuestSign.Pattern _pattern)
|
{
|
GameObjectPoolManager.GameObjectPool pool = null;
|
var poolKey = (int)_pattern;
|
if (!pools.ContainsKey(poolKey))
|
{
|
var prefab = UILoader.LoadPrefab(StringUtility.Contact("HeadUpQuestSign_", _pattern));
|
if (prefab != null)
|
{
|
pool = GameObjectPoolManager.Instance.RequestPool(prefab);
|
pools[poolKey] = pool;
|
}
|
}
|
else
|
{
|
pool = pools[poolKey];
|
}
|
|
if (pool != null)
|
{
|
var instance = pool.Request();
|
instance.SetActive(true);
|
return instance.GetComponent<HeadUpQuestSign>();
|
}
|
else
|
{
|
return null;
|
}
|
}
|
|
public static void Recycle(HeadUpQuestSign _questSign)
|
{
|
var pattern = _questSign.pattern;
|
GameObjectPoolManager.GameObjectPool pool;
|
if (pools.TryGetValue((int)pattern, out pool))
|
{
|
pool.Release(_questSign.gameObject);
|
_questSign.transform.SetParent(null);
|
_questSign.SetActive(false);
|
}
|
|
}
|
|
public static void Clear()
|
{
|
foreach (var key in pools.Keys)
|
{
|
var pool = pools[key];
|
if (pool != null)
|
{
|
pool.Clear();
|
}
|
}
|
pools.Clear();
|
}
|
}
|
}
|