Пример #1
0
    //从对象池中取出GameObject接口
    public GameObject GetFromPool(string spawnName, string spawnPoolName)
    {
        m_spawnPool = PoolManager.Pools[spawnPoolName];
        Transform prefabPoolIns = m_spawnPool.Spawn(spawnName);

        return(prefabPoolIns.gameObject);
    }
Пример #2
0
 void Start()
 {
     if (spawnPool == null)
     {
         spawnPool = PoolManager.Pools["Test"];
     }
 }
Пример #3
0
        /// <summary>
        /// Start is called on the frame when a script is enabled just before
        /// any of the Update methods is called the first time.
        /// </summary>
        public void Start()
        {
            truckLibrary = Resources.Load("Truck Library") as TruckLibrary;
            truckPool    = PoolManager.Pools["Trucks"];

            spawnMessage = MessageBroker.Default.Receive <SpawnTruckMessage>().Subscribe(message =>
            {
                if (truckLibrary.library.ContainsKey(message.Type))
                {
                    Transform spawned = Spawn(truckLibrary.library[message.Type]);
                    message.Truck.Invoke(spawned.GetComponent <Transform>());
                }
                else
                {
                    throw new KeyNotFoundException("The requested key " + message.Type + " could not be found.");
                }
            });

            despawnMessage = MessageBroker.Default.Receive <DespawnTruckMessage>().Subscribe(message =>
            {
                if (message.Truck == null)
                {
                    DespawnAll();
                }
                else
                {
                    Despawn(message.Truck);
                }
            });
        }
Пример #4
0
    public void Init()
    {
        //return;
        var o = GameObject.Find("SpawnRoot") ?? new GameObject("SpawnRoot");

        GameObject.DontDestroyOnLoad(o);
        spawnRoot = o.transform;
        SpawnPoolDic.Clear();

        var sp = new SpawnPool
        {
            parentRoot = spawnRoot,
            prefabName = "prefabs/models/dj001_kirigaya_kazuto",
            spawnCount = 2
        };

        sp.Init();
        SpawnPoolDic.Add(sp.prefabName, sp);
        var sp1 = new SpawnPool
        {
            parentRoot = spawnRoot,
            prefabName = "prefabs/models/dj002_asuna",
            spawnCount = 2
        };

        sp1.Init();
        SpawnPoolDic.Add(sp1.prefabName, sp1);
    }
Пример #5
0
    //创建enemyPool
    void GenerateEnemyPool()
    {
        enemySpawnPool = PoolManager.Pools.Create(enemyPool);
        enemySpawnPool.group.parent      = transform;
        enemySpawnPool.dontDestroyOnLoad = true;

        if (SceneManager.GetActiveScene().name == Game.Instance.StaticData.Level3)
        {
            shellEnemyInfo = Game.Instance.StaticData.shellEnemyList;
            foreach (EnemyInfo info in shellEnemyInfo)
            {
                PrefabPool prefabPool = new PrefabPool(info.Prefab.transform);
                PoolSetting(prefabPool, 4);
                enemySpawnPool.CreatePrefabPool(prefabPool);
            }
        }
        else
        {
            enemyInfo = Game.Instance.StaticData.enemyList;
            foreach (EnemyInfo info in enemyInfo)
            {
                PrefabPool prefabPool = new PrefabPool(info.Prefab.transform);
                PoolSetting(prefabPool, 4);
                enemySpawnPool.CreatePrefabPool(prefabPool);
            }

            bossEnemyInfo = Game.Instance.StaticData.bossEnemyList;
            foreach (EnemyInfo info in bossEnemyInfo)
            {
                PrefabPool prefabPool = new PrefabPool(info.Prefab.transform);
                PoolSetting(prefabPool, 12);
                enemySpawnPool.CreatePrefabPool(prefabPool);
            }
        }
    }
Пример #6
0
    /// <summary>
    /// Run by a SpawnPool when it is destroyed
    /// </summary>
    internal void SelfDestruct()
    {
        // Probably overkill but no harm done
        this.prefab    = null;
        this.prefabGO  = null;
        this.spawnPool = null;

        // Go through both lists and destroy everything
        foreach (Transform inst in this._despawned)
        {
            if (inst != null)
            {
                UnityEngine.Object.Destroy(inst.gameObject);
            }
        }

        foreach (Transform inst in _spawned)
        {
            if (inst != null)
            {
                UnityEngine.Object.Destroy(inst.gameObject);
            }
        }

        this._spawned.Clear();
        this._despawned.Clear();
    }
