void SpawnBall() { PoolObject ballPO = PoolManager.Instance.GetObjectFromPool(PoolObjectItem.ePoolItem.Ball); ballPO.ActivatePoolObject(); ball = ballPO.GetComponent <Ball>(); }
internal void CheckForActivationsInPool() { if (this._waitingForActivationPool != null) { List <PoolObject> moveToActiveList = new List <PoolObject>(); for (int i = 0; i < this._waitingForActivationPool.Count; i++) { PoolObject objectToCheck = this._waitingForActivationPool[i]; if (objectToCheck != null) { float timeToAppear = objectToCheck.objectSettings.startTime + objectToCheck.objectSettings.appearanceTime - Time.time; if (timeToAppear < 0) { moveToActiveList.Add(objectToCheck); } } } for (int i = 0; i < moveToActiveList.Count; i++) { PoolObject objectToMove = moveToActiveList[i]; this._waitingForActivationPool.Remove(objectToMove); this._activePool.Add(objectToMove); objectToMove.ActivatePoolObject(); } } }
internal GameObject GetObjectFromPool(PoolObjectSettings settings) { if (settings != null) { PoolObject poolObject = TakeObjectFromPool(); if (poolObject != null) { poolObject.objectSettings = settings; settings.startTime = Time.time; if (settings != null && settings.appearanceTime <= 0) { this._idlePool.Remove(poolObject); this._activePool.Add(poolObject); poolObject.ActivatePoolObject(); } else { this._idlePool.Remove(poolObject); this._waitingForActivationPool.Add(poolObject); } return(poolObject._object); } } return(null); }
void SpawnPaddle() { PoolObject paddle = PoolManager.Instance.GetObjectFromPool(PoolObjectItem.ePoolItem.Paddle); paddle.ActivatePoolObject(); paddle.transform.position = new Vector3(0, -3, 0); playerPaddle = paddle.GetComponent <Paddle>(); }
internal GameObject GetAndActivateObjectFromPool(PoolObjectSettings settings) { if (settings != null) { PoolObject poolObject = TakeObjectFromPool(); if (poolObject != null) { poolObject.objectSettings = settings; settings.startTime = Time.time; this._idlePool.Remove(poolObject); poolObject.ActivatePoolObject(); this._activePool.Add(poolObject); return(poolObject._object); } } Debug.Log("Got null from pool!"); return(null); }