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


C# Slot.AddItemStack方法代码示例

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


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

示例1: MoveItem


//.........这里部分代码省略.........
                        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;

            //If the slot clicked has Items in it, swap the items held with the items in slot
            if (!to.IsEmpty())
            {
                Stack<BaseItem> tmpHover = HoverIcon.hoverIcon.GetComponent<Slot>().Items;
                CreateHoverIcon();
                Stack<BaseItem> leftOvers = to.AddItemStack(tmpHover);
                if (leftOvers.Count == 0)
                {
                    DestroyImmediate(HoverIcon.hoverIcon.gameObject);
                }
                else
                {
                    HoverIcon.hoverIcon.GetComponent<Slot>().Items = leftOvers;
                    HoverIcon.hoverIcon.GetComponentInChildren<Text>().text = HoverIcon.hoverIcon.GetComponent<Slot>().Items.Count > 1 ? HoverIcon.hoverIcon.GetComponent<Slot>().Items.Count.ToString() : string.Empty;
                }
                to = null;
            }
            //If clicked slot is empty place items into slot
            else
            {
                to.AddItemStack(HoverIcon.hoverIcon.GetComponent<Slot>().Items);
                CreateToolTip();
                to = null;
                from = null;
                Destroy(HoverIcon.hoverIcon.gameObject);
            }
        }
    }
开发者ID:RAWeber,项目名称:Unity,代码行数:101,代码来源:Slot.cs


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