Exemplo n.º 1
0
    public void GetNew(string key, Action <GameObject> action)     //  , uint num = defaultNum)
    {
        GameObject obj = null;

        if (!dic.ContainsKey(key))
        {
            PoolBase pool = new PoolBase(key, defaultNum);
            dic.Add(key, pool);
            obj = pool.Get();
        }
        else
        {
            obj = dic [key].Get();
        }
        if (obj == null)
        {
            AEResources.LoadSingle(key, (obj1) => {
                obj           = obj1 as GameObject;
                GameObject go = GameObject.Instantiate(obj);
                action(go);
            });
        }
        else
        {
            action(obj);
        }
    }
Exemplo n.º 2
0
 public void Create(PoolBase _pool, int _index)
 {
     pool     = _pool;
     index    = _index;
     isActive = true;
     Start();
 }
Exemplo n.º 3
0
    //清空缓存池
    public void clearObjectPool(string poolName)
    {
        PoolBase pool = getPoolByPoolName(poolName);

        pool.CleanAll();
        poolsDict.Remove(poolName);
    }
Exemplo n.º 4
0
    //回收缓存池节点
    public void recycleObject(GameObject obj)
    {
        string   name = obj.name;
        PoolBase pool = getPoolByPoolName(name);

        pool.Despawn(obj);
    }
Exemplo n.º 5
0
    public void Remove(string name)
    {
        if (!_pooldic.ContainsKey(name))
        {
            Debug.LogError("[POOL]:" + name + " is not exist");
            return;
        }

        PoolBase pool = _pooldic[name];

        pool.Clear();
        _pooldic.Remove(name);
    }
Exemplo n.º 6
0
    public PoolBase Create(string name, GameObject prefab, int initnum)
    {
        if (_pooldic.ContainsKey(name))
        {
            Debug.LogError("[POOL]:" + name + " is exist");
            return(_pooldic[name]);
        }

        GameObject obj  = new GameObject();
        PoolBase   pool = obj.AddComponent <PoolBase>();

        pool.Init(name, _trans, prefab, initnum);
        _pooldic.Add(name, pool);
        return(pool);
    }
    public override void Setup(params MonoBehaviour[] args)
    {
        base.Setup(args);

        PoolBase projectilesPool = null;

        foreach (MonoBehaviour arg in args)
        {
            if (projectilesPool == null && arg is PoolBase)
            {
                projectilesPool = (PoolBase)arg;
            }
        }

        foreach (WeaponBase weapon in weapons)
        {
            var rangeWeapon = (WeaponRange)weapon;
            rangeWeapon.Setup(projectilesPool);
        }
    }
Exemplo n.º 8
0
 /// Used from Pool declaration
 public void Initialize(PoolBase parentPool)
 {
     ParentPool = parentPool;
     SearchInterfaces();
 }
Exemplo n.º 9
0
 void IClientPoolable.OnInstanceCreated(PoolBase pool)
 {
     _pool = pool;
 }
Exemplo n.º 10
0
 protected virtual void OnInsoectorInfoGUI(PoolBase pool)
 {
     EditorGUILayout.LabelField($"Auto Expand:{ pool.AutoExpand}");
 }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="pool"></param>
 void IClientPoolable.OnInstanceCreated(PoolBase pool)
 {
     _pool = pool;
     _go   = gameObject;
 }
Exemplo n.º 12
0
 public virtual void Reset()
 {
     pool     = null;
     index    = -1;
     isActive = false;
 }
Exemplo n.º 13
0
 void InitPool()
 {
     mCheckPool = new PoolBase <Check>(m_CheckSample, m_CheckPool);
     mChessPool = new PoolBase <Chess>(m_ChessSample, m_ChessPool);
 }
Exemplo n.º 14
0
 public void Remove(PoolBase pool)
 {
     Remove(pool.Name);
 }
Exemplo n.º 15
0
    //获得缓存池节点
    public GameObject spawnObject(string poolName)
    {
        PoolBase pool = getPoolByPoolName(poolName);

        return(pool.Spawn());
    }