Exemplo n.º 1
0
    private void ShootBullet()
    {
        GameObject       bullet          = bulletPool.Rent(false);
        BulletController bulletComponent = bullet.GetComponent <BulletController>();

        bulletComponent.SetBulletType();

        if (GameObject.Find("BulletPool"))
        {
            if (GameObject.Find("FreezeBullet") && bulletComponent.bulletType == Scriptable.BulletTypes.Freeze)
            {
                bullet.transform.parent = GameObject.Find("BulletPool/FreezeBullet").transform;
            }
            if (GameObject.Find("FreezeBullet") && bulletComponent.bulletType == Scriptable.BulletTypes.AreaDamage)
            {
                bullet.transform.parent = GameObject.Find("BulletPool/NormalBullet").transform;
            }
        }

        bullet.transform.position = Vector3.zero;
        bullet.transform.position = bulletSpawnPoint.transform.position;

        bullet.SetActive(true);
        Tools.EmitOnDisable emitOnDisable = bullet.GetComponent <Tools.EmitOnDisable>();
        emitOnDisable.OnDisableGameObject += BulletDisable;

        bulletComponent.ResetBullet(MapCreation.MapCreator.BlockSize, activeTargets[0].transform.position);
    }
 public GameObject Rent(bool returnActive)
 {
     if (m_InternalPool == null)
     {
         Transform parent = null;
         if (m_HasParent)
         {
             parent = new GameObject(m_ParentName).transform;
         }
         m_InternalPool = new GameObjectPool(m_InitSize, m_Prefab, m_ExpandBy, parent);
     }
     return(m_InternalPool.Rent(returnActive));
 }