Example #1
0
 public void SetRobotContext(Layer ActiveLayer, RobotAnimation ActiveRobotAnimation, WeaponBase ActiveWeapon, float Angle, Vector2 Position)
 {
     this.ActiveLayer     = ActiveLayer;
     Target               = ActiveRobotAnimation;
     TargetWeapon         = ActiveWeapon;
     TargetWeaponAngle    = Angle;
     TargetWeaponPosition = Position;
 }
Example #2
0
 public void SetRobotContext(RobotAnimation ActiveRobotAnimation, WeaponBase ActiveWeapon, float Angle, Vector2 Position)
 {
     Owner.GlobalRobotContext.SetRobotContext(this, ActiveRobotAnimation, ActiveWeapon, Angle, Position);
 }
Example #3
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);
            }
        }
Example #4
0
        public Vehicle(string Name, Layer CurrentLayer, Vector2 Position, int Team, PlayerInventory Equipment, ISFXGenerator PlayerSFXGenerator, List <WeaponBase> ListExtraWeapon)
            : base(Name, CurrentLayer, Position, Team, new EquipmentLoadout(), PlayerSFXGenerator)
        {
            ListUser = new List <RobotAnimation>();

            FileStream   FS = new FileStream("Content/Units/Triple Thunder/Vehicles/" + Name + ".peuv", FileMode.Open, FileAccess.Read);
            BinaryReader BR = new BinaryReader(FS, Encoding.UTF8);

            BR.BaseStream.Seek(0, SeekOrigin.Begin);

            MaxHP        = BR.ReadInt32();
            MaxEN        = BR.ReadInt32();
            Accel        = BR.ReadSingle();
            MaxWalkSpeed = BR.ReadSingle();
            JumpSpeed    = BR.ReadSingle();
            byte ControlType = BR.ReadByte();
            byte CaptureType = BR.ReadByte();

            HasKnockback = BR.ReadBoolean();
            IsDynamic    = BR.ReadBoolean();

            int ListExtraAnimationCount = BR.ReadInt32();

            ListStanceAnimation = new List <WeaponBase>(ListExtraAnimationCount);
            for (int W = 0; W < ListExtraAnimationCount; ++W)
            {
                string ExtraAnimationPath = BR.ReadString();
                if (!string.IsNullOrEmpty(ExtraAnimationPath))
                {
                    ListStanceAnimation.Add(WeaponBase.CreateFromFile(Name, ExtraAnimationPath, true, CurrentLayer.DicRequirement, CurrentLayer.DicEffect, CurrentLayer.DicAutomaticSkillTarget));
                }
            }

            CurrentStanceAnimations = StandingAnimations;

            int ListWeaponCount = BR.ReadInt32();

            PrimaryWeapons   = new WeaponHolder(ListWeaponCount);
            SecondaryWeapons = new WeaponHolder(0);
            for (int W = 0; W < ListWeaponCount; ++W)
            {
                string WeaponName = BR.ReadString();
                PrimaryWeapons.AddWeaponToStash(WeaponBase.CreateFromFile(Name, WeaponName, false, CurrentLayer.DicRequirement, CurrentLayer.DicEffect, CurrentLayer.DicAutomaticSkillTarget));
            }

            if (ListExtraWeapon != null)
            {
                foreach (ComboWeapon ActiveWeapon in ListExtraWeapon)
                {
                    PrimaryWeapons.AddWeaponToStash(ActiveWeapon);
                    PrimaryWeapons.UseWeapon(ActiveWeapon);
                }
            }

            FS.Close();
            BR.Close();

            Load();

            SetAnimation(StandingAnimations.GetDefaultAnimationName());
            CurrentMovementInput = MovementInputs.None;
            ActiveMovementStance = "None";
            Update(new GameTime());
            SetIdle();

            if (!PrimaryWeapons.HasActiveWeapons)
            {
                if (PrimaryWeapons.HasWeapons)
                {
                    ChangeWeapon(0);
                }
                else
                {
                    ChangeWeapon(-1);
                }
            }

            UpdateSkills(BaseSkillRequirement.OnCreatedRequirementName);
        }
Example #5
0
 public void SetRobotContext(WeaponBase ActiveWeapon, float Angle, Vector2 Position)
 {
     CurrentLayer.SetRobotContext(this, ActiveWeapon, Angle, Position);
 }
