• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Items.ItemTemplate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WCell.RealmServer.Items.ItemTemplate的典型用法代码示例。如果您正苦于以下问题:C# ItemTemplate类的具体用法?C# ItemTemplate怎么用?C# ItemTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ItemTemplate类属于WCell.RealmServer.Items命名空间,在下文中一共展示了ItemTemplate类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: LootItem

		public LootItem(ItemTemplate templ, int amount, uint index, uint randomPropertyId)
		{
			Template = templ;
			Amount = amount;
			Index = index;
			RandomPropertyId = randomPropertyId;
		}
开发者ID:ray2006,项目名称:WCell,代码行数:7,代码来源:LootItem.cs


示例2: GetHappinessGain

		public int GetHappinessGain(ItemTemplate food)
		{
			if (food == null) return 0;

			// TODO: Replace constants with named Variables
			var diff = (Level - (int)food.Level);
			if (diff > 0)
			{
				if (diff < 16)
				{
					return PetMgr.MaxFeedPetHappinessGain;
				}
				if (diff < 26)
				{
					return (PetMgr.MaxFeedPetHappinessGain / 2);
				}
				if (diff < 36)
				{
					return (PetMgr.MaxFeedPetHappinessGain / 4);
				}
			}
			else
			{
				if (diff > -16)
				{
					return PetMgr.MaxFeedPetHappinessGain;
				}
			}
			return 0;
		}
开发者ID:WCellFR,项目名称:WCellFR,代码行数:30,代码来源:NPC.Pet.cs


示例3: VendorItem

		/// <param name="template">The ItemTemplate for this item.</param>
		/// <param name="numStacksForSale">The maximum number of lots of this item the vendor can sell per period of time. 0xFFFFFFFF means infinite.</param>
		/// <param name="buyStackSize">The vendor sells these items in lots of buyStackSize.</param>
		/// <param name="regenTime">If the vendor has a limited number of this item to sell, this is the time it takes to regen one item.</param>
		public VendorItem( ItemTemplate template, uint numStacksForSale, uint buyStackSize, uint regenTime )
		{
			Template = template;
			this.numStacksForSale = numStacksForSale;
			maxStacksForSale = numStacksForSale;
			BuyStackSize = buyStackSize;

			lastUpdate = DateTime.Now;
			this.regenTime = regenTime;
		}
开发者ID:pallmall,项目名称:WCell,代码行数:14,代码来源:VendorItem.cs


示例4: SendItemNameQueryResponse

		public static void SendItemNameQueryResponse(IPacketReceiver client, ItemTemplate item)
		{
			using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.DefaultName.Length))
			{
				outPacket.WriteInt(item.Id);
				outPacket.WriteCString(item.DefaultName);

				client.Send(outPacket);
			}
		}
开发者ID:Zerant,项目名称:WCell,代码行数:10,代码来源:ItemHandler.cs


示例5: Ensure

		public InventoryError Ensure(ItemTemplate templ, int amount, bool equip)
		{
			if (equip && templ.EquipmentSlots == null)
			{
				return InventoryError.ITEM_CANT_BE_EQUIPPED;
			}

			if (templ.EquipmentSlots != null)
			{
				for (var i = 0; i < templ.EquipmentSlots.Length; i++)
				{
					var slot = templ.EquipmentSlots[i];
					var item = m_Items[(int)slot];
					if (item != null && item.Template.Id == templ.Id)
					{
						// done
						return InventoryError.OK;
					}
				}
			}

			var found = 0;
			if (Iterate(item =>
			{
				if (item.Template == templ)
				{
					found += item.Amount;
					if (equip && !item.IsEquipped)
					{
						TryEquip(this, item.Slot);
						return false;
					}
					else if (found >= amount)
					{
						return false;
					}
				}
				return true;
			}))
			{
				// didn't add everything yet
				amount -= found;
				if (!equip)
				{
					return TryAdd(templ, ref amount);
				}

				var slot = GetEquipSlot(templ, true);
				if (slot == InventorySlot.Invalid)
				{
					return InventoryError.INVENTORY_FULL;
				}
				return TryAdd(templ, slot);
			}
			return InventoryError.OK;
		}
