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


C# Slot.ClearSlot方法代码示例

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


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

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

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

示例3: use

 public override void use(Slot slot)
 {
     GameObject.FindObjectOfType<KeyHandler>().ComboSetActive(true);
     if (slot.name.Equals("Slot"))
     {
         foreach(Slot s in GameControl.comboWindow.ComboSlots)
         {
             if (s.name.Equals("ComboSlot") && s.IsEmpty())
             {
                 s.AddItem(this);
                 slot.ClearSlot();
                 break;
             }
         }
         GameControl.comboWindow.updateSet();
     }
     else
     {
         GameControl.inventory.AddItemToInventory(this);
         slot.ClearSlot();
     }
 }
开发者ID:RAWeber,项目名称:Unity,代码行数:22,代码来源:BaseRelic.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: MergeStacks

    /// <summary>
    /// Merges the items on two slots
    /// </summary>
    /// <param name="source">The slot to merge the items from</param>
    /// <param name="destination">The slot to merge the items into</param>
    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 ont have more items to merge with
        {
            source.ClearSlot();
            Destroy(GameObject.Find("Hover"));
        }
    }
开发者ID:jordanepickett,项目名称:RPG,代码行数:24,代码来源:Inventory.cs

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

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

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

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

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

示例11: UnequipItem

    public void UnequipItem(Slot slot, ItemHolder item)
    {
        Inventory inventory = GameObject.Find("Inventory").GetComponent<Inventory>();

        if (inventory.emptySlots > 0) {
            inventory.AddItem(item);
            slot.ClearSlot();

            switch (item.Item.Type) {
            case ItemType.CIPELE:
                BootsSprite.sprite = defaultBoots;
                break;
            case ItemType.HLACE:
                PantsSprite.sprite = defaultPants;
                break;
            case ItemType.MAJICA:
                ShirtSprite.sprite = defaultShirt;
                break;
            case ItemType.KAPA:
                HatSprite.gameObject.SetActive(false);
                break;
            default:
                break;
            }

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


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