Beispiel #1
0
        public void removeNode(GameObject node)
        {
            if (nodeList.Count == 0)
            {
                return;
            }

            LListNode del = null;

            foreach (LListNode elem in nodeList)
            {
                if (elem.obj == node)
                {
                    del = elem;
                    nodeList.Remove(elem);
                    break;
                }
            }
            if (limitNum > 0)
            {
                pushFreePool(del);
            }
            else
            {
                Object.Destroy(node);
            }
        }
Beispiel #2
0
        private void pushFreePool(LListNode node)
        {
            if (!freeDic.ContainsKey(node.tpl_id))
            {
                freeDic.Add(node.tpl_id, new List <LListNode>());
            }

            freeDic[node.tpl_id].Add(node);
            node.obj.SetActive(false);
        }
Beispiel #3
0
        private LListNode popFreePool(int id)
        {
            if (!freeDic.ContainsKey(id))
            {
                freeDic.Add(id, new List <LListNode>());
            }
            LListNode node = null;

            if (freeDic[id].Count > 0)
            {
                node = freeDic[id][0];
                freeDic[id].RemoveAt(0);
                node.obj.SetActive(true);
            }
            return(node);
        }
Beispiel #4
0
 public void removeNodeAtIndex(int idx)
 {
     if (nodeList.Count == 0)
     {
         return;
     }
     if (limitNum > 0)
     {
         LListNode node = nodeList[idx];
         pushFreePool(node);
     }
     else
     {
         Object.Destroy(nodeList[idx].obj);
     }
     nodeList.RemoveAt(idx);
 }
Beispiel #5
0
        public GameObject dequeueItem(int id)
        {
            GameObject ret = null;

            if (limitNum > 0)
            {
                LListNode node = popFreePool(id);
                if (node != null)
                {
                    ret = node.obj;
                }
            }

            if (ret == null)
            {
                ret = Instantiate(transform.Find("container/cell_tpl" + id).gameObject);
                ret.SetActive(true);
            }
            return(ret);
        }