本文整理汇总了C#中Slot.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# Slot.AddItem方法的具体用法?C# Slot.AddItem怎么用?C# Slot.AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slot
的用法示例。
在下文中一共展示了Slot.AddItem方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MergeStacks
//Merges the items on two slots
//The slot to merge the items from, The slot to merge the items into
public void MergeStacks(Slot source, Slot destination)
{
//Calculates the max amount of items we are allowed to merge onto the stack
int max = destination.CurrentItem.Item.MaxSize - destination.Items.Count;
//Sets the correct amount so that we don't put too many items down
int count = source.Items.Count < max ? source.Items.Count : max;
for (int i = 0; i < count; i++) { //Merges the items into the other stack
destination.AddItem(source.RemoveItem()); //Removes the items from the source and adds them to the destination
InventoryManager.Instance.HoverObject.transform.GetChild(0).GetComponent<Text>().text = InventoryManager.Instance.MovingSlot.Items.Count.ToString(); //Updates the text on the stack that
}
if (source.Items.Count == 0) { //We don't have more items to merge with
Destroy(GameObject.Find("Hover"));
}
}
示例2: MergeStacks
public void MergeStacks(Slot sourceSlot, Slot destinationSlot)
{
int max = destinationSlot.CurrentItem.Item.MaxStack - destinationSlot.Items.Count;
int count = sourceSlot.Items.Count < max ? sourceSlot.Items.Count : max;
for (int i = 0; i < count; i++) {
destinationSlot.AddItem(sourceSlot.RemoveItem());
PanelManager.Instance.HoverObject.transform.GetChild(0).GetComponent<Text>().text = PanelManager.Instance.MovingSlot.Items.Count.ToString();
}
if (sourceSlot.Items.Count == 0) {
sourceSlot.ClearSlot();
Destroy(GameObject.Find("Hover"));
}
}
示例3: use
public override void use(Slot slot)
{
GameObject.FindObjectOfType<KeyHandler>().EquipSetActive(true);
if (slot.name.Equals("Slot") || slot.name.Equals("ResultSlot"))
{
Slot equipSlot = GameObject.Find(this.SubType.ToString()).GetComponent<Slot>();
BaseItem tmp = equipSlot.SlotItems();
equipSlot.ClearSlot();
equipSlot.AddItem(this);
slot.ClearSlot();
if (slot.name.Equals("Slot"))
{
slot.AddItem(tmp);
}
else
{
GameControl.inventory.AddItemToInventory(tmp);
GameControl.comboWindow.Created = false;
}
GameControl.player.Stats.TransferStats(this.Stats);
}
else
{
GameControl.inventory.AddItemToInventory(this);
GameControl.player.Stats.RemoveStats(this.Stats);
slot.ClearSlot();
}
}
示例4: MergeStacks
public void MergeStacks (Slot source, Slot destination) {
int max = destination.CurrentItem.Item.MaxSize - destination.Items.Count;
int count = source.Items.Count < max ? source.Items.Count : max;
for (int i = 0; i < count; i++) {
destination.AddItem(source.RemoveItem());
InventoryManager.Instance.HoverObject.transform.GetChild (0).GetComponent<Text> ().text = InventoryManager.Instance.MovingSlot.Items.Count.ToString();
}
if (source.Items.Count == 0) //We ont have more items to merge with
{
//FIX REMOVES SOURCE.CLEAR
Destroy(GameObject.Find("Hover"));
}
}
示例5: MergeStacks
public void MergeStacks(Slot source, Slot destination)
{
int max = destination.currentItem.maxSize - destination.items.Count;
int count = source.items.Count < max ? source.items.Count : max;
for(int i = 0; i < count; i++)
{
destination.AddItem(source.RemoveItem());
InventoryManager.Instance.HoverObject.transform.GetChild (0).GetComponent<Text>().text = InventoryManager.Instance.MovingSlot.items.Count.ToString();
}
if (source.items.Count == 0)
{
source.ClearSlot();
Destroy(GameObject.Find("Hover"));
}
}
示例6: use
public override void use(Slot slot)
{
GameObject.FindObjectOfType<KeyHandler>().EquipSetActive(true);
Slot mainHand = GameObject.Find("MAINHAND").GetComponent<Slot>();
Slot offHand = GameObject.Find("OFFHAND").GetComponent<Slot>();
if (slot.name.Equals("Slot") || slot.name.Equals("ResultSlot"))
{
Slot weaponSlot;
if (mainHand.IsEmpty() || this.Hand==2 || ((BaseWeapon)mainHand.SlotItems()).Hand==2)
{
weaponSlot = mainHand;
if (this.Hand==2)
{
BaseWeapon item = (BaseWeapon)offHand.SlotItems();
GameControl.inventory.AddItemToInventory(item);
offHand.ClearSlot();
}
}
else
{
weaponSlot = offHand;
}
BaseItem tmp = weaponSlot.SlotItems();
weaponSlot.ClearSlot();
weaponSlot.AddItem(this);
slot.ClearSlot();
if (slot.name.Equals("Slot"))
{
slot.AddItem(tmp);
}
else
{
GameControl.inventory.AddItemToInventory(tmp);
GameControl.comboWindow.Created = false;
}
GameControl.player.Stats.TransferStats(this.Stats);
}
else
{
if (slot.name.Equals("MAINHAND"))
{
BaseWeapon item = (BaseWeapon)offHand.SlotItems();
GameControl.inventory.AddItemToInventory(this);
GameControl.inventory.AddItemToInventory(item);
offHand.ClearSlot();
}
else
{
GameControl.inventory.AddItemToInventory(this);
}
GameControl.player.Stats.RemoveStats(this.Stats);
slot.ClearSlot();
}
}