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

C# eInventorySlot类代码示例

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

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



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

示例1: GetValidInventorySlot

		/// <summary>
		/// Check if the slot is valid in the inventory
		/// </summary>
		/// <param name="slot">SlotPosition to check</param>
		/// <returns>the slot if it's valid or eInventorySlot.Invalid if not</returns>
		protected override eInventorySlot GetValidInventorySlot(eInventorySlot slot)
		{
			foreach (eInventorySlot visibleSlot in VISIBLE_SLOTS)
				if (visibleSlot == slot)
					return slot;
			return eInventorySlot.Invalid;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:12,代码来源:GameNpcInventoryTemplate.cs


示例2: SwitchItem

        public void SwitchItem(GamePlayer player, eInventorySlot ToSlot, eInventorySlot FromSlot)
        {
            if (player.Inventory.GetItem(FromSlot) != null)
            {
                InventoryItem item = player.Inventory.GetItem(FromSlot);

                if (!GlobalConstants.IsWeapon(item.Object_Type))
                {
                    DisplayMessage(player.Client, "That is not a weapon!");
                    DisplaySyntax(player.Client);
                    return;
                }

                if (!player.Inventory.MoveItem(FromSlot, ToSlot, 1))
                {
                    DisplayMessage(player.Client, "There seems to have been a problem. Please try again.");
                    DisplaySyntax(player.Client);
                    return;
                }
            }
        }
开发者ID:uvbs,项目名称:Dawn-of-Light-core,代码行数:21,代码来源:SwitchCommandHandler.cs


示例3: MoveItem

		/// <summary>
		/// Overridden. Inventory template cannot be modified.
		/// </summary>
		/// <param name="fromSlot"></param>
		/// <param name="toSlot"></param>
		/// <param name="itemCount"></param>
		/// <returns></returns>
		public override bool MoveItem(eInventorySlot fromSlot, eInventorySlot toSlot, int itemCount)
		{
			return false;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:11,代码来源:GameNpcInventoryTemplate.cs


示例4: MoveItem

		/// <summary>
		/// Exchange two Items in form specified slot
		/// </summary>
		/// <param name="fromSlot">Source slot</param>
		/// <param name="toSlot">Destination slot</param>
		/// <param name="itemCount"></param>
		/// <returns>true if successfull false if not</returns>
		public virtual bool MoveItem(eInventorySlot fromSlot, eInventorySlot toSlot, int itemCount)
		{
			lock (m_items) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				fromSlot = GetValidInventorySlot(fromSlot);
				toSlot = GetValidInventorySlot(toSlot);
				if (fromSlot == eInventorySlot.Invalid || toSlot == eInventorySlot.Invalid)
					return false;

				InventoryItem fromItem;
				InventoryItem toItem;

				m_items.TryGetValue(fromSlot, out fromItem);
				m_items.TryGetValue(toSlot, out toItem);

				if (!CombineItems(fromItem, toItem) && !StackItems(fromSlot, toSlot, itemCount))
				{
					ExchangeItems(fromSlot, toSlot);
				}

				if (!m_changedSlots.Contains(fromSlot))
					m_changedSlots.Add(fromSlot);

				if (!m_changedSlots.Contains(toSlot))
					m_changedSlots.Add(toSlot);

				if (m_changesCounter <= 0)
					UpdateChangedSlots();

				return true;
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:39,代码来源:GameLivingInventory.cs


示例5: AddTradeItem

		public virtual bool AddTradeItem(eInventorySlot slot, InventoryItem item)
		{
			return false;
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:4,代码来源:GameLivingInventory.cs


示例6: GetFirstItemByName

		/// <summary>
		/// Searches for the first occurrence of an item with given
		/// name between specified slots
		/// </summary>
		/// <param name="name">name</param>
		/// <param name="minSlot">fist slot for search</param>
		/// <param name="maxSlot">last slot for search</param>
		/// <returns>found item or null</returns>
		public InventoryItem GetFirstItemByName(string name, eInventorySlot minSlot, eInventorySlot maxSlot)
		{
			minSlot = GetValidInventorySlot(minSlot);
			maxSlot = GetValidInventorySlot(maxSlot);
			if (minSlot == eInventorySlot.Invalid || maxSlot == eInventorySlot.Invalid)
				return null;

			// If lower slot is greater than upper slot, flip the values.
			if (minSlot > maxSlot)
			{
				eInventorySlot tmp = minSlot;
				minSlot = maxSlot;
				maxSlot = tmp;
			}

			lock (m_items)
			{
				InventoryItem item;

				for (eInventorySlot i = minSlot; i <= maxSlot; i++)
				{
					if (m_items.TryGetValue(i, out item))
					{
						if (item.Name == name)
							return item;
					}
				}
			}

			return null;
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:39,代码来源:GameLivingInventory.cs


示例7: FindSlot

		/// <summary>
		/// Searches between two slots for the first or last full or empty slot
		/// </summary>
		/// <param name="first"></param>
		/// <param name="last"></param>
		/// <param name="searchFirst"></param>
		/// <param name="searchNull"></param>
		/// <returns></returns>
		protected virtual eInventorySlot FindSlot(eInventorySlot first, eInventorySlot last, bool searchFirst, bool searchNull)
		{
			lock (m_items) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				first = GetValidInventorySlot(first);
				last = GetValidInventorySlot(last);

				if (first == eInventorySlot.Invalid || last == eInventorySlot.Invalid)
					return eInventorySlot.Invalid;

				// If first/last slots are identical, check to see if the slot is full/empty and return based on
				// whether we instructed to find an empty or a full slot.
				if (first == last)
				{
					// If slot is empty, and we wanted an empty slot, or if slot is full, and we wanted
					// a full slot, return the given slot, otherwise return invalid.
					return !m_items.ContainsKey(first) == searchNull ? first : eInventorySlot.Invalid;
				}

				// If lower slot is greater than upper slot, flip the values.
				if (first > last)
				{
					eInventorySlot tmp = first;
					first = last;
					last = tmp;
				}

				for (int i = 0; i <= last - first; i++)
				{
					var testSlot = (int) (searchFirst ? (first + i) : (last - i));

					if (!m_items.ContainsKey((eInventorySlot) testSlot) == searchNull)
						return (eInventorySlot) testSlot;
				}

				return eInventorySlot.Invalid;
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:46,代码来源:GameLivingInventory.cs


示例8: FindLastFullSlot

		/// <summary>
		/// Find the last full slot in the inventory
		/// </summary>
		/// <param name="first">SlotPosition to start the search</param>
		/// <param name="last">SlotPosition to stop the search</param>
		/// <returns>the empty inventory slot or eInventorySlot.Invalid</returns>
		public virtual eInventorySlot FindLastFullSlot(eInventorySlot first, eInventorySlot last)
		{
			return FindSlot(first, last, false, false);
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:10,代码来源:GameLivingInventory.cs


示例9: IsSlotsFree

		/// <summary>
		/// Checks if specified count of slots is free
		/// </summary>
		/// <param name="count"></param>
		/// <param name="minSlot"></param>
		/// <param name="maxSlot"></param>
		/// <returns></returns>
		public bool IsSlotsFree(int count, eInventorySlot minSlot, eInventorySlot maxSlot)
		{
			if (count < 1)
				return true;

			// If lower slot is greater than upper slot, flip the values.
			if (minSlot > maxSlot)
			{
				eInventorySlot tmp = minSlot;
				minSlot = maxSlot;
				maxSlot = tmp;
			}

			lock (m_items) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				for (eInventorySlot i = minSlot; i <= maxSlot; i++)
				{
					if (m_items.ContainsKey(i))
						continue;

					count--;

					if (count <= 0)
						return true;
				}

				return false;
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:36,代码来源:GameLivingInventory.cs


示例10: OnPlayerBuy

        /// <summary>
        /// The Player is buying an Item from the merchant
        /// </summary>
        /// <param name="player"></param>
        /// <param name="playerInventory"></param>
        /// <param name="fromClientSlot"></param>
        /// <param name="toClientSlot"></param>
		public virtual void OnPlayerBuy(GamePlayer player, eInventorySlot fromClientSlot, eInventorySlot toClientSlot, bool usingMarketExplorer = false)
        {
			IDictionary<int, InventoryItem> clientInventory = GetClientInventory(player);

			InventoryItem fromItem = null;

			if (clientInventory.ContainsKey((int)fromClientSlot))
			{
				fromItem = clientInventory[(int)fromClientSlot];
			}

			if (fromItem == null)
			{
				ChatUtil.SendErrorMessage(player, "I can't find the item you want to purchase!");
				log.ErrorFormat("CM: {0}:{1} can't find item to buy in slot {2} on consignment merchant on lot {3}.", player.Name, player.Client.Account, (int)fromClientSlot, HouseNumber);
				return;
			}

			string buyText = "Do you want to buy this Item?";

			// If the player has a marketExplorer activated they will be charged a commission
			if (player.TargetObject is MarketExplorer)
			{
				player.TempProperties.setProperty(CONSIGNMENT_BUY_ITEM, fromClientSlot);
				if (ServerProperties.Properties.MARKET_FEE_PERCENT > 0)
				{
					player.Out.SendCustomDialog("Buying directly from the Market Explorer costs an additional " +  ServerProperties.Properties.MARKET_FEE_PERCENT + "% fee. Do you want to buy this Item?", new CustomDialogResponse(BuyMarketResponse));
				}
				else
				{
					player.Out.SendCustomDialog(buyText, new CustomDialogResponse(BuyResponse));
				}
			}
			else if (player.TargetObject == this)
			{
				player.TempProperties.setProperty(CONSIGNMENT_BUY_ITEM, fromClientSlot);
				player.Out.SendCustomDialog(buyText, new CustomDialogResponse(BuyResponse));
			}
			else
			{
				ChatUtil.SendErrorMessage(player, "I'm sorry, you need to be talking to a market explorer or consignment merchant in order to make a purchase.");
				log.ErrorFormat("CM: {0}:{1} did not have a CM or ME targeted when attempting to purchase {2} on consignment merchant on lot {3}.", player.Name, player.Client.Account, fromItem.Name, HouseNumber);
			}
        }
开发者ID:mynew4,项目名称:DAoC,代码行数:51,代码来源:ConsignmentMerchant.cs


示例11: AddNPCEquipment

		/// <summary>
		/// Adds item to template reusing inventory item instances from other templates.
		/// </summary>
		/// <param name="slot">The equipment slot</param>
		/// <param name="model">The equipment model</param>
		/// <returns>true if added</returns>
		public bool AddNPCEquipment(eInventorySlot slot, int model)
		{
			return AddNPCEquipment(slot, model, 0, 0, 0);
		}
开发者ID:boscorillium,项目名称:dol,代码行数:10,代码来源:GameNpcInventoryTemplate.cs


示例12: RemoveTemplate

		/// <summary>
		/// Overridden. Inventory template cannot be modified.
		/// </summary>
		/// <param name="templateID">The ItemTemplate ID</param>
		/// <param name="count">The count of items to add</param>
		/// <param name="minSlot">The first slot</param>
		/// <param name="maxSlot">The last slot</param>
		/// <returns>false</returns>
		public override bool RemoveTemplate(string templateID, int count, eInventorySlot minSlot, eInventorySlot maxSlot)
		{
			return false;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:12,代码来源:GameNpcInventoryTemplate.cs


示例13: AddTemplate

		/// <summary>
		/// Overridden. Inventory template cannot be modified.
		/// </summary>
		/// <param name="template">The ItemTemplate</param>
		/// <param name="count">The count of items to add</param>
		/// <param name="minSlot">The first slot</param>
		/// <param name="maxSlot">The last slot</param>
		/// <returns>false</returns>
		public override bool AddTemplate(InventoryItem template, int count, eInventorySlot minSlot, eInventorySlot maxSlot)
		{
			return false;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:12,代码来源:GameNpcInventoryTemplate.cs


示例14: ExchangeItems

		/// <summary>
		/// Overridden. Inventory template cannot be modified.
		/// </summary>
		/// <param name="fromSlot">First SlotPosition</param>
		/// <param name="toSlot">Second SlotPosition</param>
		/// <returns>false</returns>
		protected override bool ExchangeItems(eInventorySlot fromSlot, eInventorySlot toSlot)
		{
			return false;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:10,代码来源:GameNpcInventoryTemplate.cs


示例15: StackItems

		/// <summary>
		/// Overridden. Inventory template cannot be modified.
		/// </summary>
		/// <param name="fromSlot">First SlotPosition</param>
		/// <param name="toSlot">Second SlotPosition</param>
		/// <param name="itemCount">How many items to move</param>
		/// <returns>false</returns>
		protected override bool StackItems(eInventorySlot fromSlot, eInventorySlot toSlot, int itemCount)
		{
			return false;
		}
开发者ID:boscorillium,项目名称:dol,代码行数:11,代码来源:GameNpcInventoryTemplate.cs


示例16: CountSlots

		/// <summary>
		/// Counts used/free slots between min and max
		/// </summary>
		/// <param name="countUsed"></param>
		/// <param name="minSlot"></param>
		/// <param name="maxSlot"></param>
		/// <returns></returns>
		public int CountSlots(bool countUsed, eInventorySlot minSlot, eInventorySlot maxSlot)
		{
			// If lower slot is greater than upper slot, flip the values.
			if (minSlot > maxSlot)
			{
				eInventorySlot tmp = minSlot;
				minSlot = maxSlot;
				maxSlot = tmp;
			}

			int result = 0;

			lock (m_items) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				for (eInventorySlot i = minSlot; i <= maxSlot; i++)
				{
					if (m_items.ContainsKey(i))
					{
						if (countUsed)
							result++;
					}
					else
					{
						if (!countUsed)
							result++;
					}
				}

				return result;
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:38,代码来源:GameLivingInventory.cs


示例17: CountItemTemplate

		/// <summary>
		/// Count items of some type
		/// </summary>
		/// <param name="itemtemplateID">template to count</param>
		/// <param name="minSlot">first slot</param>
		/// <param name="maxSlot">last slot</param>
		/// <returns>number of matched items found</returns>
		public int CountItemTemplate(string itemtemplateID, eInventorySlot minSlot, eInventorySlot maxSlot)
		{
			lock (m_items) // Mannen 10:56 PM 10/30/2006 - Fixing every lock(this)
			{
				int count = 0;

				// If lower slot is greater than upper slot, flip the values.
				if (minSlot > maxSlot)
				{
					eInventorySlot tmp = minSlot;
					minSlot = maxSlot;
					maxSlot = tmp;
				}

				InventoryItem item;

				for (eInventorySlot i = minSlot; i <= maxSlot; i++)
				{
					if (m_items.TryGetValue(i, out item) && item.Id_nb == itemtemplateID)
					{
						count += item.Count;
					}
				}

				return count++;
			}
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:34,代码来源:GameLivingInventory.cs


示例18: CommanderSwitchWeapon

		/// <summary>
		/// Changes the commander's weapon to the specified type
		/// </summary>
		/// <param name="slot"></param>
		/// <param name="aSlot"></param>
		/// <param name="weaponType"></param>
		protected void CommanderSwitchWeapon(eInventorySlot slot, eActiveWeaponSlot aSlot, string weaponType)
		{
			if (Inventory == null)
				return;

			string itemId = string.Format("BD_Commander_{0}_{1}", slot.ToString(), weaponType);
			//all weapons removed before
			InventoryItem item = Inventory.GetItem(eInventorySlot.RightHandWeapon);
			if (item != null) Inventory.RemoveItem(item);
			item = Inventory.GetItem(eInventorySlot.TwoHandWeapon);
			if (item != null) Inventory.RemoveItem(item);

			ItemTemplate temp = GameServer.Database.FindObjectByKey<ItemTemplate>(itemId);

			if (temp == null)
			{
				if (log.IsErrorEnabled)
					log.Error(string.Format("Unable to find Bonedancer item: {0}", itemId));
				return;
			}

			Inventory.AddItem(slot, GameInventoryItem.Create<ItemTemplate>(temp));
			SwitchWeapon(aSlot);
			AddStatsToWeapon();
			BroadcastLivingEquipmentUpdate();
		}
开发者ID:andyhebear,项目名称:DOLSharp,代码行数:32,代码来源:CommanderPet.cs


示例19: FindLastEmptySlot

		/// <summary>
		/// Find the last empty slot in the inventory
		/// </summary>
		/// <param name="first">SlotPosition to start the search</param>
		/// <param name="last">SlotPosition to stop the search</param>
		/// <returns>the empty inventory slot or eInventorySlot.Invalid</returns>
		public virtual eInventorySlot FindLastEmptySlot(eInventorySlot first, eInventorySlot last)
		{
			return FindSlot(first, last, false, true);
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:10,代码来源:GameLivingInventory.cs


示例20: MoveItemFromObject

		/// <summary>
		/// Move an item from the inventory object to a player's backpack (uses client slots)
		/// </summary>
		public static IDictionary<int, InventoryItem> MoveItemFromObject(this IGameInventoryObject thisObject, GamePlayer player, eInventorySlot fromClientSlot, eInventorySlot toClientSlot)
		{
			// We will only allow moving to the backpack.

			if (toClientSlot < eInventorySlot.FirstBackpack || toClientSlot > eInventorySlot.LastBackpack)
				return null;

			lock (thisObject.LockObject())
			{
				Dictionary<int, InventoryItem> inventory = thisObject.GetClientInventory(player);

				if (inventory.ContainsKey((int)fromClientSlot) == false)
				{
					ChatUtil.SendErrorMessage(player, "Item not found in slot " + (int)fromClientSlot);
					return null;
				}

				InventoryItem fromItem = inventory[(int)fromClientSlot];
				InventoryItem toItem = player.Inventory.GetItem(toClientSlot);

				// if there is an item in the players target inventory slot then move it to the object
				if (toItem != null)
				{
					player.Inventory.RemoveTradeItem(toItem);
					toItem.SlotPosition = fromItem.SlotPosition;
					toItem.OwnerID = thisObject.GetOwner(player);
					thisObject.OnAddItem(player, toItem);
					GameServer.Database.SaveObject(toItem);
				}

				thisObject.OnRemoveItem(player, fromItem);

				// Create the GameInventoryItem from this InventoryItem.  This simply wraps the InventoryItem, 
				// which is still updated when this item is moved around
				InventoryItem objectItem = GameInventoryItem.Create<InventoryItem>(fromItem);

				player.Inventory.AddTradeItem(toClientSlot, objectItem);

				var updateItems = new Dictionary<int, InventoryItem>(1);
				updateItems.Add((int)fromClientSlot, toItem);

				return updateItems;
			}
		}
开发者ID:andyhebear,项目名称:DOLSharp,代码行数:47,代码来源:GameInventoryObject.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# eProperty类代码示例发布时间:2022-05-24
下一篇:
C# eChartType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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