Exemple #1
0
        public void UpdateAllWeaponsAngle(Vector2 Target)
        {
            int W = 0;

            foreach (WeaponBase ActiveWeapon in PrimaryWeapons.ActiveWeapons)
            {
                bool RotateTowardMouse = ActiveWeapon.CanRotateTowardMouse(ActiveMovementStance);

                float Angle = 0;
                if (RotateTowardMouse)
                {
                    Angle = (float)Math.Atan2(Target.Y, Target.X);
                }

                ActiveWeapon.WeaponAngle = Angle;

                if (Angle <= -MathHelper.PiOver2 || Angle >= MathHelper.PiOver2)
                {
                    ActiveSpriteEffects = SpriteEffects.None;
                }
                else
                {
                    ActiveSpriteEffects = SpriteEffects.FlipHorizontally;
                    Angle = MathHelper.Pi - Angle;
                }

                UpdatePrimaryWeaponAngle(Angle + MathHelper.Pi, W++);
            }

            W = 0;
            foreach (WeaponBase ActiveWeapon in SecondaryWeapons.ActiveWeapons)
            {
                bool RotateTowardMouse = ActiveWeapon.CanRotateTowardMouse(ActiveMovementStance);

                float Angle = 0;
                if (RotateTowardMouse)
                {
                    Angle = (float)Math.Atan2(Target.Y, Target.X);
                }

                ActiveWeapon.WeaponAngle = Angle;

                if (Angle <= -MathHelper.PiOver2 || Angle >= MathHelper.PiOver2)
                {
                    ActiveSpriteEffects = SpriteEffects.None;
                }
                else
                {
                    ActiveSpriteEffects = SpriteEffects.FlipHorizontally;
                    Angle = MathHelper.Pi - Angle;
                }

                UpdateSecondaryWeaponAngle(Angle, W++);
            }
        }