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


C# Slot.RemoveItem方法代码示例

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


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

示例1: Use

	public override void Use (Slot slot, ItemScript item) {

        if (ItemName == "Energy Potion" && Stamina.Instance.currentStamina < Stamina.Instance.maxStamina){
            Debug.Log(ItemName);
            Stamina.Instance.currentStamina += Stamina.Instance.energyPot;
            Stamina.Instance.bar.fillAmount += Stamina.Instance.energyPot / 100f;
            Stamina.Instance.ManaColor();
            Stamina.Instance.ManaText();
                if(Stamina.Instance.currentStamina >= Stamina.Instance.maxStamina) {
                    Stamina.Instance.currentStamina = Stamina.Instance.maxStamina;
                }
            slot.RemoveItem();
        }
        if (ItemName == "Health Potion" && PlayerScript.Instance.currentHealth < PlayerScript.Instance.maxHealth) {
            Debug.Log(ItemName);
            PlayerScript.Instance.GetHealth();
            PlayerScript.Instance.HandleHealth();
            slot.RemoveItem();
        }
        if (ItemName == "Rage Potion" && Stamina.Instance.currentRage < Stamina.Instance.maxRage) {
            Debug.Log(ItemName);
            Stamina.Instance.RagePotion();
            slot.RemoveItem();
        }
    }
开发者ID:Fahrettin52,项目名称:Game-Lab-1.1,代码行数:25,代码来源:Consumable.cs

示例2: Use

    public override void Use(Slot slot, ItemScript item)
    {
        slot.RemoveItem ();

        Debug.Log ("Used " + ItemName);
        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.health = player = GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.health + Health;
        if(GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.health >= GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.maxHealth)
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.health = GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.maxHealth;
        }

        player = GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.mana = player = GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.mana + Mana;
        if(GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.mana >= GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.maxMana)
        {
            GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.mana = GameObject.FindGameObjectWithTag("Player").GetComponent<Fighter>().PlayerClass.maxMana;
        }
    }
开发者ID:jordanepickett,项目名称:RPG,代码行数:17,代码来源:Consumable.cs

示例3: 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

示例4: 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

示例5: MoveItem

    //Moves item to new slot in inventory/swap items
    public void MoveItem(Slot clickedSlot)
    {
        //If holding shift, make a splitStack window
        if (Input.GetKey(KeyCode.LeftShift) && !clickedSlot.IsEmpty() && !HoverIcon.hoverIcon)
        {
            from = clickedSlot;
            CreateSplitter();
            return;
        }

        if (clickedSlot.transform.parent.gameObject.Equals(GameControl.comboWindow.gameObject))
        {
            if (HoverIcon.hoverIcon != null)
            {
                if (HoverIcon.hoverIcon.GetComponent<Slot>().SlotItems().Type != BaseItem.ItemType.RELIC)
                {
                    return;
                }
            }
            else
            {
                if (clickedSlot.name.Equals("ResultSlot"))
                {
                    if (GameControl.comboWindow.Created)
                    {
                        from = clickedSlot;
                        CreateHoverIcon();
                        while (!from.IsEmpty())
                        {
                            HoverIcon.hoverIcon.GetComponent<Slot>().Items.Push(from.RemoveItem());
                        }
                        GameControl.comboWindow.Created = false;
                    }
                    return;
                }
            }
        }

        if (clickedSlot.transform.parent.gameObject.Equals(GameControl.equipment.gameObject))
        {
            if (HoverIcon.hoverIcon != null)
            {
                if (HoverIcon.hoverIcon.GetComponent<Slot>().SlotItems().Type == BaseItem.ItemType.EQUIPMENT)
                {
                    BaseEquipment item = (BaseEquipment)(HoverIcon.hoverIcon.GetComponent<Slot>().SlotItems());
                    if (!item.SubType.ToString().Equals(clickedSlot.name))
                    {
                        return;
                    }
                    GameControl.player.Stats.TransferStats(item.Stats);
                }
                else if (HoverIcon.hoverIcon.GetComponent<Slot>().SlotItems().Type == BaseItem.ItemType.WEAPON)
                {
                    if (clickedSlot.name.Equals("MAINHAND") || clickedSlot.name.Equals("OFFHAND"))
                    {
                        BaseWeapon item = (BaseWeapon)(HoverIcon.hoverIcon.GetComponent<Slot>().SlotItems());
                        if (item.Hand==2 && !clickedSlot.name.Equals("MAINHAND"))
                        {
                            return;
                        }
                        GameControl.player.Stats.TransferStats(item.Stats);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (!clickedSlot.IsEmpty())
                {
                    GameControl.player.Stats.RemoveStats(clickedSlot.GetComponent<Slot>().SlotItems().Stats);
                }
            }
        }
        //If from is null and slot has items in it, set from equal to slicked slot
        if (HoverIcon.hoverIcon == null)
        {
            if (!clickedSlot.IsEmpty())
            {
                from = clickedSlot;

                CreateHoverIcon();
                while (!from.IsEmpty())
                {
                    HoverIcon.hoverIcon.GetComponent<Slot>().Items.Push(from.RemoveItem());
                }
            }
        }
        //If the hoverIcon exists and has items in it, run code
        else if (HoverIcon.hoverIcon != null)
        {
            to = clickedSlot;

//.........这里部分代码省略.........
开发者ID:RAWeber,项目名称:Unity,代码行数:101,代码来源:Slot.cs

示例6: 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

示例7: Use

 /// <summary>
 /// Uses the item
 /// </summary>
 public override void Use(Slot slot, ItemScript item)
 {
     Debug.Log("Used " + ItemName);
     slot.RemoveItem();
 }
开发者ID:ALapidis,项目名称:AmberIsles,代码行数:8,代码来源:Consumeable.cs

示例8: 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


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