예제 #1
0
        public void Initialize(int id)
        {
            RunnerStruct rs = DataStructs.Runners.Find(r => r.ID == id);

            HP = new HitPoints(rs.HP, rs.HP, 0);
            HPBar.Percentage = 100;
            HPRegen = rs.HPRegen;
            Velocity = rs.Velocity;
            IsMelee = rs.IsMelee;
            IsGround = rs.IsGround;
            Recycles = rs.Recycles;
            Bounty = rs.Bounty;
            FinishDmg = rs.FinishDamage;

            ImmuneStun = rs.ImmuneStun;
            ImmuneSlow = rs.ImmuneSlow;
            ImmuneArmorReduction = rs.ImmuneArmorReduction;
            ImmuneRooted = rs.ImmuneRooted;

            Animation = AnimationFactory.Create(rs.AnimationType, out RelativeAABB);
            HPBar.BarDrawRect = new Rectangle(HPBar.BarDrawRect.X, HPBar.BarDrawRect.Y, Animation.FrameSize.X, HPBar.BarDrawRect.Height);
            Animation.DrawColor = rs.DrawColor;
            CenterLocOffset = new Vector2(Animation.FrameSize.X / 2, Animation.FrameSize.Y / 2);
            FeetLocOffset = new Vector2(Animation.FrameSize.X / 2, Animation.FrameSize.Y);
            Armor = rs.Armor;
            m_AABB = RelativeAABB;

            IsFightingWithDefenders = new List<ITargetable>();
            TargettedByDefenders = new List<ITargetable>();

            #region Weapons
            Weapons = new List<BaseWeapon>();
            ShortestWeaponRange = int.MaxValue;
            HasRangedWeapon = false;
            RangedWpnRange = int.MaxValue;
            foreach (WeaponStruct ws in rs.Weapons)
            {
                BaseWeapon w = new BaseWeapon(Common.InvalidVector2, ws, this);
                Weapons.Add(w);
                if (w.IsRanged)
                {
                    HasRangedWeapon = true;
                    if (RangedWpnRange > ws.Range)
                        RangedWpnRange = ws.Range;
                }
                if (ShortestWeaponRange > ws.Range)
                    ShortestWeaponRange = ws.Range;
            }
            #endregion
            HasWeapons = Weapons.Count > 0;

            IsFightingRanged = false;
        }
