private void GrowPool(Pooleable pooleable, int cantidad) { for (int i = 0; i < cantidad; i++) { Pooleable obj = Instantiate(pooleable); obj.Desactivar(); pool[pooleable].Enqueue(obj); } }
/// <summary> /// <para>Adds a listener to the OnDie event</para> /// </summary> private void Awake() { _stats = GetComponent <Stats>(); _rigidbody2D = GetComponent <Rigidbody2D>(); _pooleable = GetComponent <Pooleable>(); _spriteRenderer = GetComponent <SpriteRenderer>(); _originalColor = _spriteRenderer.color; _stats.OnDie += OnDie; }
public Pooleable SpawnObjeto(Pooleable obj) { if (!pool.ContainsKey(obj)) { CrearPool(obj, defaultQuantity); } nuevoObj = pool[obj].Dequeue(); nuevoObj.Activar(); pool[obj].Enqueue(nuevoObj); return(nuevoObj); }
internal void Activate(EnemyWaveManager manager, Pooler pool) { this.manager = manager; totalEnemy = enemigos.Count; for (int i = 0; i < totalEnemy; i++) { currentEnemy = pool.SpawnObjeto(enemigos[i].enemigo); currentEnemy.Reiniciar(); currentEnemy.SubscribirCaller(this); currentEnemy.transform.position = enemigos[i].spawnPosition; } }
/// <summary> /// Instantiates game objects with the given <paramref name="pooleable"/> and <paramref name="quantity"/>. /// The new gameObjects will have their parent called <paramref name="parentName"/> /// </summary> /// <param name="quantity"></param> /// <param name="pooleable"></param> /// <param name="parentName"></param> /// <param name="grow">Method that will be executed when the pool grows.</param> public void InstantiateObjects(int quantity, Pooleable pooleable, string parentName, Action <List <Pooleable> > grow = null) { initialQuantity = quantity; parent = new GameObject { name = parentName }; objectToPool = pooleable; objects = new List <Pooleable>(); onGrow = grow; Grow(); }
public void CrearPool(Pooleable pooleable, int cantidad) { if (!pool.ContainsKey(pooleable)) { Queue <Pooleable> qpool = new Queue <Pooleable>(); for (int i = 0; i < cantidad; i++) { Pooleable obj = Instantiate(pooleable); obj.Desactivar(); qpool.Enqueue(obj); } pool.Add(pooleable, qpool); } else { GrowPool(pooleable, cantidad); } }