Пример #7
0
    public void Destroy()
    {
        // Go through both lists and destroy everything
        for (int i = 0; i < despawned.size; ++i)
        {
            if (despawned[i] != null)
            {
                GameObject.Destroy(despawned[i]);
                despawned[i] = null;
            }
        }

        for (int i = 0; i < spawned.size; ++i)
        {
            if (spawned[i] != null)
            {
                GameObject.Destroy(spawned[i]);
                spawned[i] = null;
            }
        }

        spawned.Release();
        despawned.Release();

        this.prefab    = null;
        this.spawnPool = null;

        BundleLoaderManager.Instance.UnloadAssetBundle(nBundleId, false);
    }
Пример #8
0
    Transform GetBubbleTran(int ID)
    {
        if (pool == null)
        {
            pool = PoolManager.Pools["BubblePool"];
        }

        int type = IDTool.GetType(ID);

        if (type == 1)
        {
            return(pool.Spawn("BubbleUnit"));
        }
        if (type == 2)
        {
            return(pool.Spawn("SpecialBubbleUnit"));
        }
        if (type == 3)
        {
            return(pool.Spawn("FreezeBubbleUnit"));
        }
        if (type == 4)
        {
            return(pool.Spawn("StoneBubbleUnit"));
        }

        return(null);
    }
Пример #9
0
 public virtual void CreateBasePool()
 {
     Common  = PoolManager.Pools.Create("Common");
     Unit    = PoolManager.Pools.Create("Units");
     Perform = PoolManager.Pools.Create("Perform");
     HUD     = PoolManager.Pools.Create("HUD");
 }
Пример #10
0
 void Start()
 {
     //方法1 直接在场景物体上挂SpawnPool
     spawnPool = PoolManager.Pools["Shapes"];
     //方法2 直接代码新建池
     refabPool = new PrefabPool(Resources.Load <Transform>("momo"));
 }
Пример #11
0
    public void OnSpawn(SpawnPool pMyPool)
    {
        m_myPool = pMyPool;

        if(m_autoDespawn)
            StartCoroutine(DespawnInCoroutine(m_despawnDelay));
    }
Пример #12
0
    /// <summary>
    /// Setup the PrefabPool. Change to test different settings.
    /// </summary>
    private void Start()
    {
        this.pool = PoolManager.Pools.Create(this.poolName);

        // Make the pool's group a child of this transform for demo purposes
        this.pool.group.parent = this.transform;

        // Set the pool group's local position for demo purposes
        this.pool.group.localPosition = new Vector3(1.5f, 0, 0);
        this.pool.group.localRotation = Quaternion.identity;

        // Create a prefab pool, set culling options but don't need to pre-load any
        //  If no options are needed, this can be skipped entirely. Just use spawn()
        //  and a PrefabPool will be created automatically with defaults
        PrefabPool prefabPool = new PrefabPool(testPrefab);
        prefabPool.preloadAmount = 5;      // This is the default so may be omitted
        prefabPool.cullDespawned = true;
        prefabPool.cullAbove = 10;
        prefabPool.cullDelay = 1;
        prefabPool.limitInstances = true;
        prefabPool.limitAmount = 5;
        prefabPool.limitFIFO = true;

        this.pool.CreatePrefabPool(prefabPool);

        this.StartCoroutine(Spawner());

        // NEW EXAMPLE... Preabs[] dict
        // In the Shapes pool, we know we have a prefab "Cube". This example uses
        //    just this name to get a reference to the prefab and spawn an instance
        Transform cubePrefab   = PoolManager.Pools["Shapes"].prefabs["Cube"];
        Transform cubeinstance = PoolManager.Pools["Shapes"].Spawn(cubePrefab);
        cubeinstance.name = "Cube (Spawned By CreationExample.cs)"; // So we can see it.
    }
