Ejemplo n.º 1
0
        public void UpdateSecondaryWeaponAngle(float Angle, int WeaponIndex)
        {
            WeaponBase ActiveWeapon = SecondaryWeapons.ActiveWeapons[WeaponIndex];

            VisibleTimeline WeaponSlotTimeline;

            DicActiveAnimationObject.TryGetValue("Weapon Slot " + (WeaponIndex + 1), out WeaponSlotTimeline);
            ActiveWeapon.UpdateWeaponAngle(Angle, ActiveMovementStance, WeaponSlotTimeline, this);
        }
Ejemplo n.º 2
0
        public void Shoot(Vector2 GunNozzlePosition, WeaponBase ActiveWeapon, int WeaponIndex)
        {
            bool CanShoot;

            if (ActiveWeapon.AmmoPerMagazine > 0)
            {
                if (ActiveWeapon.AmmoCurrent > 0)
                {
                    --ActiveWeapon.AmmoCurrent;
                    CanShoot = true;
                }
                else
                {
                    CanShoot = false;
                }
            }
            else
            {
                CanShoot = true;
            }

            VisibleTimeline  WeaponSlotTimeline;
            PartialAnimation WeaponAnimation;

            if (CanShoot)
            {
                float OffsetX = GunNozzlePosition.X - AnimationOrigin.Position.X;
                float OffsetY = GunNozzlePosition.Y - AnimationOrigin.Position.Y;

                if (ActiveWeapon.CurrentAnimation != null && DicPartialAnimation.TryGetValue(ActiveWeapon.CurrentAnimation.AnimationPath, out WeaponAnimation))
                {
                    OffsetX = GunNozzlePosition.X - WeaponAnimation.AnimationOrigin.Position.X;
                    OffsetY = GunNozzlePosition.Y - WeaponAnimation.AnimationOrigin.Position.Y;
                }

                float WeaponOffsetX = 0;
                float WeaponOffsetY = 0;
                if (DicActiveAnimationObject.TryGetValue("Weapon Slot " + (WeaponIndex + 1), out WeaponSlotTimeline))
                {
                    WeaponOffsetX = WeaponSlotTimeline.Position.X - AnimationOrigin.Position.X;
                    WeaponOffsetY = WeaponSlotTimeline.Position.Y - AnimationOrigin.Position.Y;
                }

                float Angle = ActiveWeapon.WeaponAngle;

                if (ActiveSpriteEffects != SpriteEffects.FlipHorizontally)
                {
                    WeaponOffsetX = -WeaponOffsetX;
                }

                double LenghtDirX  = Math.Cos(Angle) * OffsetX;
                double LenghtDirY  = Math.Sin(Angle) * OffsetX;
                double LenghtDirX2 = Math.Cos(Angle + MathHelper.ToRadians(90)) * OffsetY;
                double LenghtDirY2 = Math.Sin(Angle + MathHelper.ToRadians(90)) * OffsetY;

                Vector2 RealGunNozzlePosition = Position + new Vector2(WeaponOffsetX, WeaponOffsetY)
                                                - new Vector2((float)(LenghtDirX + LenghtDirX2), (float)(LenghtDirY + LenghtDirY2));

                SetRobotContext(ActiveWeapon, Angle, RealGunNozzlePosition);

                foreach (MagicSpell ActiveSpell in ListMagicSpell)
                {
                    ActiveSpell.ExecuteSpell();
                }

                if (ActiveWeapon.HasSkills)
                {
                    ActiveWeapon.UpdateSkills("Shoot");
                }
                else
                {
                    ActiveWeapon.Shoot(this, RealGunNozzlePosition, Angle, new List <BaseAutomaticSkill>());
                }

                CreateNozzleFlashAnimation(ActiveWeapon.NozzleFlashAnimation, RealGunNozzlePosition, Angle);
            }
        }