コード例 #1
0
 /// <summary>
 /// Shoots a bullet barrage of up to 10 buullets
 /// </summary>
 /// <returns></returns>
 IEnumerator BulletBarrage()
 {
     shotBullets = 0;
     if (bullet != null)
     {
         bullet.GetComponent <Bullet_Player>().ShootBullet();
         counter = 0;
     }
     for (int i = 0; i < barrageAmount; i++)
     {
         if (barrageAmount > i)
         {
             bullet            = Instantiate(bulletPrefab, transform.position, Quaternion.identity);
             bulletLight       = bullet.GetComponentInChildren <Light>();
             bulletLight.range = 1;
             counter           = 1;
             ShootSound();
             bullet.GetComponent <Bullet_Player>().ShootBullet();
             counter = 0;
             shotBullets++;
             BulletShot?.Invoke();
             bullet = null;
             yield return(new WaitForSeconds(.1f));
         }
     }
 }
コード例 #2
0
ファイル: Shooter.cs プロジェクト: sunor4/SpaceInvaders
 private void OnBulletShot()
 {
     if (BulletShot != null)
     {
         BulletShot.Invoke();
     }
 }
コード例 #3
0
ファイル: PlayerShooting.cs プロジェクト: Rud156/StormTime
        private void ShootShotGunBullet()
        {
            float currentRotation = _playerRoot.GetRotationDegrees();
            float currentAngle    = currentRotation - shotGunBulletCount / 2.0f * shotGunAngleDiff;

            for (int i = 0; i < shotGunBulletCount; i++)
            {
                float xVelocity = Mathf.Cos(Mathf.Deg2Rad(currentAngle));
                float yVelocity = Mathf.Sin(Mathf.Deg2Rad(currentAngle));

                Vector2 launchVelocity = new Vector2(xVelocity, yVelocity);
                ShootSingleShotBullet(launchVelocity.Normalized());

                currentAngle += shotGunAngleDiff;
            }

            bulletShot?.Invoke(_currentWeaponType);
        }