Пример #13
0
    public bool Load()
    {
        if (_prefab != null)
        {
            return(true);
        }
        string poolMangerName = "InGame2dRes";

        //string poolMangerName = "Common2dRes";
        if (!PoolManager.Pools.ContainsKey(poolMangerName))
        {
            Debug.LogError("No InGame2dRes Prefab Loaded!!!");
            return(false);
        }
        _spawnPool = PoolManager.Pools[poolMangerName];
        if (!_spawnPool.prefabs.ContainsKey("Canvas_HuPrompt"))
        {
            Debug.LogError("No Canvas_HuPrompt Prefab Loaded!!!");
            return(false);
        }
        _prefab = _spawnPool.Spawn("Canvas_HuPrompt");

        loadUI();
        if (_prefab != null && _prefab.gameObject.activeSelf == true)
        {
            _prefab.gameObject.SetActive(false);
        }

        return(true);
    }
Пример #14
0
        internal void Init()
        {
            if (m_initFlag == false)
            {
                m_initFlag = true;
                GameObject obj  = new GameObject("PoolManager");
                SpawnPool  pool = obj.AddComponent <SpawnPool>();
                pool.poolName          = AppConst.PoolName;
                pool.dontDestroyOnLoad = true;
                PoolManager.Pools.Add(pool);

                GameObject lua  = new GameObject("GameManager");
                Main       main = lua.AddComponent <Main>();
                AppConst.GameManager = lua.transform;

                GameObject     payObj         = new GameObject("PaymentManager");
                PaymentManager paymentManager = payObj.AddComponent <PaymentManager>();
            }
            else
            {
                LuaManager mgr = AppFacade.Instance.GetManager <LuaManager>(ManagerName.Lua);
                mgr.DoFile("Main.lua");
                mgr.CallFunction("EnterMainScene");
            }
        }
 /// <summary>
 /// Initialize all private properties
 /// </summary>
 private void Awake()
 {
     _pool            = GameObject.Find("GameManager").GetComponent<GameManager>().BulletPool;
     _xform           = GameObject.Find("EnemySpawnPoint").transform;
     _playerXform     = GameObject.Find("Player").transform;
     _particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleEffectsManager>();
 }
Пример #16
0
 private void  Start()
 {
     // Create an inventory, and store the first weapon in there
     _weaponInventory = new bool[ System.Enum.GetValues(typeof (WeaponType)).Length];
     _player          = gameObject.GetComponent<Player>();
     _pool            = PoolManager.Pools[_BULLET_POOL_STRING];
 }
Пример #17
0
        /// <summary>
        /// 加载GameObect,并且缓存
        /// </summary>
        /// <param name="assetPath">资源路径</param>
        /// <param name="cachePool">缓存池</param>
        /// <param name="isCache">是否为缓存</param>
        /// <returns></returns>
        private Object Inner_LoadGameObjectSync(string assetPath, SpawnPool cachePool, bool isCache = false)
        {
            //        LogSystem.Debug("Inner_LoadObjectSync: " + assetPath);
            Object        uObj;
            PrefabPathMap ppm = CheckPrefabBundle(assetPath);

            if (ppm.IsHasBundle)
            {
                AssetBundle _Bundle = AssetBundleManager.LoadAssetBundleFromFile(ppm.BundleName);
                uObj = _Bundle.LoadAsset(ppm.AssetPath, typeof(GameObject));

                if (null != uObj)
                {
                    AddBundleToUnloadList(ppm.BundleName, isCache);
                }
            }
            else
            {
#if UNITY_EDITOR
                uObj = AssetDatabase.LoadAssetAtPath(ppm.AssetPath, typeof(GameObject));
#else
                uObj = Resources.Load(ppm.ResourcePath, typeof(GameObject));
#endif
            }
            if (null != uObj)
            {
                CacheGameObject(uObj, assetPath, cachePool);
                if (!isCache)
                {
                    uObj = cachePool.Spawn(assetPath).gameObject;
                }
            }
            return(uObj);
        }
