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


C# GridItem.GetQuantity方法代码示例

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


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

示例1: OnCloseSplitMenu

	public void OnCloseSplitMenu(GridItem item, int quantity)
	{
		_windowPanel.SplitItemPanel.Hide();

		if(quantity > 0 && quantity < item.GetQuantity())
		{
			//reduce the exsiting item's quantity and add new item to selected
			item.SetQuantity(item.GetQuantity() - quantity);
			Item newItem = new Item(item.Item);
			CreateSelectedItem(newItem, quantity);
		}
		else if(quantity >= item.GetQuantity())
		{
			PickupItem(item);
		}


	}
开发者ID:rotorist,项目名称:Warzone,代码行数:18,代码来源:InventoryPanel.cs

示例2: OnPlaceItem

	public void OnPlaceItem(GridItem item)
	{
		if(SelectedItem == item && item.Boundary.alpha == 1)
		{
			
			if(FocusedTempSlot != null)
			{
				//place in temp slot
				GridItem existingItem = null;
				TempSlot temp = FocusedTempSlot;
				if(FocusedTempSlot.Items.Count > 0)
				{
					existingItem = FocusedTempSlot.Items[0];
				}
				FocusedTempSlot.Items.Clear();

				PlaceItemInTempSlot(item);

				if(_selectedItemLastList != null && _selectedItemLastList != temp.Items)
				{
					_selectedItemLastList.Remove(item);
					_selectedItemLastList = null;
				}

				if(existingItem != null && existingItem != item)
				{
					PickupItem(existingItem);
				}


			}
			else if(FocusedBodySlot != null)
			{
				//place in body slot
				GridItem existingItem = null;
				BodySlot temp = FocusedBodySlot;
				if(FocusedBodySlot.Items.Count > 0)
				{
					existingItem = FocusedBodySlot.Items[0];
				}


				if(item.Item.Type == ItemType.Ammo && (FocusedBodySlot.AllowedItemType == ItemType.PrimaryWeapon || FocusedBodySlot.AllowedItemType == ItemType.SideArm))
				{
					if(existingItem != null && (int)existingItem.Item.GetAttributeByName("_LoadedAmmos").Value <= 0 && 
						(string)item.Item.GetAttributeByName("_Caliber").Value == (string)existingItem.Item.GetAttributeByName("_Caliber").Value)
					{
						existingItem.Item.SetAttribute("_LoadedAmmoID", item.Item.ID);
						GameManager.Inst.UIManager.SetConsoleText("The weapon is now loading " + item.Item.Name);
					}
					else if((int)existingItem.Item.GetAttributeByName("_LoadedAmmos").Value > 0)
					{
						GameManager.Inst.UIManager.SetConsoleText("Weapon is still loaded, unload ammo first.");
					}
					else if((string)item.Item.GetAttributeByName("_Caliber").Value != (string)existingItem.Item.GetAttributeByName("_Caliber").Value)
					{
						GameManager.Inst.UIManager.SetConsoleText("Caliber doesn't match!");
					}

				}
				else
				{
					FocusedBodySlot.Items.Clear();
					PlaceItemInBodySlot(item);

					if(_selectedItemLastList != null && _selectedItemLastList != temp.Items)
					{
						_selectedItemLastList.Remove(item);
						_selectedItemLastList = null;
					}


					if(existingItem != null && existingItem != item)
					{

						PickupItem(existingItem);

					}

				}


			}
			else if(FocusedGrid != null)
			{
				PlaceItem(item);	

				if(_selectedItemLastList != null)
				{
					_selectedItemLastList.Remove(item);
					_selectedItemLastList = null;
				}

				if(ReplaceItem != null)
				{
					Debug.Log("Replace item is not null");
					//if replace item is same as item then try to combine the two
					if(ReplaceItem.Item.ID == item.Item.ID && item.Item.MaxStackSize > 1)
					{
						int fill = item.Item.MaxStackSize - item.GetQuantity();
//.........这里部分代码省略.........
开发者ID:rotorist,项目名称:Warzone,代码行数:101,代码来源:InventoryPanel.cs


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