本文整理汇总了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);
}
}
示例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;
}
}
}
}