开发者ID:NVN,项目名称:WCell,代码行数:56,代码来源:PlayerInventory.cs


示例6: TryAdd

		/// <summary>
		/// Tries to add a single new item with the given template to the given slot.
		/// Make sure the given targetSlot is valid before calling this method.
		/// </summary>
		public InventoryError TryAdd(ItemTemplate template, EquipmentSlot targetSlot)
		{
			var amount = 1;
			return TryAdd(template, ref amount, (int)targetSlot, true);
		}
开发者ID:NVN,项目名称:WCell,代码行数:9,代码来源:PlayerInventory.cs


示例7: FindFreeSlotCheck

		/// <summary>
		/// Finds a free slot after checking for uniqueness
		/// </summary>
		/// <param name="templ"></param>
		/// <param name="amount"></param>
		/// <returns></returns>
		public SimpleSlotId FindFreeSlotCheck(ItemTemplate templ, int amount)
		{
			var err = InventoryError.OK;
			var possibleAmount = amount;
			CheckUniqueness(templ, ref possibleAmount, ref err, true);
			if (possibleAmount != amount)
			{
				return SimpleSlotId.Default;
			}

			return FindFreeSlot(templ, amount);
		}
开发者ID:ray2006,项目名称:WCell,代码行数:18,代码来源:PlayerInventory.cs


示例8: SendRefundInfo

 private static void SendRefundInfo(IRealmClient client, ItemTemplate item)
 {
     //throw new NotImplementedException();
 }
开发者ID:Zakkgard,项目名称:WCell,代码行数:4,代码来源:ItemHandler.cs


示例9: SendItemPushResult

        /// <summary>
        /// Sends the Item's PushResult (required after adding items).
        /// </summary>
        public static void SendItemPushResult(Character owner, Item item, ItemTemplate templ, int amount, ItemReceptionType reception)
        {
            bool isStacked;
            int contSlot;
            uint propertySeed, randomPropid;
            if (item != null)
            {
                contSlot = item.Container.Slot;
                isStacked = item.Amount != amount; // item.Amount == amount means that it was not added to an existing stack
                propertySeed = item.PropertySeed;
                randomPropid = item.RandomPropertiesId;
            }
            else
            {
                contSlot = BaseInventory.INVALID_SLOT;
                isStacked = true;													// we did not have an item -> stacked
                propertySeed = 0;
                randomPropid = 0;
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_PUSH_RESULT, 45))
            {
                packet.Write(owner.EntityId);
                packet.Write((ulong)reception);

                //packet.Write(received ? 1 : 0);										// 0 = "You looted...", 1 = "You received..."
                //packet.Write(isNew ? 1 : 0);										// 0 = "You received/looted...", 1 = "You created..."

                packet.Write(1);													// log message
                packet.Write((byte)contSlot);
                packet.Write(isStacked ? -1 : item.Slot);
                packet.Write(templ.Id);
                packet.Write(propertySeed);
                packet.Write(randomPropid);
                packet.Write(amount);												// amount added
                packet.Write(owner.Inventory.GetAmount(templ.ItemId));				// amount of that type of item in inventory

                owner.Send(packet);
            }
        }
开发者ID:Zakkgard,项目名称:WCell,代码行数:43,代码来源:ItemHandler.cs


示例10: Distribute

		public override bool Distribute(ItemTemplate template, ref int amount)
		{
			// distribute to ammo
			if (m_ammo != null && m_ammo.Template == template)
			{
				var diff = template.MaxAmount - m_ammo.Amount;
				if (diff > 0)
				{
					if (amount <= diff)
					{
						m_ammo.Amount += amount;
						return true;		// done
					}

					m_ammo.Amount += diff;
					amount -= diff;
				}
			}
			return base.Distribute(template, ref amount);
		}
