Example #1
0
        private void Fire(Transform transform, float enemySpeed, UnitSound unitSound)
        {
            var        global = GlobalFields.Instans;
            GameObject laser  = GameObject.Instantiate(enemyLaserPregab, transform.position + shift, Quaternion.identity, global.GetSpawnHolder());

            laser.GetComponent <Rigidbody2D>().velocity = new Vector2(0f, -laserSpeed - enemySpeed);
            unitSound.AudioPlayEnemyShoot();
        }
Example #2
0
 public IEnumerator Shooting(Transform transform, float enemySpeed, UnitSound unitSound)
 {
     while (shooting)
     {
         GetRandomTime();
         Fire(transform, enemySpeed, unitSound);
         yield return(new WaitForSeconds(shotCounter));
     }
 }
Example #3
0
        public IEnumerator Fire(Transform transform, UnitSound unitSound)
        {
            var global = GlobalFields.Instans;

            while (true)
            {
                if ((Input.GetButton("Fire1") || autoFire))
                {
                    GameObject laser = GameObject.Instantiate(laserPrefab, transform.position, Quaternion.identity, global.GetSpawnHolder());
                    laser.GetComponent <Rigidbody2D>().velocity = new Vector2(0, laserSpeed);
                    unitSound.AudioPlayPlayerShoot();
                    yield return(new WaitForSeconds(instatiateSpeed));
                }
                yield return(new WaitForSeconds(0.01f));

                if (GlobalFields.Instans.GetIsWin())
                {
                    break;
                }
            }
        }