Example #1
0
 IEnumerator ShootRoutine()
 {
     while (shotCount > 0)
     {
         shootable?.FireShot();
         --shotCount;
         yield return(new WaitForSeconds(shotFrequency));
     }
 }
Example #2
0
    private void Update()
    {
        bool willBeDestroyed = destructible != null && destructible.WillBeDestroyed;

        if (!willBeDestroyed)
        {
            if (enableShooting)
            {
                if (Time.time - lastShotTime >= shotFrequency && currentShotCount < maxShotCount)
                {
                    shootable?.FireShot();
                    lastShotTime = Time.time;
                    ++currentShotCount;
                }
            }

            movable?.Move(Time.deltaTime);
        }
    }