Exemple #1
0
 IEnumerator Shoot()
 {
     while (true)
     {
         if (mPool.bulletsPool.Length != 0)
         {
             Vector3 pos = transform.GetChild(0).position;
             mPool.Spawner(pos, transform.rotation);
             yield return(new WaitForSeconds(cadence));
         }
         else
         {
             yield return(null);
         }
     }
 }
Exemple #2
0
    IEnumerator BulletCreator()
    {
        while (true)
        {
            if (!GameManager.instance.pause && !GameManager.instance.gameOver)
            {
                if (secondAmmo > 0 && thirdAmmo <= 0)
                {
                    m_Gunz = Gunz.SecondGun;
                }
                else if (thirdAmmo > 0)
                {
                    m_Gunz = Gunz.ThirdGun;
                }
                else
                {
                    m_Gunz = Gunz.BasicGun;
                }

                if (thirdAmmo < 0)
                {
                    thirdAmmo = 0;
                }
                switch (m_Gunz)
                {
                case Gunz.BasicGun:
                    if (OnShooting)
                    {
                        if (mOrder == CanyonOrder.Right)
                        {
                            m_pooler.Spawner(transform.localPosition + canyonPositions[0], Quaternion.identity);
                            mOrder = CanyonOrder.Left;
                        }
                        else
                        {
                            m_pooler.Spawner(transform.localPosition + canyonPositions[1], Quaternion.identity);
                            mOrder = CanyonOrder.Right;
                            m_pooler.bulletsPool[0].GetComponent <BulletController>().StartBullet();
                        }
                        AudioSource.PlayClipAtPoint(GameManager.instance.playerShot, Camera.main.transform.position);
                        yield return(new WaitForSeconds(0.3f));
                    }
                    break;

                case Gunz.SecondGun:
                    if (OnShooting)
                    {
                        secondAmmo--;
                        if (mOrder == CanyonOrder.Right)
                        {
                            m_pooler.Spawner(transform.localPosition + canyonPositions[0], Quaternion.identity);
                        }
                        else
                        {
                            m_pooler.Spawner(transform.localPosition + canyonPositions[1], Quaternion.identity);
                        }
                        if (mOrder == CanyonOrder.Right)
                        {
                            mOrder = CanyonOrder.Left;
                        }
                        else
                        {
                            mOrder = CanyonOrder.Right;
                        }
                        AudioSource.PlayClipAtPoint(GameManager.instance.playerShot, Camera.main.transform.position);
                        yield return(new WaitForSeconds(0.3f));
                    }
                    break;

                case Gunz.ThirdGun:
                    if (OnShooting)
                    {
                        thirdAmmo -= 6;

                        for (int i = 0; i < 6; i++)
                        {
                            if (i < 3)
                            {
                                m_pooler.Spawner(transform.localPosition + canyonPositions[0], Quaternion.identity);
                            }
                            else
                            {
                                m_pooler.Spawner(transform.localPosition + canyonPositions[1], Quaternion.identity);
                            }
                        }

                        AudioSource.PlayClipAtPoint(GameManager.instance.playerShot, Camera.main.transform.position);
                        yield return(new WaitForSeconds(0.3f));
                    }
                    break;

                default:
                    break;
                }
            }

            yield return(null);
        }
    }