Пример #18
0
    /// <summary>
    /// Spawn a particle instance at start, and respawn it to show particle reactivation
    /// </summary>
    private IEnumerator ParticleSpawner()
    {
        SpawnPool particlesPool = PoolManager.Pools[this.particlesPoolName];

        ParticleSystem prefab      = this.particleSystemPrefab;
        Vector3        prefabXform = this.particleSystemPrefab.transform.position;
        Quaternion     prefabRot   = this.particleSystemPrefab.transform.rotation;

        // Spawn an emitter that will auto-despawn when all particles die
        //  testEmitterPrefab is already a ParticleEmitter, so just pass it.
        // Note the return type is also a ParticleEmitter
        ParticleSystem emitter = particlesPool.Spawn(prefab, prefabXform, prefabRot);

        while (emitter.IsAlive(true))
        {
            // Wait for a little while to be sure we can see it despawn
            yield return(new WaitForSeconds(3));
        }

        ParticleSystem inst = particlesPool.Spawn(prefab, prefabXform, prefabRot);

        // Early despawn (in 2 seconds) and re-spawn
        particlesPool.Despawn(inst.transform, 2);

        yield return(new WaitForSeconds(2));

        particlesPool.Spawn(prefab, prefabXform, prefabRot);
    }
Пример #19
0
    private void LoadEffectToPool()
    {
        SpawnPool pool = EffectMgr.GetPool();

        pool.transform.parent = transform;
        if (mEffectDuration == null)
        {
            mEffectDuration = new Dictionary <eEffectType, float>();
        }

        string strPath = "";

        for (int i = 0; i < (int)eEffectType.Max; ++i)
        {
            strPath = GetEnumDes((eEffectType)i);
            UnityEngine.Object obj = Resources.Load(strPath);
            if (obj != null)
            {
                GameObject go = obj as GameObject;
                InsertPool(pool, go);
                float            dLastTime = 0f;
                ParticleSystem[] psArray   = go.GetComponentsInChildren <ParticleSystem>();
                for (int j = 0; j < psArray.Length; j++)
                {
                    dLastTime = Mathf.Max(dLastTime, psArray[j].startLifetime);
                }
                mEffectDuration.Add((eEffectType)i, dLastTime);
            }
            else
            {
                Debug.LogError(" 路径没有特效文件 path:" + strPath);
            }
        }
    }
Пример #20
0
 /// <summary>
 /// 释放对象池
 /// </summary>
 public void Release()
 {
     PoolManager.Pools.Destroy("Dogface");
     _dogFacePool = null;
     _prefabDic   = null;
     _prefabList  = null;
 }
Пример #21
0
    protected override void OnStart()
    {
        base.OnStart();

        AssetBundleMgr.Instance.LoadOrDownload("Download/Prefab/UIPrefab/UIOther/UITipItem.assetbundle", "UITipItem", (GameObject obj) =>
        {
            m_TipItem = obj.transform;

            m_TipPool = PoolManager.Pools.Create("TipPool");
            m_TipPool.group.parent        = transform;
            m_TipPool.group.localPosition = Vector3.zero;

            PrefabPool prefabPool    = new PrefabPool(m_TipItem);
            prefabPool.preloadAmount = 5;     //预加载数量

            prefabPool.cullDespawned  = true; //是否开启缓存池自动清理模式
            prefabPool.cullAbove      = 10;   // 缓存池自动清理 但是始终保留几个对象不清理
            prefabPool.cullDelay      = 2;    //多长时间清理一次 单位是秒
            prefabPool.cullMaxPerPass = 2;    //每次清理几个

            m_TipPool.CreatePrefabPool(prefabPool);
        });

        //m_TipItem = ResourcesMgr.Instance.Load(ResourcesMgr.ResourceType.UIOther, "UITipItem", cache: true, returnClone: false).transform;
    }
Пример #22
0
    private void EndFire()
    {
        if (this.Parent)
        {
            this.Parent.ExtinguishPoint(this);
        }
        if (BoltNetwork.isRunning && base.entity && base.entity.isAttached && base.entity.isOwner)
        {
            BoltNetwork.Detach(base.gameObject);
        }
        SpawnPool spawnPool = PoolManager.Pools["Particles"];

        if (spawnPool.IsSpawned(base.transform))
        {
            spawnPool.Despawn(base.transform);
        }
        else if (base.transform.parent)
        {
            base.gameObject.SetActive(false);
        }
        else
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
    }
Пример #23
0
    public Transform SpawnerEntity(string avatarName, Vector3 v, ResourceType rType, Transform parent)
    {
        string    poolName = Util.GetPoolName(rType);
        SpawnPool pool     = CreatePool(poolName);

        if (null == pool)
        {
            Debuger.LogError("init pool failed:" + poolName);
            return(null);
        }

        if (!pool.prefabPools.ContainsKey(avatarName))
        {
            GameObject prefab = ResourcesMgr.Instance.LoadResource <GameObject>(rType, avatarName);
            if (null == prefab)
            {
                Debuger.LogError(avatarName + " is NULL!");
                return(null);
            }
            CreatePoolPrefab(pool, avatarName, prefab.transform);
        }
        if (pool.prefabPools.ContainsKey(avatarName))
        {
            Transform tran = SpawnerEntity(pool, pool.prefabPools[avatarName].prefab, parent, v);
            return(tran);
        }
        return(null);
    }
