Пример #1
0
        private void FireMissileShot(Vector2 fireAngle)
        {
            ShotFiredEventArgs args = new ShotFiredEventArgs
            {
                Location = _turretSprite.WorldLocation,
                Velocity = fireAngle * WeaponSpeed,
                ShotType = ShotType.Missile
            };

            ShotFired?.Invoke(this, args);

            _missileTimer.Reset();
        }
Пример #2
0
        private void FireTripleShot(Vector2 fireAngle)
        {
            Vector2 baseWeaponVector = fireAngle * WeaponSpeed;
            double  baseAngle        = Math.Atan2(baseWeaponVector.Y, baseWeaponVector.X);
            double  offset           = MathHelper.ToRadians(TripleWeaponSplitAngleDegrees);

            ShotFiredEventArgs shot1 = new ShotFiredEventArgs
            {
                Location = _turretSprite.WorldLocation,
                Velocity = baseWeaponVector,
                ShotType = ShotType.Bullet
            };

            ShotFiredEventArgs shot2 = new ShotFiredEventArgs
            {
                Location = _turretSprite.WorldLocation,
                Velocity = new Vector2(
                    (float)Math.Cos(baseAngle - offset),
                    (float)Math.Sin(baseAngle - offset)
                    ) * baseWeaponVector.Length(),
                ShotType = ShotType.Bullet
            };

            ShotFiredEventArgs shot3 = new ShotFiredEventArgs
            {
                Location = _turretSprite.WorldLocation,
                Velocity = new Vector2(
                    (float)Math.Cos(baseAngle + offset),
                    (float)Math.Sin(baseAngle + offset)
                    ) * baseWeaponVector.Length(),
                ShotType = ShotType.Bullet
            };

            ShotFired?.Invoke(this, shot1);
            ShotFired?.Invoke(this, shot2);
            ShotFired?.Invoke(this, shot3);

            _shotTimer.Reset();
        }
Пример #3
0
 public void AddShot(ShotFiredEventArgs args)
 {
     AddShot(args.Location, args.Velocity, args.ShotType);
 }