Exemple #1
0
        /// <summary>
        /// Get disabled object from pool.
        /// </summary>
        public GameObject GetPooledObject(bool extraPooledObjects, GameObject parentObject, List <GameObject> ObjectsToPool, List <GameObject> ObjectPool)
        {
            List <GameObject> w = ObjectPool;

            for (int i = 0; i < w.Count; i++)
            {
                if (!w[i].activeInHierarchy)
                {
                    return(w[i]);
                }
            }
            if (extraPooledObjects)
            {
                GameObject wal  = Instantiate(ObjectsToPool[UnityEngine.Random.Range(0, ObjectsToPool.Count)]);
                Grenade    gren = wal.GetComponent <Grenade>();
                if (gren)
                {
                    gren.grenadeLauncher = this;
                }
                wal.transform.parent = parentObject.transform;
                w.Add(wal);
                return(wal);
            }
            return(null);
        }
Exemple #2
0
 //
 private void Start()
 {// check runtime platform
     if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)
     {
         mobile = true;
     }
     else if (GameManager.Mobile)
     {
         mobile = true;
     }
     else
     {
         mobile = false;
     }
     trigger  = GameManager._gameManager.shootOptions.shootTrigger;
     rt       = GameManager.fRt;
     m_Button = GameManager._gameManager.shootOptions.shootButton.GetComponent <ShootButton>();
     player   = GameManager._player;
     temp.transform.parent = GameManager._gameManager.PoolParent.transform;
     if (GrenadeChildPrefabs.Count > 0)
     {
         GameManager._gameManager.ObjectPooling(maxChildGrenades, temp, GrenadeChildPrefabs, GrenadeChildPool);                                // fill grenades pool;
     }
     foreach (var g in GrenadeChildPool)
     {
         Grenade gren = g.GetComponent <Grenade>();
         if (gren)
         {
             gren.grenadeLauncher = this;
         }
     }
     if (GrenadePrefabs.Count > 0)
     {
         GameManager._gameManager.ObjectPooling(maxGrenades, temp, GrenadePrefabs, GrenadePool);                           // fill grenades pool;
     }
     foreach (var g in GrenadePool)
     {
         Grenade gren = g.GetComponent <Grenade>();
         if (gren)
         {
             gren.grenadeLauncher = this;
         }
     }
     if (puffs.Count > 0)
     {
         GameManager._gameManager.ObjectPooling(maxpuffs, temp, puffs, PuffPool);                 // fill puffs pool;
     }
     if (ChildExplosions.Count > 0)
     {
         GameManager._gameManager.ObjectPooling(maxChildExpllosions, temp, ChildExplosions, ChildExplosionsPool);                           // fill puffs pool;
     }
 }