开发者ID:NVN,项目名称:WCell,代码行数:20,代码来源:PlayerInventory.cs


示例11: SetItem

		/// <summary>
		/// Set the Item at the given slot on this corpse.
		/// </summary>
		public void SetItem(EquipmentSlot slot, ItemTemplate template)
		{
			//var id = (template.DisplayId & 0x00FFFFFF) | (uint)((int)template.InventorySlotType << 24);
			var id = template.DisplayId | (uint)((int)template.InventorySlotType << 24);
			var slotId = (int)CorpseFields.ITEM + (int)slot;
            
            SetUInt32(slotId, id);

			//Array.Copy(characterFields, (int)PlayerFields.VISIBLE_ITEM_1_0,
			//    m_updateValues, (int)CorpseFields.ITEM, EmptyItemFields.Length);

			//if (!m_queuedForUpdate && m_isInWorld)
			//{
			//    RequestUpdate();
			//}
		}
开发者ID:WCellFR,项目名称:WCellFR,代码行数:19,代码来源:Corpse.cs


示例12: ItemStackTemplate

 public ItemStackTemplate(ItemTemplate templ)
     : this(templ, templ.MaxAmount)
 {
 }
开发者ID:ebakkedahl,项目名称:WCell,代码行数:4,代码来源:ItemStacks.cs


示例13: MayAddToContainer

 /// <summary>
 /// For templates of Containers only, checks whether the given
 /// Template may be added
 /// </summary>
 /// <param name="templ"></param>
 /// <returns></returns>
 public bool MayAddToContainer(ItemTemplate templ)
 {
     return BagFamily == 0 || templ.BagFamily.HasAnyFlag(BagFamily);
 }
开发者ID:ebakkedahl,项目名称:WCell,代码行数:10,代码来源:ItemTemplate.cs


示例14: CheckEquippedGems

		internal bool CheckEquippedGems(ItemTemplate gemTempl)
		{
			if (gemTempl != null && gemTempl.Flags.HasFlag(ItemFlags.UniqueEquipped))
			{
				// may only equip a certain maximum of this kind of gem
				for (var slot = EquipmentSlot.Head; slot < EquipmentSlot.Bag1; slot++)
				{
					var item = this[slot];
					if (item != null && item.HasGem(gemTempl.ItemId))
					{
						return false;
					}
				}
			}
			return true;
		}
开发者ID:Jeroz,项目名称:WCell,代码行数:16,代码来源:PlayerInventory.cs


示例15: CreateRecord

		public static ItemRecord CreateRecord(ItemTemplate templ)
		{
			var item = CreateRecord();
			item.EntryId = templ.Id;

			item.Amount = templ.MaxAmount;
			item.Durability = templ.MaxDurability;
			item.Flags = templ.Flags;
			item.ItemTextId = templ.PageTextId;
			item.RandomProperty = (int)(templ.RandomPropertiesId != 0 ? templ.RandomPropertiesId : templ.RandomSuffixId);
			item.RandomSuffix = (int) templ.RandomSuffixId;
			item.Duration = templ.Duration;

			if (templ.UseSpell != null)
			{
				item.Charges = (short)templ.UseSpell.Charges;
			}
			return item;
		}
开发者ID:remixod,项目名称:netServer,代码行数:19,代码来源:ItemRecord.cs


示例16: FindFreeSlotCheck

		/// <summary>
		/// Finds a free slot after checking for uniqueness
		/// </summary>
		/// <param name="templ"></param>
		/// <param name="amount"></param>
		/// <returns></returns>
		public SimpleSlotId FindFreeSlotCheck(ItemTemplate templ, int amount, out InventoryError err)
		{
			err = InventoryError.OK;
			var possibleAmount = amount;
			CheckUniqueness(templ, ref possibleAmount, ref err, true);
			if (possibleAmount != amount)
			{
				return SimpleSlotId.Default;
			}

			var slot = FindFreeSlot(templ, amount);
			if (slot.Slot == INVALID_SLOT)
			{
				err = InventoryError.INVENTORY_FULL;
			}
			return slot;
		}
