public HeroInBattle(Battle b, Creature ph, Point coord, bool needImage) { Battle = b; CurrentTile = b.Battlefield.Tiles[coord.Y, coord.X]; PlayerHero = ph; IsLive = true; Parameters = new HeroParameters(ph.ParametersWithAmmunition); Debug.Assert(Parameters.Health > 0); Debug.Assert(Parameters.Mana > 0); Debug.Assert(Parameters.Stamina > 0); CurrentHealth = Parameters.Health; CurrentMana = Parameters.Mana; CurrentStamina = Parameters.Stamina; State = StateHeroInBattle.None; QuantityArrows = ph.TypeCreature.QuantityArrows; LastTarget = default; if (needImage) { bmpIconOriginal = new Bitmap(Program.formMain.bmpBorderForIcon.Size.Width, Program.formMain.bmpBorderForIcon.Size.Height); brushBandHealth = new SolidBrush(FormMain.Config.UnitHealth); brushBandHealthNone = new SolidBrush(FormMain.Config.UnitHealthNone); needRedraw = true; } }
} // Сколько шагов боя герой уже воскрешается internal void GetFromParams(HeroParameters hp) { Strength = hp.Strength; Dexterity = hp.Dexterity; Magic = hp.Magic; Vitality = hp.Vitality; CoefHealth = hp.CoefHealth; CoefMana = hp.CoefMana; CoefStamina = hp.CoefStamina; Health = hp.Health; Mana = hp.Mana; Stamina = hp.Stamina; }
private static int sequenceID = 0;// Генератор уникального кода героя public Creature(TypeCreature tc, BattleParticipant bp) { TypeCreature = tc; BattleParticipant = bp; ID = ++sequenceID; StateCreature = TypeCreature.PersistentStateHeroAtMap; // Применяем дефолтные способности Abilities.AddRange(TypeCreature.Abilities); Specialization = FormMain.Config.FindSpecialization("SpeedMove"); SecondarySkills.Add(FormMain.Config.FindSecondarySkill("Health")); // Берем оружие и доспехи MeleeWeapon = TypeCreature.WeaponMelee; RangeWeapon = TypeCreature.WeaponRange; Armour = TypeCreature.Armour; if (TypeCreature.MaxLevel > 1) { Level = 0; ParametersBase = new HeroParameters(TypeCreature.ParametersByHire); // Переходим на 1 уровень LevelUp(); ParametersWithAmmunition = new HeroParameters(ParametersBase); // UpdateBaseParameters(); } else { Level = 1; } }
public TypeCreature(XmlNode n) : base(n) { KindCreature = FormMain.Config.FindKindCreature(XmlUtils.GetStringNotNull(n.SelectSingleNode("KindCreature"))); MaxLevel = XmlUtils.GetInteger(n.SelectSingleNode("MaxLevel")); DefaultPositionPriority = XmlUtils.GetInteger(n.SelectSingleNode("DefaultPositionPriority")); Reward = XmlUtils.GetInteger(n.SelectSingleNode("Reward")); QuantityArrows = XmlUtils.GetInteger(n.SelectSingleNode("QuantityArrows")); DamageToCastle = XmlUtils.GetInteger(n.SelectSingleNode("DamageToCastle")); if (n.SelectSingleNode("PersistentState") != null) { PersistentStateHeroAtMap = FormMain.Config.FindStateCreature(XmlUtils.GetStringNotNull(n.SelectSingleNode("PersistentState"))); } else { PersistentStateHeroAtMap = FormMain.Config.FindStateCreature(NameStateCreature.Nothing.ToString()); } Debug.Assert(MaxLevel >= 1); Debug.Assert(MaxLevel <= 100); Debug.Assert(DefaultPositionPriority >= 0); Debug.Assert(DefaultPositionPriority <= 1000); Debug.Assert(Reward >= 0); Debug.Assert(Reward <= 1000); Debug.Assert(DamageToCastle >= 0); // Загружаем основные параметры if (n.SelectSingleNode("BaseParameters") != null) { ParametersByHire = new HeroParameters(n.SelectSingleNode("BaseParameters")); // if (n.SelectSingleNode("NextLevel") != null) { ConfigNextLevel = new ConfigNextLevelHero(n.SelectSingleNode("NextLevel")); } } // Загружаем дефолтные способности XmlNode na = n.SelectSingleNode("Abilities"); if (na != null) { Ability a; foreach (XmlNode l in na.SelectNodes("Ability")) { a = FormMain.Config.FindAbility(l.InnerText); // Проверяем, что такая способность не повторяется foreach (Ability a2 in Abilities) { if (a.ID == a2.ID) { throw new Exception("Способность " + a.ID + " повторяется в списке способностей героя."); } } Abilities.Add(a); } } // Загружаем дефолтное оружие и доспехи nameMeleeWeapon = XmlUtils.GetString(n.SelectSingleNode("MeleeWeapon")); nameRangeWeapon = XmlUtils.GetString(n.SelectSingleNode("RangeWeapon")); nameArmour = XmlUtils.GetString(n.SelectSingleNode("Armour")); //Debug.Assert(nameMeleeWeapon != ""); //Debug.Assert(nameArmour != ""); if (nameRangeWeapon.Length > 0) { Debug.Assert(QuantityArrows > 0); } else { Debug.Assert(QuantityArrows == 0); } }
public HeroParameters(HeroParameters mp) { GetFromParams(mp); }