Example #6
0
        public RobotAnimation(string Name, Layer CurrentLayer, Vector2 Position, int Team, PlayerInventory Equipment, ISFXGenerator PlayerSFXGenerator, List <WeaponBase> ListExtraWeapon)
            : this()
        {
            this.PlayerSFXGenerator = PlayerSFXGenerator.Copy();
            this.Name         = Name;
            this.CurrentLayer = CurrentLayer;
            this.Position     = Position;
            this.Team         = Team;
            this.Equipment    = new EquipmentLoadout(Equipment, this);

            FileStream   FS = new FileStream("Content/Units/Triple Thunder/" + Name + ".peu", FileMode.Open, FileAccess.Read);
            BinaryReader BR = new BinaryReader(FS, Encoding.UTF8);

            BR.BaseStream.Seek(0, SeekOrigin.Begin);

            MaxHP        = BR.ReadInt32();
            MaxEN        = BR.ReadInt32();
            Accel        = BR.ReadSingle();
            MaxWalkSpeed = BR.ReadSingle();
            JumpSpeed    = BR.ReadSingle();
            HasKnockback = BR.ReadBoolean();
            IsDynamic    = BR.ReadBoolean();

            Dictionary <string, BaseSkillRequirement>     DicRequirement          = null;
            Dictionary <string, BaseEffect>               DicEffect               = null;
            Dictionary <string, AutomaticSkillTargetType> DicAutomaticSkillTarget = null;

            if (CurrentLayer != null)
            {
                DicRequirement          = CurrentLayer.DicRequirement;
                DicEffect               = CurrentLayer.DicEffect;
                DicAutomaticSkillTarget = CurrentLayer.DicAutomaticSkillTarget;
            }

            ListStanceAnimation = new List <WeaponBase>(4);

            if (File.Exists("Content/Triple Thunder/Weapons/" + Name + "/Default" + ".ttw"))
            {
                ListStanceAnimation.Add(WeaponBase.CreateFromFile(Name, Name + "/Default", true, DicRequirement, DicEffect, DicAutomaticSkillTarget));
            }

            if (File.Exists("Content/Triple Thunder/Weapons/" + Name + "/Crouch" + ".ttw"))
            {
                ListStanceAnimation.Add(WeaponBase.CreateFromFile(Name, Name + "/Crouch", true, DicRequirement, DicEffect, DicAutomaticSkillTarget));
            }

            if (File.Exists("Content/Triple Thunder/Weapons/" + Name + "/Roll" + ".ttw"))
            {
                ListStanceAnimation.Add(WeaponBase.CreateFromFile(Name, Name + "/Roll", true, DicRequirement, DicEffect, DicAutomaticSkillTarget));
            }

            if (File.Exists("Content/Triple Thunder/Weapons/" + Name + "/Prone" + ".ttw"))
            {
                ListStanceAnimation.Add(WeaponBase.CreateFromFile(Name, Name + "/Prone", true, DicRequirement, DicEffect, DicAutomaticSkillTarget));
            }

            CurrentStanceAnimations = StandingAnimations;

            int ListWeaponCount = BR.ReadInt32();

            PrimaryWeapons   = new WeaponHolder(ListWeaponCount);
            SecondaryWeapons = new WeaponHolder(1);
            for (int W = 0; W < ListWeaponCount; ++W)
            {
                string     WeaponName = BR.ReadString();
                WeaponBase NewWeapon;
                string     WeaponPath = Name + "/Weapons/" + WeaponName;
                bool       IsGrenade  = false;
                if (!File.Exists("Content/Triple Thunder/Weapons/" + WeaponPath + ".ttw"))
                {
                    WeaponPath = Name + "/Grenades/" + WeaponName;
                    IsGrenade  = true;
                }

                if (CurrentLayer == null)
                {
                    NewWeapon = WeaponBase.CreateFromFile(Name, WeaponPath, false, null, null, null);
                }
                else
                {
                    NewWeapon = WeaponBase.CreateFromFile(Name, WeaponPath, false, CurrentLayer.DicRequirement, CurrentLayer.DicEffect, CurrentLayer.DicAutomaticSkillTarget);
                }

                NewWeapon.WeaponName = WeaponName;
                if (IsGrenade)
                {
                    SecondaryWeapons.AddWeaponToStash(NewWeapon);
                }
                else
                {
                    PrimaryWeapons.AddWeaponToStash(NewWeapon);
                }
            }

            if (ListExtraWeapon != null)
            {
                foreach (WeaponBase ActiveWeapon in ListExtraWeapon)
                {
                    ActiveWeapon.IsExtra = true;
                    PrimaryWeapons.AddWeaponToStash(ActiveWeapon);
                    PrimaryWeapons.UseWeapon(ActiveWeapon);
                }
            }

            Sounds = new UnitSounds(BR);

            FS.Close();
            BR.Close();

            Load();

            if (!PrimaryWeapons.HasActiveWeapons)
            {
                if (PrimaryWeapons.HasWeapons)
                {
                    ChangeWeapon(0);
                }
                else
                {
                    ChangeWeapon(-1);
                }
            }

            if (CurrentLayer != null)
            {
                UpdateSkills(BaseSkillRequirement.OnCreatedRequirementName);
            }
        }
        private void UpdateOwner(GameTime gameTime)
        {
            if (GrenadeCooldown > 0)
            {
                GrenadeCooldown -= gameTime.ElapsedGameTime.TotalSeconds;
            }

            bool IsIdle = true;

            if (InputHelper.InputRightHold() || KeyboardHelper.KeyHold(Keys.D))
            {
                IsIdle = false;
                Owner.Move(MovementInputs.Right);
            }
            else if (InputHelper.InputLeftHold() || KeyboardHelper.KeyHold(Keys.A))
            {
                IsIdle = false;
                Owner.Move(MovementInputs.Left);
            }

            if (InputHelper.InputUpHold() || KeyboardHelper.KeyHold(Keys.W))
            {
                IsIdle = false;
                Owner.Jump();
            }
            else if (InputHelper.InputDownPressed() || KeyboardHelper.KeyPressed(Keys.S))
            {
                IsIdle = false;
                Owner.StartCrouch();
                //Disabled until I can specify which platforms to not fall through.
                //Owner.FallThroughFloor();
            }
            else if (InputHelper.InputDownHold() || KeyboardHelper.KeyHold(Keys.S))
            {
                IsIdle = false;
                Owner.Crouch();
                //Disabled until I can specify which platforms to not fall through.
                //Owner.FallThroughFloor();
            }
            else if (KeyboardHelper.KeyHold(Keys.X))
            {
                IsIdle = false;
                Owner.GoProne();
            }

            if (IsIdle)
            {
                Owner.SetIdle();
            }

            if (InputHelper.InputUpReleased() || KeyboardHelper.KeyReleased(Keys.W))
            {
                Owner.StopJump();
            }

            if (KeyboardHelper.KeyHold(Keys.Space))
            {
                Owner.UseJetpack(gameTime);
            }
            else
            {
                Owner.Freefall(gameTime);
            }

            if (KeyboardHelper.KeyPressed(Keys.R))
            {
                for (int W = 0; W < Owner.PrimaryWeapons.ActiveWeapons.Count; W++)
                {
                    WeaponBase ActiveWeapon = Owner.PrimaryWeapons.ActiveWeapons[W];
                    if (ActiveWeapon.CanBeReloaded())
                    {
                        ActiveWeapon.ResetAnimationToIdle();
                    }
                }
                Owner.Reload();
            }
            else if (KeyboardHelper.KeyPressed(Keys.LeftShift) || KeyboardHelper.KeyPressed(Keys.RightShift))
            {
                Owner.DropActiveWeapons();
            }
            else if (MouseHelper.InputLeftButtonPressed())
            {
                Owner.UnholsterWeaponsIfNeeded();
                Owner.InitiateAttack(gameTime, AttackInputs.LightPress);
            }
            else if (MouseHelper.InputLeftButtonHold())
            {
                Owner.UnholsterWeaponsIfNeeded();
                Owner.InitiateAttack(gameTime, AttackInputs.LightHold);
            }

            if (GrenadeCooldown <= 0)
            {
                if (MouseHelper.InputRightButtonPressed())
                {
                    if (Owner.SecondaryWeapons.ActiveWeapons.Count > 0)
                    {
                        Owner.HolsterAndReplaceWeapon(Owner.SecondaryWeapons.ActiveWeapons[0]);
                    }
                    else
                    {
                        Owner.InitiateAttack(gameTime, AttackInputs.HeavyPress);
                    }
                }
                else if (MouseHelper.InputRightButtonReleased())
                {
                    if (Owner.SecondaryWeapons.ActiveWeapons.Count > 0)
                    {
                        Owner.SecondaryWeapons.ActiveWeapons[0].InitiateAttack(gameTime, AttackInputs.HeavyPress, Owner.CurrentMovementInput, Owner.ActiveMovementStance, true, Owner);
                        Owner.UnholsterWeaponsIfNeeded();
                        GrenadeCooldown = 1;
                    }
                }
                else if (MouseHelper.InputRightButtonHold())
                {
                    if (Owner.SecondaryWeapons.ActiveWeapons.Count > 0)
                    {
                        Owner.SecondaryWeapons.ActiveWeapons[0].InitiateAttack(gameTime, AttackInputs.HeavyHold, Owner.CurrentMovementInput, Owner.ActiveMovementStance, false, Owner);
                    }
                    else
                    {
                        Owner.InitiateAttack(gameTime, AttackInputs.HeavyHold);
                    }
                }
            }

            if (KeyboardHelper.KeyPressed(Keys.D1))
            {
                Owner.ChangeWeapon(-1);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D2))
            {
                Owner.ChangeWeapon(0);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D3))
            {
                Owner.ChangeWeapon(1);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D4))
            {
                Owner.ChangeWeapon(2);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D5))
            {
                Owner.ChangeWeapon(3);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D6))
            {
                Owner.ChangeWeapon(4);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D7))
            {
                Owner.ChangeWeapon(5);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D8))
            {
                Owner.ChangeWeapon(6);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D9))
            {
                Owner.ChangeWeapon(7);
            }
            else if (KeyboardHelper.KeyPressed(Keys.D0))
            {
                Owner.ChangeWeapon(8);
            }
        }
Example #8
0
 public void UseWeapon(WeaponBase WeaponToUse)
 {
     ListActiveWeapon.Add(WeaponToUse);
 }
Example #9
0
 public void AddWeaponToStash(WeaponBase NewWeapon)
 {
     DicWeaponByName.Add(NewWeapon.WeaponPath, NewWeapon);
     ListWeaponByIndex.Add(NewWeapon.WeaponPath);
 }