/// <summary> /// 为坦克准备缓冲池 /// </summary> void PrepareTank() { //Breed.Instance().Create("tank", _Prefab_Tank[GlobalManager.GetInstants()._PlayerEntity._Tank_Id - 1]); Breed.Instance().Create("tank", _Prefab_Tank[GlobalManager.GetInstants()._PlayerEntity._Tank_Id - 1]); this._Tank_Pool = Breed.Instance().Get("tank"); this._Tank_Pool.Preload(20); }
// creates a pool, must be named and the object to pool must be set public BreedPool Create(string name, GameObject obj) { BreedPool pool = new BreedPool(name, obj); pools.Add(pool); return(pool); }
// removes the pool by name public void Remove(string name) { for (int i = 0; i < pools.Count; i++) { BreedPool pool = pools[i] as BreedPool; if (pool.name == name) { // clear it first pool.Clear(); // remove it from the array pools.RemoveAt(i); } } }
/// <summary> /// 为子弹准备缓冲池 /// </summary> void PrepareBullet(GameObject bullet) { Breed.Instance().Create("bullet", bullet); this._BulletPool = Breed.Instance().Get("bullet"); this._BulletPool.Preload(10); }
/// <summary> /// 为炸弹准备缓冲池 /// </summary> void PrepareProp() { Breed.Instance().Create("prop", _Prefab_Props[GlobalManager.GetInstants()._PlayerEntity._Bombing_Weapons - 1]); this._Prop_Pool = Breed.Instance().Get("prop"); this._Prop_Pool.Preload(5); }
void OnSpawn(BreedPool pmp) { // we will use this when unspawning, thats why it was passed - so we don't have to type PoolManager.GetPool this._TankPool = pmp; }