예제 #2
0
        public static void LoadRunners()
        {
            Runners.Clear();
            string[] enemyXmls = Directory.GetFiles("Data/Enemies", "*.xml");

            foreach (string path in enemyXmls)
            {
                XDocument doc = XDocument.Load(path);

                // ID
                RunnerStruct rs = new RunnerStruct(int.Parse(doc.Root.Element("ID").Value));

                #region Basic
                XElement BasicNode = doc.Root.Element("Basic");
                if (BasicNode != null)
                {
                    XElement basic;

                    basic = BasicNode.Element("HP");
                    if (basic != null)
                    {
                        rs.HP = int.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("HPRegen");
                    if (basic != null)
                    {
                        rs.HPRegen = int.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("Bounty");
                    if (basic != null)
                    {
                        rs.Bounty = int.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("Velocity");
                    if (basic != null)
                    {
                        rs.Velocity = float.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("IsMelee");
                    if (basic != null)
                    {
                        rs.IsMelee = bool.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("IsGround");
                    if (basic != null)
                    {
                        rs.IsGround = bool.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("Recycles");
                    if (basic != null)
                    {
                        rs.Recycles = bool.Parse(basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("Armor");
                    if (basic != null)
                    {
                        rs.Armor = (eArmorType)Enum.Parse(typeof(eArmorType), basic.Value);
                    }
                    basic = null;

                    basic = BasicNode.Element("Name");
                    if (basic != null)
                    {
                        rs.Name = basic.Value;
                    }
                    else
                    {
                        throw new NullReferenceException("The name MUST be supplied. " + path);
                    }
                    basic = null;

                    basic = BasicNode.Element("Animation");
                    if (basic != null)
                    {
                        rs.AnimationType = (eAnimation)Enum.Parse(typeof(eAnimation), basic.Value);
                    }
                    else
                    {
                        throw new NullReferenceException("The animation MUST be supplied. " + path);
                    }
                    basic = null;
                }
                else
                {
                    throw new NullReferenceException("The Basic Node MUST be supplied. " + path);
                }
                #endregion

                #region Immunities
                XElement ImmunitiesNode = doc.Root.Element("Immunities");
                if (ImmunitiesNode != null)
                {
                    XElement immunity;

                    immunity = ImmunitiesNode.Element("Stun");
                    if (immunity != null)
                    {
                        rs.ImmuneStun = bool.Parse(immunity.Value);
                    }
                    immunity = null;

                    immunity = ImmunitiesNode.Element("Slow");
                    if (immunity != null)
                    {
                        rs.ImmuneSlow = bool.Parse(immunity.Value);
                    }
                    immunity = null;

                    immunity = ImmunitiesNode.Element("Rooted");
                    if (immunity != null)
                    {
                        rs.ImmuneRooted = bool.Parse(immunity.Value);
                    }
                    immunity = null;

                    immunity = ImmunitiesNode.Element("ArmorReduction");
                    if (immunity != null)
                    {
                        rs.ImmuneArmorReduction = bool.Parse(immunity.Value);
                    }
                    immunity = null;
                }
                #endregion

                #region Weapons
                XElement wpnMainNode = doc.Root.Element("Weapons");
                if (wpnMainNode != null)
                {
                    foreach (XElement wpnNode in wpnMainNode.Elements())
                    {
                        int      splashValue = 0;
                        XElement splash      = wpnNode.Element("Splash");
                        if (splash != null)
                        {
                            splashValue = int.Parse(splash.Value);
                        }

                        int      splashDmgPercValue = 0;
                        XElement splashDmgPerc      = wpnNode.Element("SplashDmgPercentage");
                        if (splashDmgPerc != null)
                        {
                            splashDmgPercValue = int.Parse(splash.Value);
                        }

                        int      critRateValue = 0;
                        XElement critRate      = wpnNode.Element("CritRate");
                        if (critRate != null)
                        {
                            critRateValue = int.Parse(splash.Value);
                        }

                        eDamageType dmgTypeValue = eDamageType.Normal;
                        XElement    dmgType      = wpnNode.Element("DamageType");
                        if (dmgType != null)
                        {
                            dmgTypeValue = (eDamageType)Enum.Parse(typeof(eDamageType), dmgType.Value);
                        }

                        int      critMultiplierValue = 0;
                        XElement critMultiplier      = wpnNode.Element("CritMultiplier");
                        if (critMultiplier != null)
                        {
                            critMultiplierValue = int.Parse(splash.Value);
                        }

                        XElement    projectileNode = wpnNode.Element("Projectile");
                        eProjectile projectileType;
                        if (projectileNode != null)
                        {
                            projectileType = (eProjectile)Enum.Parse(typeof(eProjectile), projectileNode.Value);
                        }
                        else
                        {
                            projectileType = eProjectile.None;
                        }

                        WeaponStruct ws;
                        if (projectileType != eProjectile.None)
                        {
                            ws = new WeaponStruct(int.Parse(wpnNode.Element("Range").Value), int.Parse(wpnNode.Element("RoF").Value), float.Parse(wpnNode.Element("Damage").Value), projectileType, splashValue, splashDmgPercValue, eAttackableTargets.All)
                            {
                                DamageType = dmgTypeValue
                            }
                        }
                        ;
                        else
                        {
                            ws = new WeaponStruct(int.Parse(wpnNode.Element("Range").Value), int.Parse(wpnNode.Element("RoF").Value), float.Parse(wpnNode.Element("Damage").Value), splashValue, splashDmgPercValue, eAttackableTargets.All)
                            {
                                DamageType = dmgTypeValue
                            }
                        };

                        XElement shootFXNode = wpnNode.Element("ShootFX");
                        if (shootFXNode != null)
                        {
                            ws.ShootFX = int.Parse(shootFXNode.Value);
                        }
                        XElement impactFXNode = wpnNode.Element("ImpactFX");
                        if (impactFXNode != null)
                        {
                            ws.ImpactFX = int.Parse(impactFXNode.Value);
                        }

                        #region Modifiers
                        XElement modifierNode = wpnNode.Element("Stunchance");
                        if (modifierNode != null)
                        {
                            ws.WeaponModifiers.StunChance = int.Parse(modifierNode.Value);
                        }
                        modifierNode = null;
                        modifierNode = wpnNode.Element("Slows");
                        if (modifierNode != null)
                        {
                            ws.WeaponModifiers.Slows = bool.Parse(modifierNode.Value);
                        }
                        modifierNode = null;
                        modifierNode = wpnNode.Element("RootChance");
                        if (modifierNode != null)
                        {
                            ws.WeaponModifiers.RootChance = int.Parse(modifierNode.Value);
                        }
                        modifierNode = null;
                        modifierNode = wpnNode.Element("ArmorReductionValue");
                        if (modifierNode != null)
                        {
                            ws.WeaponModifiers.ArmorReductionValue = int.Parse(modifierNode.Value);
                        }
                        modifierNode = null;
                        #endregion

                        rs.Weapons.Add(ws);
                    }
                }
                #endregion

                Runners.Add(rs);
            }
        }