Пример #24
0
    void Awake()
    {
        Instance = this;
        _mapPool = gameObject.AddComponent<SpawnPool>();

        Camera.main.transparencySortMode = TransparencySortMode.Orthographic;
    }
Пример #25
0
 public static void Despawn(SpawnPool pool, GameObject unit)
 {
     if (unit.activeSelf)
     {
         pool.Despawn(unit.transform);
     }
 }
Пример #26
0
    public SpawnPool GetSpawnPool()
    {
        if(pool == null)
            pool = PoolManager.Instance.GetPool(poolName);

        return pool;
    }
Пример #27
0
 public void AddEffect()
 {
     if (_view._btnWin.transform.childCount > 0)
     {
         return;
     }
     if (PoolManager.Pools.ContainsKey("InGameEffectRes"))
     {
         SpawnPool pool = PoolManager.Pools["InGameEffectRes"];
         if (pool.prefabs.ContainsKey("FX_PengGang"))
         {
             Transform effect = pool.Spawn("FX_PengGang");
             Transform kong   = effect.Find("Panel/FX_Btn_kong");
             Transform win    = effect.Find("Panel/FX_Btn_win");
             Transform pong   = effect.Find("Panel/FX_Btn_pong");
             if (kong && win && pong)
             {
                 win.parent         = _view._btnWin.transform;
                 pong.parent        = _view._btnPong.transform;
                 kong.parent        = _view._btnKong.transform;
                 win.localPosition  = Vector3.zero;
                 pong.localPosition = Vector3.zero;
                 kong.localPosition = Vector3.zero;
                 win.gameObject.SetActive(true);
                 pong.gameObject.SetActive(true);
                 kong.gameObject.SetActive(true);
                 pool.Despawn(effect);
             }
         }
     }
     else
     {
         Debug.LogError("No InGameEffectRes Prefab Loaded!!!");
     }
 }
Пример #28
0
 void Update()
 {
     if (CreepQueue != null)
     {
         if (CreepQueue.Count > 0 && SpawnPool.Count > 0)
         {
             //Counts down to spawn
             SpawnTimer -= Time.deltaTime;
             if (SpawnTimer <= 0)
             {
                 //Gets next creep in queue
                 BaseCreep creep = CreepQueue.Dequeue();
                 //Gets next SpawnPool object
                 GameObject poolObject = SpawnPool.Dequeue();
                 //Sets object to active
                 poolObject.SetActive(true);
                 //Gets component for creep handling and sets correct creep
                 poolObject.GetComponent<CreepMovementTesting>().CurrentCreep = creep;
                 Debug.Log("Spawning Creep");
                 //Reset timer
                 SpawnTimer = SpawnDelay;
                 SpawnCounter++;
                 Debug.Log(SpawnCounter);
             }
         }
     }
 }
Пример #29
0
        public void KillPlayer(GameObject unit, PlayerAnimations animation, bool play_death_effect)
        {
            if (!player_death)
            {
                player_death     = true;
                player_unit      = unit;
                player_movements = player_unit.GetComponent <PlayerMovements>();
                player_movements.LockMovements(true);
                animator.SetAnimation(animation);
                player_movements.HealthBarVisibility(false);
                player_movements.SetPlayerHP(0);
                player_movements.ActivateSpeedBoost(false);
                if (play_death_effect)
                {
                    SpawnPool general_pool = PoolManager.Pools[CurrentLevel.GetGeneralPoolName()];
                    general_pool.Spawn(death_effect, unit.transform.position, new Quaternion(0, 0, 0, 0));
                }

                if (animation == PlayerAnimations.Death)
                {
                    player_movements.StartCoroutine(DeathAnimation());
                }
                else
                {
                    player_movements.StartCoroutine(ResurrectPlayer(RESPAWN_TIMER));
                }
            }
        }
