/// <summary> /// Creates an ItemEntity on the map. /// </summary> /// <param name="template">ItemTemplate to create the characterID from.</param> /// <param name="pos">Position to create the characterID at.</param> /// <param name="amount">Amount of the characterID to create. Must be greater than 0.</param> /// <returns>Reference to the new ItemEntity created.</returns> public ItemEntity CreateItem(IItemTemplateTable template, Vector2 pos, byte amount) { // Check for a valid amount if (amount < 1) { const string errmsg = "Invalid characterID amount `{0}`! Amount must be > 0."; Debug.Fail(string.Format(errmsg, amount)); if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, amount); } return(null); } // Check for a valid template if (template == null) { const string errmsg = "Parameter `template` may not be null!"; Debug.Fail(errmsg); if (log.IsErrorEnabled) { log.Error(errmsg); } return(null); } // Create the characterID, add it to the map, and return the reference var item = new ItemEntity(template, pos, amount); AddEntity(item); return(item); }
/// <summary> /// Checks if this <see cref="IItemTemplateTable"/> contains the same values as another <see cref="IItemTemplateTable"/>. /// </summary> /// <param name="source">The source <see cref="IItemTemplateTable"/>.</param> /// <param name="otherItem">The <see cref="IItemTemplateTable"/> to compare the values to.</param> /// <returns> /// True if this <see cref="IItemTemplateTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false. /// </returns> public static System.Boolean HasSameValues(this IItemTemplateTable source, IItemTemplateTable otherItem) { return(Equals(source.ActionDisplayID, otherItem.ActionDisplayID) && Equals(source.Description, otherItem.Description) && Equals(source.EquippedBody, otherItem.EquippedBody) && Equals(source.Graphic, otherItem.Graphic) && Equals(source.Height, otherItem.Height) && Equals(source.HP, otherItem.HP) && Equals(source.ID, otherItem.ID) && Equals(source.MP, otherItem.MP) && Equals(source.Name, otherItem.Name) && Equals(source.Range, otherItem.Range) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Int), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Int)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)) && Equals(source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi), otherItem.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi)) && Equals(source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int), otherItem.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int)) && Equals(source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str), otherItem.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str)) && Equals(source.GetStat((DemoGame.StatType)DemoGame.StatType.Str), otherItem.GetStat((DemoGame.StatType)DemoGame.StatType.Str)) && Equals(source.Type, otherItem.Type) && Equals(source.Value, otherItem.Value) && Equals(source.WeaponType, otherItem.WeaponType) && Equals(source.Width, otherItem.Width)); }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTemplateTable source, IDictionary <String, Object> dic) { dic["action_display_id"] = source.ActionDisplayID; dic["description"] = source.Description; dic["equipped_body"] = source.EquippedBody; dic["graphic"] = source.Graphic; dic["height"] = source.Height; dic["hp"] = source.HP; dic["id"] = source.ID; dic["mp"] = source.MP; dic["name"] = source.Name; dic["range"] = source.Range; dic["stat_agi"] = (Int16)source.GetStat(StatType.Agi); dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence); dic["stat_int"] = (Int16)source.GetStat(StatType.Int); dic["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit); dic["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP); dic["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP); dic["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit); dic["stat_req_agi"] = (Int16)source.GetReqStat(StatType.Agi); dic["stat_req_int"] = (Int16)source.GetReqStat(StatType.Int); dic["stat_req_str"] = (Int16)source.GetReqStat(StatType.Str); dic["stat_str"] = (Int16)source.GetStat(StatType.Str); dic["type"] = source.Type; dic["value"] = source.Value; dic["weapon_type"] = source.WeaponType; dic["width"] = source.Width; }
/// <summary> /// Creates the <see cref="StyledText"/> lines needed to display the information for an item. /// </summary> /// <param name="itemInfo">The item information to create the <see cref="StyledText"/> lines for.</param> /// <returns>The <see cref="StyledText"/> lines needed to display the information for the <paramref name="itemInfo"/>.</returns> public static StyledText[] GetStyledText(IItemTemplateTable itemInfo) { if (itemInfo == null) return StyledText.EmptyArray; return GetStyledText(itemInfo.Name, itemInfo.Description, itemInfo.Value, itemInfo.HP, itemInfo.MP, itemInfo.Stats, itemInfo.ReqStats); }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTemplateTable source, System.Collections.Generic.IDictionary <System.String, System.Object> dic) { dic["action_display_id"] = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; dic["description"] = (System.String)source.Description; dic["equipped_body"] = (System.String)source.EquippedBody; dic["graphic"] = (NetGore.GrhIndex)source.Graphic; dic["height"] = (System.Byte)source.Height; dic["hp"] = (DemoGame.SPValueType)source.HP; dic["id"] = (DemoGame.ItemTemplateID)source.ID; dic["mp"] = (DemoGame.SPValueType)source.MP; dic["name"] = (System.String)source.Name; dic["range"] = (System.UInt16)source.Range; dic["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence); dic["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit); dic["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP); dic["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP); dic["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit); dic["stat_req_agi"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_req_int"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_req_str"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str); dic["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str); dic["type"] = (DemoGame.ItemType)source.Type; dic["value"] = (System.Int32)source.Value; dic["weapon_type"] = (DemoGame.WeaponType)source.WeaponType; dic["width"] = (System.Byte)source.Width; }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this ItemTemplateTable. /// </summary> /// <param name="source">The IItemTemplateTable to copy the values from.</param> public void CopyValuesFrom(IItemTemplateTable source) { this.ActionDisplayID = (System.Nullable <NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; this.Description = (System.String)source.Description; this.EquippedBody = (System.String)source.EquippedBody; this.Graphic = (NetGore.GrhIndex)source.Graphic; this.Height = (System.Byte)source.Height; this.HP = (DemoGame.SPValueType)source.HP; this.ID = (DemoGame.ItemTemplateID)source.ID; this.MP = (DemoGame.SPValueType)source.MP; this.Name = (System.String)source.Name; this.Range = (System.UInt16)source.Range; this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str)); this.Type = (DemoGame.ItemType)source.Type; this.Value = (System.Int32)source.Value; this.WeaponType = (DemoGame.WeaponType)source.WeaponType; this.Width = (System.Byte)source.Width; }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this ItemTemplateTable. /// </summary> /// <param name="source">The IItemTemplateTable to copy the values from.</param> public void CopyValuesFrom(IItemTemplateTable source) { ActionDisplayID = source.ActionDisplayID; Description = source.Description; EquippedBody = source.EquippedBody; Graphic = source.Graphic; Height = source.Height; HP = source.HP; ID = source.ID; MP = source.MP; Name = source.Name; Range = source.Range; SetStat(StatType.Agi, source.GetStat(StatType.Agi)); SetStat(StatType.Defence, source.GetStat(StatType.Defence)); SetStat(StatType.Int, source.GetStat(StatType.Int)); SetStat(StatType.MaxHit, source.GetStat(StatType.MaxHit)); SetStat(StatType.MaxHP, source.GetStat(StatType.MaxHP)); SetStat(StatType.MaxMP, source.GetStat(StatType.MaxMP)); SetStat(StatType.MinHit, source.GetStat(StatType.MinHit)); SetReqStat(StatType.Agi, source.GetReqStat(StatType.Agi)); SetReqStat(StatType.Int, source.GetReqStat(StatType.Int)); SetReqStat(StatType.Str, source.GetReqStat(StatType.Str)); SetStat(StatType.Str, source.GetStat(StatType.Str)); Type = source.Type; Value = source.Value; WeaponType = source.WeaponType; Width = source.Width; }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The keys must already exist in the DbParameterValues; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void CopyValues(this IItemTemplateTable source, NetGore.Db.DbParameterValues paramValues) { paramValues["action_display_id"] = (System.Nullable <System.UInt16>)source.ActionDisplayID; paramValues["description"] = (System.String)source.Description; paramValues["equipped_body"] = (System.String)source.EquippedBody; paramValues["graphic"] = (System.UInt16)source.Graphic; paramValues["height"] = (System.Byte)source.Height; paramValues["hp"] = (System.Int16)source.HP; paramValues["id"] = (System.UInt16)source.ID; paramValues["mp"] = (System.Int16)source.MP; paramValues["name"] = (System.String)source.Name; paramValues["range"] = (System.UInt16)source.Range; paramValues["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi); paramValues["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence); paramValues["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int); paramValues["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit); paramValues["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP); paramValues["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP); paramValues["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit); paramValues["stat_req_agi"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi); paramValues["stat_req_int"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int); paramValues["stat_req_str"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str); paramValues["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str); paramValues["type"] = (System.Byte)source.Type; paramValues["value"] = (System.Int32)source.Value; paramValues["weapon_type"] = (System.Byte)source.WeaponType; paramValues["width"] = (System.Byte)source.Width; }
/// <summary> /// Creates the <see cref="StyledText"/> lines needed to display the information for an item. /// </summary> /// <param name="itemInfo">The item information to create the <see cref="StyledText"/> lines for.</param> /// <returns>The <see cref="StyledText"/> lines needed to display the information for the <paramref name="itemInfo"/>.</returns> public static StyledText[] GetStyledText(IItemTemplateTable itemInfo) { if (itemInfo == null) { return(StyledText.EmptyArray); } return(GetStyledText(itemInfo.Name, itemInfo.Description, itemInfo.Value, itemInfo.HP, itemInfo.MP, itemInfo.Stats, itemInfo.ReqStats)); }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="t">The item template to copy the initial values from.</param> /// <param name="pos">The world position of the item.</param> /// <param name="amount">The amount of the item.</param> /// <param name="map">The map the item is to spawn on.</param> public ItemEntity(IItemTemplateTable t, Vector2 pos, byte amount, MapBase map) : this(t, pos, amount) { // Since the item is spawning on a map, ensure that the position is valid for the map var validPos = ValidatePosition(map, pos); if (!IsDisposed) { Teleport(validPos); map.AddEntity(this); } }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="t">The item template to copy the initial values from.</param> /// <param name="pos">The world position of the item.</param> /// <param name="amount">The amount of the item.</param> public ItemEntity(IItemTemplateTable t, Vector2 pos, byte amount) : this( pos, new Vector2(t.Width, t.Height), t.ID, t.Name, t.Description, t.Type, t.WeaponType, t.Range, t.Graphic, t.Value, amount, t.HP, t.MP, t.EquippedBody, t.ActionDisplayID, t.Stats.Select(x => (Stat <StatType>)x), t.ReqStats.Select(x => (Stat <StatType>)x)) { if (ItemTemplateID.HasValue) { WorldStatsTracker.Instance.AddCountCreateItem((int)ItemTemplateID, amount); EventCounterManager.ItemTemplate.Increment(ItemTemplateID.Value, ItemTemplateEventCounterType.Create, amount); } }
public CharacterTemplateInventoryItem(IItemTemplateTable itemTemplate, byte min, byte max, ItemChance chance) { if (min > max) { var tmp = min; min = max; max = tmp; Debug.Fail("min was less than max. Swapped to fix the problem, but could indicate a problem elsewhere."); } ItemTemplate = itemTemplate; Min = min; Max = max; Chance = chance; }
/// <summary> /// Checks if this <see cref="IItemTemplateTable"/> contains the same values as another <see cref="IItemTemplateTable"/>. /// </summary> /// <param name="source">The source <see cref="IItemTemplateTable"/>.</param> /// <param name="otherItem">The <see cref="IItemTemplateTable"/> to compare the values to.</param> /// <returns> /// True if this <see cref="IItemTemplateTable"/> contains the same values as the <paramref name="otherItem"/>; otherwise false. /// </returns> public static Boolean HasSameValues(this IItemTemplateTable source, IItemTemplateTable otherItem) { return Equals(source.ActionDisplayID, otherItem.ActionDisplayID) && Equals(source.Description, otherItem.Description) && Equals(source.EquippedBody, otherItem.EquippedBody) && Equals(source.Graphic, otherItem.Graphic) && Equals(source.Height, otherItem.Height) && Equals(source.HP, otherItem.HP) && Equals(source.ID, otherItem.ID) && Equals(source.MP, otherItem.MP) && Equals(source.Name, otherItem.Name) && Equals(source.Range, otherItem.Range) && Equals(source.GetStat(StatType.Agi), otherItem.GetStat(StatType.Agi)) && Equals(source.GetStat(StatType.Defence), otherItem.GetStat(StatType.Defence)) && Equals(source.GetStat(StatType.Int), otherItem.GetStat(StatType.Int)) && Equals(source.GetStat(StatType.MaxHit), otherItem.GetStat(StatType.MaxHit)) && Equals(source.GetStat(StatType.MaxHP), otherItem.GetStat(StatType.MaxHP)) && Equals(source.GetStat(StatType.MaxMP), otherItem.GetStat(StatType.MaxMP)) && Equals(source.GetStat(StatType.MinHit), otherItem.GetStat(StatType.MinHit)) && Equals(source.GetReqStat(StatType.Agi), otherItem.GetReqStat(StatType.Agi)) && Equals(source.GetReqStat(StatType.Int), otherItem.GetReqStat(StatType.Int)) && Equals(source.GetReqStat(StatType.Str), otherItem.GetReqStat(StatType.Str)) && Equals(source.GetStat(StatType.Str), otherItem.GetStat(StatType.Str)) && Equals(source.Type, otherItem.Type) && Equals(source.Value, otherItem.Value) && Equals(source.WeaponType, otherItem.WeaponType) && Equals(source.Width, otherItem.Width); }
void RecvStartShopping(IIPSocket conn, BitStream r) { var shopOwnerIndex = r.ReadMapEntityIndex(); var canBuy = r.ReadBool(); var name = r.ReadString(); var itemCount = r.ReadByte(); var items = new IItemTemplateTable[itemCount]; for (var i = 0; i < itemCount; i++) { var value = new ItemTemplateTable(); value.ReadState(r); items[i] = value; } var shopOwner = Map.GetDynamicEntity(shopOwnerIndex); var shopInfo = new ShopInfo <IItemTemplateTable>(shopOwner, name, canBuy, items); GameplayScreen.ShopForm.DisplayShop(shopInfo); }
/// <summary> /// Initializes a new instance of the <see cref="QuestItemTemplateAmount"/> struct. /// </summary> /// <param name="itemTemplate">The item template.</param> /// <param name="amount">The amount.</param> public QuestItemTemplateAmount(IItemTemplateTable itemTemplate, byte amount) { _itemTemplate = itemTemplate; _amount = amount; }
/// <summary> /// Initializes a new instance of the <see cref="ItemTemplateTable"/> class. /// </summary> /// <param name="source">IItemTemplateTable to copy the initial values from.</param> public ItemTemplateTable(IItemTemplateTable source) { CopyValuesFrom(source); }
/// <summary> /// Copies the values from the given <paramref name="source"/> into this ItemTemplateTable. /// </summary> /// <param name="source">The IItemTemplateTable to copy the values from.</param> public void CopyValuesFrom(IItemTemplateTable source) { this.ActionDisplayID = (System.Nullable<NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; this.Description = (System.String)source.Description; this.EquippedBody = (System.String)source.EquippedBody; this.Graphic = (NetGore.GrhIndex)source.Graphic; this.Height = (System.Byte)source.Height; this.HP = (DemoGame.SPValueType)source.HP; this.ID = (DemoGame.ItemTemplateID)source.ID; this.MP = (DemoGame.SPValueType)source.MP; this.Name = (System.String)source.Name; this.Range = (System.UInt16)source.Range; this.SetStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Defence, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxHP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MaxMP, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP)); this.SetStat((DemoGame.StatType)DemoGame.StatType.MinHit, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Agi, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Int, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int)); this.SetReqStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str)); this.SetStat((DemoGame.StatType)DemoGame.StatType.Str, (System.Int32)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str)); this.Type = (DemoGame.ItemType)source.Type; this.Value = (System.Int32)source.Value; this.WeaponType = (DemoGame.WeaponType)source.WeaponType; this.Width = (System.Byte)source.Width; }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTemplateTable source, System.Collections.Generic.IDictionary<System.String,System.Object> dic) { dic["action_display_id"] = (System.Nullable<NetGore.Features.ActionDisplays.ActionDisplayID>)source.ActionDisplayID; dic["description"] = (System.String)source.Description; dic["equipped_body"] = (System.String)source.EquippedBody; dic["graphic"] = (NetGore.GrhIndex)source.Graphic; dic["height"] = (System.Byte)source.Height; dic["hp"] = (DemoGame.SPValueType)source.HP; dic["id"] = (DemoGame.ItemTemplateID)source.ID; dic["mp"] = (DemoGame.SPValueType)source.MP; dic["name"] = (System.String)source.Name; dic["range"] = (System.UInt16)source.Range; dic["stat_agi"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_defence"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence); dic["stat_int"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_maxhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit); dic["stat_maxhp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP); dic["stat_maxmp"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP); dic["stat_minhit"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit); dic["stat_req_agi"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi); dic["stat_req_int"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int); dic["stat_req_str"] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str); dic["stat_str"] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str); dic["type"] = (DemoGame.ItemType)source.Type; dic["value"] = (System.Int32)source.Value; dic["weapon_type"] = (DemoGame.WeaponType)source.WeaponType; dic["width"] = (System.Byte)source.Width; }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="t">The item template to copy the initial values from.</param> /// <param name="amount">The amount of the item.</param> public ItemEntity(IItemTemplateTable t, byte amount) : this(t, Vector2.Zero, amount) { }
/// <summary> /// Initializes a new instance of the <see cref="ItemEntity"/> class. /// </summary> /// <param name="t">The item template to copy the initial values from.</param> /// <param name="pos">The world position of the item.</param> /// <param name="amount">The amount of the item.</param> public ItemEntity(IItemTemplateTable t, Vector2 pos, byte amount) : this( pos, new Vector2(t.Width, t.Height), t.ID, t.Name, t.Description, t.Type, t.WeaponType, t.Range, t.Graphic, t.Value, amount, t.HP, t.MP, t.EquippedBody, t.ActionDisplayID, t.Stats.Select(x => (Stat<StatType>)x), t.ReqStats.Select(x => (Stat<StatType>)x)) { if (ItemTemplateID.HasValue) { WorldStatsTracker.Instance.AddCountCreateItem((int)ItemTemplateID, amount); EventCounterManager.ItemTemplate.Increment(ItemTemplateID.Value, ItemTemplateEventCounterType.Create, amount); } }
/// <summary> /// Copies the column values into the given Dictionary using the database column name /// with a prefixed @ as the key. The keys must already exist in the Dictionary; /// this method will not create them if they are missing. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="dic">The Dictionary to copy the values into.</param> public static void CopyValues(IItemTemplateTable source, IDictionary<String, Object> dic) { dic["action_display_id"] = source.ActionDisplayID; dic["description"] = source.Description; dic["equipped_body"] = source.EquippedBody; dic["graphic"] = source.Graphic; dic["height"] = source.Height; dic["hp"] = source.HP; dic["id"] = source.ID; dic["mp"] = source.MP; dic["name"] = source.Name; dic["range"] = source.Range; dic["stat_agi"] = (Int16)source.GetStat(StatType.Agi); dic["stat_defence"] = (Int16)source.GetStat(StatType.Defence); dic["stat_int"] = (Int16)source.GetStat(StatType.Int); dic["stat_maxhit"] = (Int16)source.GetStat(StatType.MaxHit); dic["stat_maxhp"] = (Int16)source.GetStat(StatType.MaxHP); dic["stat_maxmp"] = (Int16)source.GetStat(StatType.MaxMP); dic["stat_minhit"] = (Int16)source.GetStat(StatType.MinHit); dic["stat_req_agi"] = (Int16)source.GetReqStat(StatType.Agi); dic["stat_req_int"] = (Int16)source.GetReqStat(StatType.Int); dic["stat_req_str"] = (Int16)source.GetReqStat(StatType.Str); dic["stat_str"] = (Int16)source.GetStat(StatType.Str); dic["type"] = source.Type; dic["value"] = source.Value; dic["weapon_type"] = source.WeaponType; dic["width"] = source.Width; }
/// <summary> /// Creates an ItemEntity on the map. /// </summary> /// <param name="template">ItemTemplate to create the characterID from.</param> /// <param name="pos">Position to create the characterID at.</param> /// <param name="amount">Amount of the characterID to create. Must be greater than 0.</param> /// <returns>Reference to the new ItemEntity created.</returns> public ItemEntity CreateItem(IItemTemplateTable template, Vector2 pos, byte amount) { // Check for a valid amount if (amount < 1) { const string errmsg = "Invalid characterID amount `{0}`! Amount must be > 0."; Debug.Fail(string.Format(errmsg, amount)); if (log.IsErrorEnabled) log.ErrorFormat(errmsg, amount); return null; } // Check for a valid template if (template == null) { const string errmsg = "Parameter `template` may not be null!"; Debug.Fail(errmsg); if (log.IsErrorEnabled) log.Error(errmsg); return null; } // Create the characterID, add it to the map, and return the reference var item = new ItemEntity(template, pos, amount); AddEntity(item); return item; }
/// <summary> /// Makes the Character drop an item. Does not modify the item requested to drop at all or anything, /// so if you want to also remove the item, such as with dropping an item from the Inventory, /// this will not take care of that. /// </summary> /// <param name="itemTemplate">ItemTemplate for the item to drop.</param> /// <param name="amount">Amount of the item to drop.</param> protected void DropItem(IItemTemplateTable itemTemplate, byte amount) { if (itemTemplate == null) { const string errmsg = "`{0}` tried to drop null item template."; if (log.IsErrorEnabled) log.ErrorFormat(errmsg, this); return; } var dropPos = GetDropPos(); // Create the item on the map var droppedItem = Map.CreateItem(itemTemplate, dropPos, amount); OnDroppedItem(droppedItem); if (DroppedItem != null) DroppedItem.Raise(this, EventArgsHelper.Create(droppedItem)); }
public CharacterTemplateEquipmentItem(IItemTemplateTable itemTemplate, ItemChance chance) { ItemTemplate = itemTemplate; Chance = chance; }
/// <summary> /// Copies the column values into the given DbParameterValues using the database column name /// with a prefixed @ as the key. The key must already exist in the DbParameterValues /// for the value to be copied over. If any of the keys in the DbParameterValues do not /// match one of the column names, or if there is no field for a key, then it will be /// ignored. Because of this, it is important to be careful when using this method /// since columns or keys can be skipped without any indication. /// </summary> /// <param name="source">The object to copy the values from.</param> /// <param name="paramValues">The DbParameterValues to copy the values into.</param> public static void TryCopyValues(this IItemTemplateTable source, NetGore.Db.DbParameterValues paramValues) { for (int i = 0; i < paramValues.Count; i++) { switch (paramValues.GetParameterName(i)) { case "action_display_id": paramValues[i] = (System.Nullable <System.UInt16>)source.ActionDisplayID; break; case "description": paramValues[i] = (System.String)source.Description; break; case "equipped_body": paramValues[i] = (System.String)source.EquippedBody; break; case "graphic": paramValues[i] = (System.UInt16)source.Graphic; break; case "height": paramValues[i] = (System.Byte)source.Height; break; case "hp": paramValues[i] = (System.Int16)source.HP; break; case "id": paramValues[i] = (System.UInt16)source.ID; break; case "mp": paramValues[i] = (System.Int16)source.MP; break; case "name": paramValues[i] = (System.String)source.Name; break; case "range": paramValues[i] = (System.UInt16)source.Range; break; case "stat_agi": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Agi); break; case "stat_defence": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Defence); break; case "stat_int": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Int); break; case "stat_maxhit": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHit); break; case "stat_maxhp": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxHP); break; case "stat_maxmp": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MaxMP); break; case "stat_minhit": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.MinHit); break; case "stat_req_agi": paramValues[i] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Agi); break; case "stat_req_int": paramValues[i] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Int); break; case "stat_req_str": paramValues[i] = (System.Int16)source.GetReqStat((DemoGame.StatType)DemoGame.StatType.Str); break; case "stat_str": paramValues[i] = (System.Int16)source.GetStat((DemoGame.StatType)DemoGame.StatType.Str); break; case "type": paramValues[i] = (System.Byte)source.Type; break; case "value": paramValues[i] = (System.Int32)source.Value; break; case "weapon_type": paramValues[i] = (System.Byte)source.WeaponType; break; case "width": paramValues[i] = (System.Byte)source.Width; break; } } }
void RecvStartShopping(IIPSocket conn, BitStream r) { var shopOwnerIndex = r.ReadMapEntityIndex(); var canBuy = r.ReadBool(); var name = r.ReadString(); var itemCount = r.ReadByte(); var items = new IItemTemplateTable[itemCount]; for (var i = 0; i < itemCount; i++) { var value = new ItemTemplateTable(); value.ReadState(r); items[i] = value; } var shopOwner = Map.GetDynamicEntity(shopOwnerIndex); var shopInfo = new ShopInfo<IItemTemplateTable>(shopOwner, name, canBuy, items); GameplayScreen.ShopForm.DisplayShop(shopInfo); }