Exemplo n.º 1
0
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position
                //Instantiate(bullet, bulletSpawn.position, Quaternion.identity);


                GameObject bullet = newManager.GetBullet();
                if (newManager.GetBullet() != null)
                {
                    bullet.transform.position = bulletSpawn.position;
                    bullet.transform.rotation = bulletSpawn.rotation;
                    bullet.SetActive(true);
                }
            }
        }
    }
Exemplo n.º 2
0
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position

                //myPool.GetBullet();
                myPool.GetBullet("Bullets", bulletSpawn.position, Quaternion.identity);
                //myPool.GetBullet("Missiles", bulletSpawn.position, Quaternion.identity);
                //Instantiate(bullet, bulletSpawn.position, Quaternion.identity);
            }
            if (isFiring2)
            {
                myPool.GetBullet("Missiles", bulletSpawn.position, Quaternion.identity);
            }
            //else if (isFiring2)
            //{
            //   _bulletSound.Play();
            //   myPool.GetBullet("Missiles", bulletSpawn.position, Quaternion.identity);
            //}
        }
    }
Exemplo n.º 3
0
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position

                //Create temp object
                GameObject firingBullet;

                //Get the bullet and assign to temp object
                firingBullet = poolManager.GetBullet();

                //Set the bullet to fire from bullet spawn position
                firingBullet.transform.position = bulletSpawn.position;
            }
        }
    }
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.15 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position



                Instantiate(bullet, bulletSpawn.position, Quaternion.identity);
            }
        }



        BuildPoolOfBullets.GetBullet();
        getSize();
        isEmpty();
    }
    void Shoot()
    {
        Bullet bulletToShoot = bulletManager.GetBullet();

        bulletToShoot.transform.position = ShootStartingPosition.position;
        bulletToShoot.Shoot(transform.forward, ShootForce);
    }
Exemplo n.º 6
0
    IEnumerator FireBullet() //code routine
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();
                //Use object pooling to reuse the bullets

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position
                GameObject bullet = bulletPoolManager.GetBullet();

                if (bullet != null)
                {
                    bullet.transform.position = bulletSpawn.position;
                }
            }
        }
    }
    IEnumerator FireBullet()
    {
        int iteration = 0;

        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position
                GameObject bullet = bulletPoolManager.GetBullet(iteration);
                bullet.transform.position = bulletSpawn.position;
                if (iteration == 49)
                {
                    iteration = 0;
                }
                else
                {
                    iteration++;
                }
            }
        }
    }
Exemplo n.º 8
0
    public IBullet GetBullet()
    {
        IBullet bulletToShoot = bulletManager.GetBullet(BulletID);

        bulletToShoot.gameObject.transform.position = ShootStartPosition.position;
        bulletToShoot.OnDestroy += OnBulletDestroy;
        return(bulletToShoot);
    }
Exemplo n.º 9
0
        public IBullet GetBullet()
        {
            IBullet bulletToShoot = bulletManager.GetBullet(BulletID);

            bulletToShoot.gameObject.transform.position = ShootStartPosition.position;
            bulletToShoot.OnDestroy += OnBulletDestroy;
            bulletToShoot.gameObject.AddComponent <CollisionController>().PlayerDestroyer = true;
            return(bulletToShoot);
        }
Exemplo n.º 10
0
    private void CheckBounds()
    {
        if (transform.position.y >= boundary.Top)
        {
            //TODO: This code needs to change to use the BulletPoolManager's
            //TODO: ResetBullet function which will return the bullet to the pool

            Bullet_Pool_Manager.GetBullet();
            Bullet_Pool_Manager.ResetBullet(bullets);
            // Destroy(this.gameObject);
        }
    }
Exemplo n.º 11
0
    void Shoot()
    {
        IBullet currentBullet = CurrentBulletGO.GetComponent <IBullet>();

        if (currentBullet == null)
        {
            return;
        }
        IBullet bulletToShoot = bulletManager.GetBullet(currentBullet.ID);

        bulletToShoot.gameObject.transform.position = ShootStartPosition.position;
        bulletToShoot.Shoot(transform.forward, ShootForce);
        bulletToShoot.OnDestroy  += OnBulletDestroy;
        bulletToShoot.OnEnemyHit += OnEnemyHit;
    }
Exemplo n.º 12
0
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                GameObject sBullet = accessBulletPoolManager.GetBullet();
                sBullet.transform.position = bulletSpawn.transform.position;
            }
        }
    }
Exemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        FireRate = FireRate + Time.deltaTime;

        if (FireRate <= 0.6f && IsFiring == false)
        {
            Bullet bulletToShoot = BulletPoolManager.GetBullet();
            bulletToShoot.transform.position = PointShoot.position;
            bulletToShoot.Shoot(new Vector3(1f, 0f, 1f), -ShootForza);
            Firing = true;
        }
        if (FireRate >= 1f)
        {
            FireRate = 0f;
            IsFiring = false;
        }
    }
Exemplo n.º 14
0
    IEnumerator FireBullet()
    {
        while (true)
        {
            // Check every 0.2 seconds if shoot button is pressed
            yield return(new WaitForSeconds(0.15f));

            if (isFiring)
            {
                _bulletSound.Play();

                //TODO: this code needs to change to user the BulletPoolManager's
                //TODO: GetBullet function which will return a reference to a
                //TODO: bullet object.
                //TODO: Ensure you position the new bullet at the bulletSpawn position
                poolManager.GetBullet(bulletSpawn.position).SetActive(true);
            }
        }
    }
 private void isEmpty()
 {
     Bullet_Pool_Manager.GetBullet();
 }