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


C# Slot.AddItem方法代码示例

本文整理汇总了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"));
        }
    }
开发者ID:ALapidis,项目名称:AmberIsles,代码行数:21,代码来源:Inventory.cs

示例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"));
        }
    }
开发者ID:ivanrenic,项目名称:inventory-system,代码行数:15,代码来源:Inventory.cs

示例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();
     }
 }
开发者ID:RAWeber,项目名称:Unity,代码行数:28,代码来源:BaseEquipment.cs

示例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"));
        }
    }
开发者ID:Fahrettin52,项目名称:Game-Lab-1.1,代码行数:13,代码来源:Inventory.cs

示例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"));
     }
 }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:15,代码来源:Inventory.cs

示例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();
     }
 }
开发者ID:RAWeber,项目名称:Unity,代码行数:54,代码来源:BaseWeapon.cs


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