当前位置: 首页>>代码示例>>C#>>正文


C# GamePlayer.CreateItemOnTheGround方法代码示例

本文整理汇总了C#中GamePlayer.CreateItemOnTheGround方法的典型用法代码示例。如果您正苦于以下问题:C# GamePlayer.CreateItemOnTheGround方法的具体用法?C# GamePlayer.CreateItemOnTheGround怎么用?C# GamePlayer.CreateItemOnTheGround使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GamePlayer的用法示例。


在下文中一共展示了GamePlayer.CreateItemOnTheGround方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildCraftedItem


//.........这里部分代码省略.........
					int countFree = item.MaxCount - item.Count;
					if (count > countFree)
					{
						changedSlots.Add(item.SlotPosition, countFree); // existing item should be changed
						count -= countFree;
					}
					else
					{
						changedSlots.Add(item.SlotPosition, count); // existing item should be changed
						count = 0;
						break;
					}
				}

				if (count > 0) // Add new object
				{
					eInventorySlot firstEmptySlot = player.Inventory.FindFirstEmptySlot(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);
					if (firstEmptySlot == eInventorySlot.Invalid)
					{
						changedSlots.Add(-1, -count); // Create the item on the ground
					}
					else
					{
						changedSlots.Add((int)firstEmptySlot, -count); // Create the item in the free slot
					}
					count = 0;
				}

				InventoryItem newItem = null;

				player.Inventory.BeginChanges();

				Dictionary<int, int>.Enumerator enumerator = changedSlots.GetEnumerator();
				while (enumerator.MoveNext())
				{
					KeyValuePair<int, int> slot = enumerator.Current;
					int countToAdd = slot.Value;
					if (countToAdd > 0)	// Add to exiting item
					{
						newItem = player.Inventory.GetItem((eInventorySlot)slot.Key);
						if (newItem != null && player.Inventory.AddCountToStack(newItem, countToAdd))
						{
							InventoryLogging.LogInventoryAction("(craft)", player, eInventoryActionType.Other, newItem.Template, countToAdd);
							// count incremented, continue with next change
							continue;
						}
					}

					if (recipe.MakeTemplated)
					{
						string adjItem = itemToCraft.Id_nb+(GetQuality(player, recipe).ToString());
						ItemTemplate adjItemToCraft = GameServer.Database.FindObjectByKey<ItemTemplate>(adjItem);
						if (adjItemToCraft != null)
						{
							newItem = GameInventoryItem.Create<ItemTemplate>(adjItemToCraft);
						}
						else
						{
							newItem = GameInventoryItem.Create<ItemTemplate>(itemToCraft);
						}
					}
					else
					{
						ItemUnique unique = new ItemUnique(itemToCraft);
						GameServer.Database.AddObject(unique);
						newItem = GameInventoryItem.Create<ItemUnique>(unique);
						newItem.Quality = GetQuality(player, recipe);
					}

					newItem.IsCrafted = true;
					newItem.Creator = player.Name;
					newItem.Count = -countToAdd;

					if (slot.Key > 0)	// Create new item in the backpack
					{
						player.Inventory.AddItem((eInventorySlot)slot.Key, newItem);
						InventoryLogging.LogInventoryAction("(craft)", player, eInventoryActionType.Craft, newItem.Template, newItem.Count);
					}
					else					// Create new item on the ground
					{
						player.CreateItemOnTheGround(newItem);
						player.Out.SendDialogBox(eDialogCode.SimpleWarning, 0, 0, 0, 0, eDialogType.Ok, true, LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.BuildCraftedItem.BackpackFull", itemToCraft.Name));
					}
				}

				player.Inventory.CommitChanges();

				player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.BuildCraftedItem.Successfully", itemToCraft.Name, newItem.Quality), eChatType.CT_Missed, eChatLoc.CL_SystemWindow);

				if (recipe.MakeTemplated == false && newItem.Quality == 100)
				{
					player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "AbstractCraftingSkill.BuildCraftedItem.Masterpiece"), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
					player.Out.SendPlaySound(eSoundType.Craft, 0x04);
				}
				else
				{
					player.Out.SendPlaySound(eSoundType.Craft, 0x03);
				}
			}
		}
开发者ID:Refizul,项目名称:DOL-Kheldron,代码行数:101,代码来源:AbstractCraftingSkill.cs

示例2: GiveItem

		protected static bool GiveItem(GameLiving source, GamePlayer player, ItemTemplate itemTemplate, bool canDrop)
		{
			InventoryItem item = null;

			if (itemTemplate is ItemUnique)
			{
				GameServer.Database.AddObject(itemTemplate as ItemUnique);
				item = GameInventoryItem.Create(itemTemplate as ItemUnique);
			}
			else
			{
				item = GameInventoryItem.Create(itemTemplate);
			}

			if (!player.ReceiveItem(source, item))
			{
				if (canDrop)
				{
					player.CreateItemOnTheGround(item);
					player.Out.SendMessage(String.Format("Your backpack is full, {0} is dropped on the ground.", itemTemplate.Name), eChatType.CT_Important, eChatLoc.CL_PopupWindow);
				}
				else
				{
					player.Out.SendMessage("Your backpack is full!", eChatType.CT_Important, eChatLoc.CL_PopupWindow);
					return false;
				}
			}

			return true;
		}
开发者ID:mynew4,项目名称:DOLSharp,代码行数:30,代码来源:AbstractQuest.cs

示例3: GiveItem

 protected static void GiveItem(GameLiving source, GamePlayer player, ItemTemplate itemTemplate)
 {
     itemTemplate.AllowAdd = true;
     if (GameServer.Database.SelectObject<ItemTemplate>("Id_nb = '" + itemTemplate.Id_nb + "'") == null)
     {
         GameServer.Database.AddObject(itemTemplate);
     }
     //ameInventoryItem.Create<ItemTemplate>(itemTemplate);
     InventoryItem item = GameInventoryItem.Create<ItemTemplate>(itemTemplate);
     if (player.Inventory.AddItem(eInventorySlot.FirstEmptyBackpack, item))
     {
         if (source == null) { player.Out.SendMessage("You receive the " + itemTemplate.Name + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow); }
         else { player.Out.SendMessage("You receive " + itemTemplate.GetName(0, false) + " from " + source.GetName(0, false) + ".", eChatType.CT_System, eChatLoc.CL_SystemWindow); }
     }
     else { player.CreateItemOnTheGround(item); player.Out.SendMessage("Your Inventory is full. You couldn't recieve the " + itemTemplate.Name + ",so it's been placed on the ground. Pick it up as soon as possible or it will vanish in a few minutes.", eChatType.CT_Important, eChatLoc.CL_PopupWindow); }
 }
开发者ID:mynew4,项目名称:DAoC,代码行数:16,代码来源:Freeweapon.cs


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