开发者ID:NVN,项目名称:WCell,代码行数:23,代码来源:PlayerInventory.cs


示例17: SendItemQueryResponse

        public static void SendItemQueryResponse(RealmClient client, ItemTemplate item)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630))
            {
                packet.Write(item.Id);
                packet.WriteInt((int)item.ItemClass);
                packet.WriteInt((int)item.ItemSubClass);
                packet.WriteInt(-1); // unknown

                packet.WriteCString(item.Name);
                packet.WriteByte(0);// name2
                packet.WriteByte(0);// name3
                packet.WriteByte(0);// name4

                packet.WriteInt(item.DisplayId);
                packet.WriteInt((int)item.Quality);
                packet.WriteInt((int)item.Flags);
                packet.WriteInt(item.BuyPrice);
                packet.WriteInt(item.SellPrice);
                packet.WriteInt((int)item.InventorySlot);
                packet.WriteInt((int)item.RequiredClassMask);
                packet.WriteInt((int)item.RequiredRaceMask);
                packet.WriteInt(item.Level);
                packet.WriteInt(item.RequiredLevel);
                packet.WriteInt(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0);
                packet.WriteInt(item.RequiredSkillLevel);
                packet.WriteInt(item.RequiredProfession != null ? (int)item.RequiredProfession.Id : 0);
                packet.WriteInt(item.RequiredPvPRank);
                packet.WriteInt(item.UnknownRank);// city rank?
                packet.WriteInt(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0);
                packet.WriteInt((int)item.RequiredFactionStanding);
                packet.WriteInt(item.UniqueCount);
                packet.WriteInt(item.MaxAmount);
                packet.WriteInt(item.ContainerSlots);
               foreach (var stat in item.Mods)
                {
					packet.WriteUInt((uint)stat.Type);
                    packet.WriteInt(stat.Value);
                }

                foreach (var dmg in item.Damages)
                {
					packet.WriteFloat(dmg.Minimum);
					packet.WriteFloat(dmg.Maximum);
					packet.WriteUInt((uint)dmg.DamageSchool);
                }

                foreach (var res in item.Resistances)
                {
                    packet.WriteUInt(res);
                }

                packet.WriteUInt(item.WeaponSpeed);
				packet.WriteUInt((uint)item.ProjectileType);
                packet.WriteFloat(item.RangeModifier);

                for (int i = 0; i < 5; i++)
                {
					packet.WriteUInt(item.Spells[i].Id);
					packet.WriteUInt((int)item.Spells[i].Trigger);
					packet.WriteUInt(item.Spells[i].Charges);
                    packet.WriteInt(item.Spells[i].Cooldown);
                    packet.WriteUInt(item.Spells[i].CategoryId);
                    packet.WriteInt(item.Spells[i].CategoryCooldown);
                }

				packet.WriteUInt((int)item.BondType);
                packet.WriteCString(item.Description);

				packet.Write(item.PageTextId);
				packet.Write(item.PageCount);
				packet.Write(item.PageMaterial);
				packet.Write(item.QuestId);
				packet.Write(item.RequiredLockpickSkill);
				packet.Write(item.Material);
				packet.Write((uint)item.SheathType);
				packet.Write(item.RandomPropertyId);
				packet.Write(item.RandomSuffixId);
				packet.Write(item.BlockValue);
				packet.Write(item.SetId);
				packet.Write(item.MaxDurability);
				packet.Write((uint)item.ZoneId);
				packet.Write((uint)item.MapId);
				packet.Write((uint)item.BagFamily);
				packet.Write(item.TotemCategory);

				for (int i = 0; i < ItemTemplate.MaxSocketCount; i++)
                {
                    packet.WriteInt(item.Sockets[i].SocketColor);
                    packet.WriteInt(item.Sockets[i].Unknown);
                }
                packet.WriteInt(item.SocketBonusId);
                packet.WriteInt(item.GemProperties);
                packet.WriteInt(item.ExtendedCost);
                packet.WriteInt(item.RequiredArenaRanking);
                packet.WriteInt(item.RequiredDisenchantingLevel);
                packet.WriteFloat(item.ArmorModifier);

                client.Send(packet);
            }