Пример #30
0
    IEnumerator GotoAddEnemyAtPoint(Vector3 pos, EnemyType type, int bDrop = 0)
    {
        //		type = EnemyType.pangxie;
        float r = Random.Range(0f, 2f);

        yield return(new WaitForSeconds(r));

        //		GameObject effect0 = (GameObject)Instantiate(BurnMonsterEffect0);
        SpawnPool spawnPool = PoolManager.Pools["Items"];
        Transform effect0   = spawnPool.Spawn(BurnMonsterEffect0.name);

        effect0.position = pos + new Vector3(0, 0.5f, 0);
        yield return(new WaitForSeconds(2f));

        //		GameObject effect1 = (GameObject)Instantiate(BurnMonsterEffect1);
        //		effect1.transform.position = pos;
        //		yield return new WaitForSeconds(0.5f);
        //		GameObject effect2 = (GameObject)Instantiate(BurnMonsterEffect2);
        Transform effect2 = spawnPool.Spawn(BurnMonsterEffect2.name);

        effect2.transform.position = pos;
        yield return(new WaitForSeconds(0.5f));

        AddEnemyAtPoint(pos, type, bDrop);
        hasBorned = true;
    }
Пример #31
0
        /// <summary>
        /// 缓存池预加载一个 Prefab
        /// </summary>
        /// <param name="pool">缓存池</param>
        /// <param name="preloadCount">预加载的实例个数</param>
        /// <param name="limitCount">缓存池实例限制</param>
        public void PreloadPrefab(SpawnPool pool, GameObject prefab, int preloadCount, int limitCount)
        {
            if (pool.GetPrefabPool(prefab.transform) != null)
            {
                Debug.LogWarning("Create A Exist Prefab Pool");
                return;
            }

            PrefabPool prefabPool = new PrefabPool(prefab.transform);

            if (limitCount > 0)
            {
                preloadCount              = Mathf.Min(preloadCount, limitCount);
                prefabPool.limitAmount    = limitCount;
                prefabPool.preloadAmount  = preloadCount;
                prefabPool.limitInstances = true;
            }
            else
            {
                prefabPool.preloadAmount  = preloadCount;
                prefabPool.limitInstances = false;
            }

            pool.CreatePrefabPool(prefabPool);
        }
Пример #32
0
    public Common2dRes()
    {
        _commonPool = PoolManager.Pools.Create("Common2dRes");
        _commonPool.dontDestroyOnLoad = true;

        #region ui canvas
        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_Debug", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_ImgSprite", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "GroupCard", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_Tips", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_commonPool, obj);
        });

        #endregion
    }
Пример #33
0
    static void CreatePrefabPool(SpawnPool spawnPool, Transform prefab, int num)
    {
        if (spawnPool._perPrefabPoolOptions.Any(c => c.prefab.name == prefab.name))
        {
            return;
        }
        PrefabPool refabPool = new PrefabPool(prefab);

        refabPool.preloadTime   = false;
        refabPool.preloadFrames = 2;
        refabPool.preloadDelay  = 1.0f;
        //默认初始化两个Prefab
        refabPool.preloadAmount = num;
        //开启限制
        refabPool.limitInstances = true;
        //关闭无限取Prefab
        refabPool.limitFIFO = true;
        //限制池子里最大的Prefab数量
        refabPool.limitAmount = num * 10;
        //开启自动清理池子
        refabPool.cullDespawned = false;
        //最终保留
        refabPool.cullAbove = 0;
        //多久清理一次
        refabPool.cullDelay = 5;
        //每次清理几个
        refabPool.cullMaxPerPass = num;
        spawnPool._perPrefabPoolOptions.Add(refabPool);
        spawnPool.CreatePrefabPool(refabPool);
    }
Пример #34
0
    public InGame2dRes()
    {
        _spawnPool = PoolManager.Pools.Create("InGame2dRes");
        _spawnPool.dontDestroyOnLoad = true;

        #region ui canvas
        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_Combo", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_LackSetting", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_GameUIInfo", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_HuPrompt", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });

        GameClient.Instance.AssetLoader.LoadAsync(_assetBundleName, "Canvas_GameResult", delegate(UnityEngine.Object obj)
        {
            PoolUtil.SingletonPrefabPool(_spawnPool, obj);
        });
        #endregion
    }
