예제 #1
0
    public bool Add(Item item, string slotType)
    {
        player.AddEquipment(item);
        switch (item.item_type)
        {
        case "helmet":
            if (helmet != null)
            {
                player.RemoveEquipment(helmet);
            }
            helmet = item;
            return(true);

        case "boots":
            if (boots != null)
            {
                player.RemoveEquipment(boots);
            }
            boots = item;
            return(true);

        case "legs":
            if (legs != null)
            {
                player.RemoveEquipment(legs);
            }
            legs = item;
            return(true);;

        case "dual":
            if (slotType == null)
            {
                if (mainHand != null && mainHand.item_id == item.item_id)
                {
                    player.RemoveEquipment(mainHand);
                }
                else if (offHand != null && offHand.item_id == item.item_id)
                {
                    player.RemoveEquipment(offHand);
                }

                if (mainHand == null)
                {
                    mainHand = item;
                    return(true);
                }
                else if (mainHand != null && offHand == null)
                {
                    offHand = item;
                    return(true);
                }
            }
            else if (slotType.Equals("mainHand"))
            {
                mainHand = item;
                return(true);
            }
            else if (slotType.Equals("offHand"))
            {
                offHand = item;
                return(true);
            }
            return(false);

        case "2H":
            if (mainHand != null)
            {
                player.RemoveEquipment(mainHand);
            }
            mainHand = item;
            return(true);;

        case "top":
            if (top != null)
            {
                player.RemoveEquipment(top);
            }
            top = item;
            return(true);;
        }
        return(false);
    }