//.........这里部分代码省略.........
开发者ID:KroneckerX,项目名称:WCell,代码行数:101,代码来源:Item.Handlers.cs


示例18: GetPreferredSlot

		/// <summary>
		/// Sets slotId to the slot that the given templ would prefer (if it has any bag preference).
		/// </summary>
		/// <param name="templ"></param>
		/// <param name="slotId"></param>
		public void GetPreferredSlot(ItemTemplate templ, int amount, ref SimpleSlotId slotId)
		{
			if (templ.IsKey)
			{
				slotId.Container = this;
				slotId.Slot = KeyRing.FindFreeSlot();
			}
			else if (!templ.IsContainer && templ.BagFamily != ItemBagFamilyMask.None)
			{
				for (var slot = InventorySlot.Bag1; slot <= InventorySlot.BagLast; slot++)
				{
					var bag = this[slot] as Container;
					if (bag != null && bag.Template.BagFamily != 0)
					{
						var inv = bag.BaseInventory;
						if (bag.Template.MayAddToContainer(templ))
						{
							slotId.Slot = inv.FindFreeSlot();
							if (slotId.Slot != INVALID_SLOT)
							{
								slotId.Container = inv;
								break;
							}
						}
					}
				}
			}
		}
开发者ID:NVN,项目名称:WCell,代码行数:33,代码来源:PlayerInventory.cs


示例19: AddItem

			public static bool AddItem(Character chr, ItemTemplate templ, int amount, bool autoEquip, bool ensureOnly)
			{
				var actualAmount = amount;
				var inv = chr.Inventory;

				InventoryError err;
				if (ensureOnly)
				{
					// only add if necessary
					err = inv.Ensure(templ, amount, autoEquip);
				}
				else
				{
					if (autoEquip)
					{
						// auto-equip
						var slot = inv.GetEquipSlot(templ, true);
						if (slot == InventorySlot.Invalid)
						{
							err = InventoryError.INVENTORY_FULL;
						}
						else
						{
							err = inv.TryAdd(templ, slot);
						}
					}
					else
					{
						// just add
						err = inv.TryAdd(templ, ref amount);
					}
				}

				if (err != InventoryError.OK || amount < actualAmount)
				{
					// something went wrong
					if (err != InventoryError.OK)
					{
						ItemHandler.SendInventoryError(chr.Client, null, null, err);
					}
					return false;
				}
				return true;
			}
开发者ID:KroneckerX,项目名称:WCell,代码行数:44,代码来源:ItemCommands.cs


示例20: EnsureItem

		/// <summary>
		/// Adds a new default Item to the given slot, if not already existing
		/// </summary>
		public Item EnsureItem(ItemTemplate template, int amount)
		{
			var slotId = m_inventory.FindFreeSlot(template, amount);
			Assert.AreNotEqual(BaseInventory.INVALID_SLOT, slotId.Slot);

			var item = slotId.Container.AddUnchecked(slotId.Slot, template, amount, true);
			Assert.IsTrue(item.IsInWorld);
			return item;
		}
开发者ID:MeaNone,项目名称:WCell,代码行数:12,代码来源:TestCharacter.cs



注:本文中的WCell.RealmServer.Items.ItemTemplate类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Misc.DamageAction类代码示例发布时间:2022-05-26
下一篇:
C# Global.Map类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap