Пример #1
0
    public static GenericPool CreateNewPoolWithPrefab(PoolableObject _poolableObjectPrefab, Transform _parent, string _poolName = "Pool", string _poolObjName = "PoolObj", int _maxPoolSize = NoSizeLimit)
    {
        GenericPool pool = CreateNewPool(_parent, _poolName, _maxPoolSize);

        pool.SetPoolableObject(_poolableObjectPrefab, _poolObjName);
        return(pool);
    }
Пример #2
0
    public static GenericPool CreateNewPool <T>(Transform _parent, string _poolName = "Pool", string _poolObjName = "PoolObj", int _maxPoolSize = NoSizeLimit) where T : PoolableObject
    {
        GenericPool pool    = CreateNewPool(_parent, _poolName, _maxPoolSize);
        T           poolObj = GameObjectUtil.CreateInstance <T>(pool.transform, _poolObjName);

        pool.SetPoolableObject(poolObj, _poolObjName);
        return(pool);
    }
Пример #3
0
    private void InitBulletPool()
    {
        if (bulletPool == null)
        {
            bulletPool = GenericPool.CreateNewPool(this.transform, "BulletPool", 100);
        }

        Bullet bullet = CreateBulletPrefab(this.bulletType);

        bulletPool.SetPoolableObject(bullet, "Bullet", true);
        Destroy(bullet.gameObject);
    }
Пример #4
0
    private void SetBulletPrefab(BulletType _bulletType)
    {
        switch (_bulletType)
        {
        case BulletType.Default:
        case BulletType.WideA:
        case BulletType.WideB:
            bulletPool.SetPoolableObject(defaultBulletPrefab, "Bullet");
            Debug.Log("Set Def Bullet");
            break;

        case BulletType.Grendate:
            bulletPool.SetPoolableObject(grenadeBulletPrefab, "GrenadeBullet");
            Debug.Log("Set Grenade Bullet");
            break;

        case BulletType.Rapid:
            bulletPool.SetPoolableObject(rapidBulletPrefab, "RapidBullet");
            Debug.Log("Set Rapid Bullet");
            break;
        }
    }