コード例 #1
0
 private void GrowPool(Pooleable pooleable, int cantidad)
 {
     for (int i = 0; i < cantidad; i++)
     {
         Pooleable obj = Instantiate(pooleable);
         obj.Desactivar();
         pool[pooleable].Enqueue(obj);
     }
 }
コード例 #2
0
ファイル: DamageReceiver.cs プロジェクト: swipswaps/retry-1
 /// <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;
 }
コード例 #3
0
 public Pooleable SpawnObjeto(Pooleable obj)
 {
     if (!pool.ContainsKey(obj))
     {
         CrearPool(obj, defaultQuantity);
     }
     nuevoObj = pool[obj].Dequeue();
     nuevoObj.Activar();
     pool[obj].Enqueue(nuevoObj);
     return(nuevoObj);
 }
コード例 #4
0
ファイル: EnemyWave.cs プロジェクト: lantun01/BinaryAssault
 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;
     }
 }
コード例 #5
0
ファイル: ObjectPooler.cs プロジェクト: swipswaps/retry-1
 /// <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();
 }
コード例 #6
0
 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);
     }
 }