Super Knight : Enter the Dungeon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.1 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Pool<T>
{
public Dictionary<string, T> dic = new Dictionary<string, T>();
public T Add(GameObject obj)
{
if (dic.ContainsKey(obj.name))
return dic[obj.name];
else
{
obj.name = $"{dic.Keys.Count}";
dic.Add(obj.name, obj.GetComponent<T>());
return dic[obj.name];
}
}
//Pool<ComboEffect> pool = new Pool<ComboEffect>();
//void OnCombo2(int cntDestroy)
//{
// ComboEffect effect = (new List<ComboEffect>(pool.dic.Values)).Find(a => !a.gameObject.activeSelf);
// //ComboEffect effect = null;
// //var list = pool.dic.GetEnumerator();
// //while (list.MoveNext())
// //{
// // if (!list.Current.Value.gameObject.activeSelf)
// // {
// // effect = list.Current.Value;
// // break;
// // }
// //}
// if (effect == null)
// effect = pool.Add(ResourcePool.ObjectCreateStatic(prefabComboEffect, transform));
// effect.OnInitialized(cntDestroy);
//}
}