Esempio n. 1
0
        private void HandleBulletShot(PlayerShooting.WeaponType weaponType)
        {
            switch (weaponType)
            {
            case PlayerShooting.WeaponType.SingleShot:
                break;

            case PlayerShooting.WeaponType.Shotgun:
            {
                float currentRotation = GetRotation() - Mathf.Pi;
                float xVelocity       = Mathf.Cos(currentRotation);
                float yVelocity       = Mathf.Sin(currentRotation);

                Vector2 reverseVelocity = new Vector2(xVelocity, yVelocity);
                reverseVelocity.x *= shotGunRecoilForce;
                reverseVelocity.y *= shotGunRecoilForce;

                _movement = reverseVelocity;
                _currentShotGunRecoilTime = shotGunRecoilAffectTime;
            }
            break;

            case PlayerShooting.WeaponType.ChargeGun:
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(weaponType), weaponType, null);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Updates currently selected weapon.
 /// </summary>
 /// <param name="weapon"></param>
 public void UpdateWeapon(PlayerShooting.WeaponType weapon)
 {
     if (weapon == PlayerShooting.WeaponType.PeaShooter)
     {
         ammoCount = 0;
         instance.ammo.GetComponent <Text>().text          = "*";
         instance.currentWeapon.GetComponent <Text>().text = "Pea Shooter";
     }
     else if (weapon == PlayerShooting.WeaponType.AutoRifle)
     {
         ammoCount = 50;
         instance.ammo.GetComponent <Text>().text          = "50";
         instance.currentWeapon.GetComponent <Text>().text = "Auto Rifle";
     }
     else if (weapon == PlayerShooting.WeaponType.TripleShot)
     {
         ammoCount = 20;
         instance.ammo.GetComponent <Text>().text          = "20";
         instance.currentWeapon.GetComponent <Text>().text = "Triple Shot";
     }
     instance.weapon = weapon;
 }