Пример #35
0
    void Start()
    {
        sr              = GetComponent <SpriteRenderer>();
        skillCD         = GameObject.Find("SkillButton").GetComponent <SkillCD>();
        enemySpawnPool  = PoolManager.Pools["Enemy"];
        effectSpawnPool = PoolManager.Pools["Effect"];

        rooms = GameObject.FindGameObjectsWithTag("Room");

        foreach (GameObject r in rooms)
        {
            if (Vector2.Distance(new Vector2(transform.position.x, transform.position.y), new Vector2(r.transform.position.x, r.transform.position.y)) < 170)
            {
                room = r.GetComponent <RoomInstance>();
            }
        }

        if (SceneManager.GetActiveScene().name == "5.Level3")
        {
            for (int i = 0; i < 20; i++)
            {
                itemLight[i] = GameObject.Find("Lights").transform.GetChild(i).transform.GetChild(0).gameObject;
            }
            items = Game.Instance.StaticData.shineItemList;
        }
        else
        {
            items = Game.Instance.StaticData.itemList;
        }
    }
Пример #36
0
 private void Start()
 {
     _xform           = transform; 
     _startingColor   = renderer.material.color; 
     _pool            = PoolManager.Pools[_BULLET_POOL_STRING];
     _particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleEffectsManager>();
     _spawnManager    = GameObject.Find("SpawnMananger").GetComponent<SpawnManager>();
 }
    private void Start()
    {
        this.pool = this.GetComponent<SpawnPool>();
        this.StartCoroutine(this.Spawner());

		if (this.musicPrefab != null)
			this.StartCoroutine(this.MusicSpawner());
    }
Пример #38
0
	public bool MakeSpawnPool()
	{
		if(effectsPool == null)
		{
			effectsPool = PoolManager.Pools.Create(myPhotonView.viewID.ToString());
			//Debug.Log(effectsPool.poolName);
		}
		return true;
	}
Пример #39
0
 private void OnDespawned(SpawnPool pool)
 {
     if (pool)
     {
         pool.DelayNextDisable = true;
     }
     this._alpha = 0.9374f;
     this._stipplingIn = false;
     base.enabled = true;
 }
Пример #40
0
    void Start ()
	{
	    _player          = GameObject.Find("Player").         GetComponent<Player>();
        _particleManager = GameObject.Find("ParticleManager").GetComponent<ParticleEffectsManager>();
	    _xForm           = transform;
        _pool            = GameObject.Find("GameManager").    GetComponent<GameManager>().BulletPool;
	    _weapons         = _player.                           GetComponent<Weapons>();
        CreatePath();
        pickupType = PickupType.BulletVel;
        SetPickupType();
	}
Пример #41
0
    void Awake()
    {
        xform                     = transform;    
        //TODO: Move this to a private serialized object                         
        _playerSpawnPoint         = GameObject.Find("PlayerSpawnPoint").transform; // set reference to Spawn Point Object
        xform.position            = _playerSpawnPoint.position;                    // Set player pos to spawnPoint pos
        _pool                     = _gm.BulletPool;
        _particleManager          = GameObject.Find("ParticleManager").GetComponent<ParticleEffectsManager>();
        weapons                   = GetComponent<Weapons>();

        GameEventManager.GameStart += GameStart;
    }
	private void OnDespawned(SpawnPool pool)
	{
		Debug.Log
		(
			string.Format
			(
				"OnSpawnedExample | OnDespawned unning for '{0}' in pool '{1}'.", 
				this.name,
				pool.poolName
			)
		);
	}
    private void GameStart()
    {
        if (droneXform == null)
        {
            Debug.Log("Please assign a drone prefab.");
            return;
        }

        _spawnPointXform = GameObject.Find("EnemySpawnPoint").transform;
        _playerXform     = GameObject.Find("Player").transform;
        _pool            = PoolManager.Pools[_nameOfPool];
        _isActive        = true;
    }
    /// <summary>
    /// Instantiates the values for all private properties
    /// </summary>
    private void SetProperties()
    {
        _xForm                    = transform;
        _pool                     = PoolManager.Pools[_BULLET_POOL_STRING];
        swarmBehavior             = GameObject.Find("SwarmBehaviorPrefab").GetComponent<SwarmBehavior>();

        // SWARM BEHAVIORS
        // Create a new swarm behavior if it is null
        if (swarmBehavior != null) return;
        var swarmObject           = new GameObject();
        swarmObject.AddComponent<SwarmBehavior>();
        swarmObject.AddComponent<ParticleEffectsManager>();
        swarmBehavior             = swarmObject.GetComponent<SwarmBehavior>();
    }
