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


C# Slot.AddItems方法代码示例

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


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

示例1: SwapItems

 public static void SwapItems(Slot from, Slot to)
 {
     ItemType movingType = from.currentItem.type;
     if (movingType == ItemType.BOOTS || movingType == ItemType.LEGS || movingType == ItemType.HEAD || movingType == ItemType.CHEST)
     {
         if (from.currentItem.isEquipped)
         {
             from.currentItem.isEquipped = false;
         }
     }
     //		print ("FROM NAME: " + from.name + " FROM ITEM: " + from.currentItem.itemName + " TO NAME: " + to.name + " TO ITEM#: " + to.items.Count);
     if (from != null && to != null)
     {
         if (to.canContain == ItemType.GENERIC || movingType == to.canContain)
         {
             Stack<ItemScript> tempTo = new Stack<ItemScript>(to.items);
             to.AddItems(from.items);
             if (tempTo.Count == 0)
             {
                 to.transform.parent.GetComponent<Inventory>().EmptySlots--;
                 from.ClearSlot();
             }
             else
             {
                 from.AddItems(tempTo);
             }
         }
     }
 }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:29,代码来源:Slot.cs

示例2: SwapItems

    public static void SwapItems(Slot source, Slot destination)
    {
        ItemType movingType = source.CurrentItem.Item.Type;

        if (source != null && destination != null) {
            bool needToRecalculateStats = source.transform.parent == CharacterPanel.Instance.transform || destination.transform.parent == CharacterPanel.Instance.transform;

            if(destination.canContain == ItemType.GENERIC || movingType == destination.canContain) {
                Stack<ItemHolder> tempDestination = new Stack<ItemHolder>(destination.Items);

                destination.AddItems(source.Items);

                if(tempDestination.Count == 0) {
                    if (source.type == SlotType.CHARACTER && destination.type == SlotType.INVENTORY)
                        GameObject.Find("Inventory").GetComponent<Inventory>().EmptySlots--;
                    else if (source.type == SlotType.INVENTORY && destination.type == SlotType.CHARACTER)
                        GameObject.Find("Inventory").GetComponent<Inventory>().EmptySlots++;
                    source.ClearSlot();
                } else {
                    source.AddItems(tempDestination);
                }
            }

            if (needToRecalculateStats) {
                CharacterPanel.Instance.CalculateStats();
            }
        }
    }
开发者ID:ivanrenic,项目名称:inventory-system,代码行数:28,代码来源:Slot.cs

示例3: SwapItems

    public static void SwapItems(Slot from, Slot to)
    {
        Stack<ItemScript> tmp = from.RemoveAllItems();
        from.AddItems(to.RemoveAllItems());
        to.AddItems(tmp);

        if (to.Items.Count > 0)
        {
            to.ChangeSprite(to.Items.Peek().sprite);

            to.IconSprite.enabled = true;
        }

        if (from.Items.Count > 0)
        {
            from.ChangeSprite(from.Items.Peek().sprite);

            from.IconSprite.enabled = true;
        }
    }
开发者ID:thyjukki,项目名称:Rebelion,代码行数:20,代码来源:Slot.cs

示例4: SwapItems

    /// <summary>
    /// Swaps two items from one slot to another
    /// </summary>
    /// <param name="from">The slot that we are moving from</param>
    /// <param name="to">The slot that we are moving to</param>
    public static void SwapItems(Slot from, Slot to)
    {
        if (to != null && from != null)
        {
            bool calcStats = from.transform.parent == CharacterPanel.Instance.transform || to.transform.parent == CharacterPanel.Instance.transform;

            if (CanSwap(from, to))
            {
                Stack<ItemScript> tmpTo = new Stack<ItemScript>(to.Items); //Stores the items from the to slot, so that we can do a swap

                to.AddItems(from.Items); //Stores the items in the "from" slot in the "to" slot

                if (tmpTo.Count == 0) //If "to" slot if 0 then we dont need to move anything to the "from " slot.
                {
                    //FIX REMOVED SLOTS MINUSMINUS
                    from.ClearSlot(); //clears the from slot
                }
                else
                {
                    from.AddItems(tmpTo); //If the "to" slot contains items thne we need to move the to the "from" slot
                }

            }

            if (calcStats) //Calculates the stats if we need to
            {
                CharacterPanel.Instance.CalcStats();
            }
        }
    }
开发者ID:ALapidis,项目名称:AmberIsles,代码行数:35,代码来源:Slot.cs

