コード例 #1
0
    /// <summary>
    /// Determines what happens when clicking on the equipment slot
    /// </summary>
    public void OnCLick()
    {
        if (InventoryScript.instance.FromSlot == null)
        {
            // if I have nothing in my hand
            if (HandScript.instance.MyMoveable == null)
            {
                HandScript.instance.TakeMoveable(equipment as IMoveable);
                InventoryScript.instance.FromEqippedSlot = this;
            }
        }

        else if (InventoryScript.instance.FromSlot != null)
        {
            bool matchingSlot = equipManager.CheckIfSlotMatchesType(slotId, HandScript.instance.MyMoveable as Equipment);

            if (matchingSlot)
            {
                bool equipSuccess = equipManager.Equip(HandScript.instance.MyMoveable as Equipment);

                if (equipSuccess)
                {
                    HandScript.instance.Drop();
                    InventoryScript.instance.FromSlot.Clear();
                    InventoryScript.instance.FromSlot = null;
                }
            }
        }
    }