Пример #45
0
    /// <summary>
    /// Spawn a particle instance at start, and respawn it to test particle reactivation
    /// </summary>
    private IEnumerator ParticleSpawner()
    {
        this.particlesPool = PoolManager.Pools[this.particlesPoolName];

        ParticleSystem prefab = this.particleSystemPrefab;
        Vector3 prefabXform = this.particleSystemPrefab.transform.position;
        Quaternion prefabRot = this.particleSystemPrefab.transform.rotation;

        // Spawn an emitter that will auto-despawn when all particles die
        //  testEmitterPrefab is already a ParticleEmitter, so just pass it.
        // Note the return type is also a ParticleEmitter
        ParticleSystem emitter = this.particlesPool.Spawn(prefab, prefabXform, prefabRot);

        while (emitter.IsAlive(true))
        {
            // Wait for a little while to be sure we can see it despawn
            yield return new WaitForSeconds(3);
        }

        this.particlesPool.Spawn(prefab, prefabXform, prefabRot);
    }
 private void Start()
 {
     this.pool = this.GetComponent<SpawnPool>();
     this.StartCoroutine(this.Spawner());
 }
 /// <summary>
 /// Creates a reference to object pools in the game
 /// </summary>
 private void SetObjectPools()
 {
     BulletPool   = PoolManager.Pools[_BULLET_POOL_STRING];
     ParticlePool = PoolManager.Pools[_PARTICLE_POOL_STRING];
 }
Пример #48
0
		/// <summary>
		/// If using PoolManager this will provide the pool name for despawn.
		/// </summary>
		protected void OnSpawned(SpawnPool spawnPool)
		{
			this.poolName = spawnPool.poolName;
		}
Пример #49
0
    public void OnSpawn(SpawnPool pMyPool)
    {
        Reset();

        myPool = pMyPool;
    }
	public void RunMe(SpawnPool pool)
	{
		Debug.Log("Delegate ran for pool " + pool.poolName);
	}
Пример #51
0
	public Transform Spawn(string prefabName, Transform parent) {
		if (spawnPool == null) {
			spawnPool = PoolManager.Pools[poolName];
		}
		return spawnPool.Spawn(prefabName, parent);
	}
Пример #52
0
  public void Despawn(Transform prefab, float seconds) {
		if (spawnPool == null) {
			spawnPool = PoolManager.Pools[poolName];
		}
		spawnPool.Despawn(prefab, seconds, spawnPool.transform);
	}
Пример #53
0
 // Use this for initialization
 void Start()
 {
     shapesPool = PoolManager.Pools[this.poolName];
 }
Пример #54
0
    private void Start()
    {
        this.shapesPool = PoolManager.Pools[this.poolName];

        this.StartCoroutine(Spawner());
        this.StartCoroutine(ParticleSpawner());
    }
Пример #55
0
 public void Init()
 {
     ladderSpawnPool = PoolManager.Pools[ladders[0].PoolName];
 }
Пример #56
0
  public Transform Spawn(string prefabName, Vector3 pos, Quaternion rot, Transform parent) {
		if (spawnPool == null) {
			spawnPool = PoolManager.Pools[poolName];
		}
		return spawnPool.Spawn(prefabName, pos, rot, parent);
  }
Пример #57
0
 internal void SelfDestruct()
 {
     this.prefab = null;
     this.prefabGO = null;
     this.spawnPool = null;
     foreach (Transform current in this._despawned)
     {
         if (current != null)
         {
             UnityEngine.Object.DestroyImmediate(current.gameObject);
         }
     }
     foreach (Transform current2 in this._spawned)
     {
         if (current2 != null)
         {
             UnityEngine.Object.DestroyImmediate(current2.gameObject);
         }
     }
     this._spawned.Clear();
     this._despawned.Clear();
 }
	void Start () {
        _pool = GameObject.Find("GameManager").GetComponent<GameManager>().BulletPool;
	}
Пример #59
0
 public void OnSpawn(SpawnPool pMyPool)
 {
     //Debug.Log("OnSpawn, apenas");
     myPool = pMyPool;
 }