示例5: SwapItems

    public static void SwapItems(Slot from, Slot to)
    {
        ItemType movingType = from.CurrentItem.Item.ItemType;

        if(to != null && from !=null)
        {
            bool calcStats = from.transform.parent == CharacterPanel.Instance.transform || to.transform.parent == CharacterPanel.Instance.transform;

            if(movingType == ItemType.TWOHAND && CharacterPanel.Instance.OffhandSlot.IsEmpty || movingType == ItemType.MAINHAND)
            {

                movingType = ItemType.GENERICWEAPON;

            }

            if(to.canContain == ItemType.GENERIC || movingType == to.canContain)
            {

                if(movingType != ItemType.OFFHAND || (CharacterPanel.Instance.WeaponSlot.IsEmpty || CharacterPanel.Instance.WeaponSlot.CurrentItem.Item.ItemType != ItemType.TWOHAND))
                {

                Stack<ItemScript> tmpTo = new Stack<ItemScript>(to.Items); //Stores the items from the to slot, so that we can do a swap

                to.AddItems(from.Items); //Stores the items in the "from" slot in the "to" slot

                if (tmpTo.Count == 0) //If "to" slot if 0 then we dont need to move anything to the "from " slot.
                {
                    to.transform.parent.GetComponent<Inventory>().EmptySlots--;
                    from.ClearSlot(); //clears the from slot
                }
                else
                {
                    from.AddItems(tmpTo); //If the "to" slot contains items thne we need to move the to the "from" slot
                }

                }
            }

            if(calcStats)
            {
               CharacterPanel.Instance.CalcStats ();
            }
        }
    }
开发者ID:jordanepickett,项目名称:RPG,代码行数:44,代码来源:Slot.cs

示例6: MoveItem

    //
    public void MoveItem(GameObject clicked)
    {
        CanvasGroup cG = clicked.transform.parent.GetComponent<CanvasGroup>();
        //clicked.GetComponentInParent<CanvasGroup>().alpha > 0
        if (cG != null && cG.alpha > 0 || clicked.transform.parent.parent.GetComponent<CanvasGroup>().alpha > 0)
        {
            InventoryManager.Instance.Clicked = clicked;
            if (!InventoryManager.Instance.MovingSlot.isEmpty)
            {
                temp = clicked.GetComponent<Slot>();
                if (temp.isEmpty)
                {

                    temp.AddItems(InventoryManager.Instance.MovingSlot.items);
                    InventoryManager.Instance.MovingSlot.items.Clear();
                    Destroy(GameObject.Find("Hover"));
                }
                else if (!temp.isEmpty && InventoryManager.Instance.MovingSlot.currentItem.classification == temp.currentItem.classification && temp.isAvailable)
                {
                    MergeStacks(InventoryManager.Instance.MovingSlot, temp);
                }
            }
            else if (InventoryManager.Instance.From == null && !Input.GetKey(KeyCode.LeftShift))
            {
                if (clicked.transform.parent.GetComponent<Inventory>().isOpen)
                {
                    if (!clicked.GetComponent<Slot>().isEmpty && !GameObject.Find ("Hover"))
                    {
                        InventoryManager.Instance.From = clicked.GetComponent<Slot>();
                        InventoryManager.Instance.From.GetComponent<Image>().color = Color.gray;
                        CreateHoverIcon();
                    }
                }
                else if (CharacterPanel.Instance.isOpen)
                {
                    if (!clicked.GetComponent<Slot>().isEmpty && !GameObject.Find ("Hover"))
                    {
                        InventoryManager.Instance.From = clicked.GetComponent<Slot>();
                        InventoryManager.Instance.From.GetComponent<Image>().color = Color.gray;
                        CreateHoverIcon();
                    }
                }
            }
            else if (InventoryManager.Instance.To == null && !Input.GetKey(KeyCode.LeftShift))
            {
                InventoryManager.Instance.To = clicked.GetComponent<Slot>();
                Destroy(GameObject.Find("Hover"));
            }
            if (InventoryManager.Instance.To != null && InventoryManager.Instance.From != null)
            {
                if (!InventoryManager.Instance.To.isEmpty && InventoryManager.Instance.From.currentItem.itemName == InventoryManager.Instance.To.currentItem.itemName && InventoryManager.Instance.To.isAvailable)
                {
                    MergeStacks(InventoryManager.Instance.From, InventoryManager.Instance.To);
                }
                else
                {
                    Slot.SwapItems(InventoryManager.Instance.From, InventoryManager.Instance.To);
                }
                InventoryManager.Instance.From.GetComponent<Image>().color = Color.white;
                InventoryManager.Instance.To = null;
                InventoryManager.Instance.From = null;
                Destroy(GameObject.Find("Hover"));
            }
        }
    }
开发者ID:Hopesresolve,项目名称:MineCraftProject,代码行数:66,代码来源:Inventory.cs


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