コード例 #1
0
    public CharObj BorrowObj(BattleObjManager.E_BATTLE_OBJECT_TYPE type)
    {
        CharObj            obj  = null;
        QObjPool <CharObj> pool = null;

        m_pools.TryGetValue(type, out pool);
        if (pool == null)
        {
            InitBattleObjPool(
                CharObjPoolConfigerMediator.Instance.GetConfiger(type).Paths,
                type,
                CharObjPoolConfigerMediator.Instance.GetConfiger(type).Count);

            m_pools.TryGetValue(type, out pool);
            //return obj;
        }

        if (pool == null)
        {
            return(obj);
        }

        obj = pool.BorrowObj();

        return(obj);
    }
コード例 #2
0
    public GameObject BorrowObj(string path)
    {
        bool                  retCode = false;
        GameObject            obj     = null;
        QObjPool <GameObject> pool    = null;

        m_pools.TryGetValue(path, out pool);
        if (pool == null)
        {
            //没有对应的pool就创建一个
            QObjPoolForParticle creator =
                new QObjPoolForParticle(path, 32);
            pool    = new QObjPool <GameObject>();
            retCode = pool.Init(creator, null);
            if (!retCode)
            {
                Debug.LogError("QObjPool 初始失败 " + path);
                return(obj);
            }
            m_pools.Add(path, pool);
        }

        obj = pool.BorrowObj();

        return(obj);
    }
コード例 #3
0
    private void InitBattleObjPool(string[] paths, BattleObjManager.E_BATTLE_OBJECT_TYPE type, int count)
    {
        QObjCreatorFactory <CharObj> creatorFactory = new CharObjCreatorFactory(
            paths, type, count);

        QObjPool <CharObj> pool = new QObjPool <CharObj>();

        pool.Init(null, creatorFactory);

        m_pools.Add(type, pool);
    }
コード例 #4
0
    public void ReturnObj(GameObject obj, string path)
    {
        QObjPool <GameObject> pool = null;

        m_pools.TryGetValue(path, out pool);
        if (pool == null)
        {
            Debug.LogWarning(path + " 对象不在对象池管理范围内");
            return;
        }

        pool.ReturnObj(obj);
    }
コード例 #5
0
    public void ReturnObj(CharObj obj)
    {
        QObjPool <CharObj> pool = null;

        m_pools.TryGetValue(obj.Type, out pool);
        if (pool == null)
        {
            return;
        }
        CharObjCreator creator = pool.BAK_CREATOR as CharObjCreator;

        creator.HideObject(obj);
        pool.ReturnObj(obj);
    }