Пример #1
0
    IEnumerator Shot()
    {
        if (shotCount < MaxShotCount)
        {
            shotCount += 1;
            isShot     = false;
            isShooting = true;
            GameObject enemyShell = shellManagerSc.GetEnemyShell();
            enemyShell.GetComponent <EnemyShell>().bounceCount = bounce;
            enemyShell.transform.position = shotPos.position;
            enemyShell.transform.rotation = Quaternion.Euler(0, headTransform.rotation.eulerAngles.y + 90, 90);
            Rigidbody enemyShellRb = enemyShell.GetComponent <Rigidbody>();
            enemyShellRb.AddForce(transform.forward * shotSpeed);
            AudioSource.PlayClipAtPoint(shotSound, transform.position);
            if (shotPos1 != null)
            {
                StartCoroutine(DoubleShot());
            }
            if (enemyHeadMove.isRange)
            {
                yield return(new WaitForSeconds(0.1f));
            }
            else if (!enemyHeadMove.isRange)
            {
                yield return(new WaitForSeconds(shotRate));
            }

            isShooting = false;
        }
        else
        {
            yield return(new WaitForSeconds(shotInterval));

            shotCount = 0;
        }
    }
Пример #2
0
    IEnumerator Shot()
    {
        if (!Tankhealth.isInvincible)
        {
            isShooting = true;
            GameObject enemyShell = shellManagerSc.GetEnemyShell();
            enemyShell.transform.position = shotPos.position;
            enemyShell.transform.rotation = Quaternion.Euler(0, headTransform.rotation.eulerAngles.y + 90, 90);
            Rigidbody enemyShellRb = enemyShell.GetComponent <Rigidbody>();
            enemyShell.GetComponent <EnemyShell>().bounceCount = bounceNum;
            enemyShellRb.AddForce(transform.forward * shotSpeed);
            AudioSource.PlayClipAtPoint(shotSound, transform.position);
            yield return(new WaitForSeconds(waitiingTime));

            isShooting = false;
        }
    }