Esempio n. 1
0
    /// <summary>
    /// 创建实例
    /// </summary>
    public static FuncPutOffEquipRequest create(int funcID, int slot, int bagIndex)
    {
        FuncPutOffEquipRequest re = (FuncPutOffEquipRequest)BytesControl.createRequest(dataID);

        re.funcID   = funcID;
        re.slot     = slot;
        re.bagIndex = bagIndex;
        return(re);
    }
    /** 卸下装备到背包 */
    public void putOffEquipToBag(int slot, int bagIndex)
    {
        ItemData equip = getEquip(slot);

        if (equip == null)
        {
            me.warnLog("卸下装备时,装备为空", slot);
            return;
        }

        if (!me.bag.hasFreeGrid(1))
        {
            me.warnLog("卸下装备时,没有空余格子");
            return;
        }

        if (bagIndex != -1)
        {
            if (me.bag.getItem(bagIndex) != null)
            {
                me.warnLog("卸下装备时,目标格子不为空", bagIndex);
                return;
            }
        }

        if (CommonSetting.isClientDriveLogic)
        {
            toPutOffEquip(slot, equip);

            if (bagIndex != -1)
            {
                me.bag.addNewItemToIndex(bagIndex, equip, CallWayType.PutOffEquip);
            }
            else
            {
                me.bag.addItem(equip, CallWayType.PutOffEquip);
            }
        }
        else
        {
            me.send(FuncPutOffEquipRequest.create(_funcID, slot, bagIndex));
        }
    }