示例#1
0
 public void Despawn(Production production, bool isDestroy)
 {
     ActivatedSet.Remove(production);
     if (isDestroy)
     {
         GameObject.Destroy(production.Obj);
     }
     else
     {
         production.Obj.SetActive(false);
         RecycledSet.Add(production);
     }
 }
示例#2
0
        private Production CreateNewInstance(Transform parent, float lifeTime)
        {
            GameObject obj        = GameObject.Instantiate(prefab, parent);
            Production production = new Production(this)
            {
                Obj      = obj,
                BornTime = GameMain.Instance.GameTime,
                LifeTime = lifeTime,
                Index    = CurIndex++
            };

            obj.SetActive(true);
            ActivatedSet.Add(production);
            return(production);
        }
示例#3
0
        private Production Reuse(float lifeTime)
        {
            Production production = RecycledSet.Min;

            //必须先执行移除再赋值,因为移除的时候会对比Hash值,先赋值的话Hash会变
            RecycledSet.Remove(production);

            production.BornTime = GameMain.Instance.GameTime;
            production.LifeTime = lifeTime;

            production.Obj.SetActive(true);
            ActivatedSet.Add(production);

            return(production);
        }