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


C# GridItem.SetQuantity方法代码示例

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


在下文中一共展示了GridItem.SetQuantity方法的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


//.........这里部分代码省略.........
						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();
						if(fill < ReplaceItem.GetQuantity())
						{
							item.SetQuantity(item.Item.MaxStackSize);
							ReplaceItem.SetQuantity(ReplaceItem.GetQuantity() - fill);

							PickupItem(ReplaceItem);
							ReplaceItem.Sprite.alpha = 1;
							ReplaceItem = null;
						}
						else
						{
							item.SetQuantity(item.GetQuantity() + ReplaceItem.GetQuantity());
							FocusedGrid.Items.Remove(ReplaceItem);
							DestroyItem(ReplaceItem);
						}

						return;
					}

					//if replace item is not the same, but selected item is ammo and replace item is an empty gun that can use the ammo
					//then load the gun with ammo
					if(item.Item.Type == ItemType.Ammo && (ReplaceItem.Item.Type == ItemType.PrimaryWeapon || ReplaceItem.Item.Type == ItemType.SideArm))
					{
						if((int)ReplaceItem.Item.GetAttributeByName("_LoadedAmmos").Value <= 0 && 
							(string)item.Item.GetAttributeByName("_Caliber").Value == (string)ReplaceItem.Item.GetAttributeByName("_Caliber").Value)
						{
							ReplaceItem.Item.SetAttribute("_LoadedAmmoID", item.Item.ID);
							GameManager.Inst.UIManager.SetConsoleText("The weapon is now loading " + item.Item.Name);
						}
						else if((int)ReplaceItem.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)ReplaceItem.Item.GetAttributeByName("_Caliber").Value)
						{
							GameManager.Inst.UIManager.SetConsoleText("Caliber doesn't match!");
						}

						PickupItem(item);
						return;
					}


					PickupItem(ReplaceItem);
					ReplaceItem.Sprite.alpha = 1;
					ReplaceItem = null;


				}


			}
				

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


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