/** 移动装备 */
    public void moveEquip(int fromSlot, int toSlot)
    {
        ItemData equip = getEquip(fromSlot);

        if (equip == null)
        {
            me.warnLog("移动装备时,物品为空", fromSlot);
            return;
        }

        if (!isSlotEnabled(toSlot))
        {
            me.warnLog("移动装备时,目标槽位不可用", fromSlot);
            return;
        }

        if (EquipSlotTypeConfig.get(toSlot).equipType != equip.config.secondType)
        {
            me.warnLog("移动装备时,装备类型不匹配", equip.id);
            return;
        }

        if (CommonSetting.isClientDriveLogic)
        {
            onMoveEquipByServer(fromSlot, toSlot);
        }
    }
Esempio n. 2
0
    /// <summary>
    /// 新创建的保存数据
    /// </summary>
    protected void newCreateUseData(MUnitUseData useData)
    {
        useData.mIndex = getOneMUnitIndex();
        useData.equips = GameC.factory.createEquipContainerData();
        useData.equips.initDefault();

        int unitType = useData.getUnitType();

        foreach (EquipSlotTypeConfig v in EquipSlotTypeConfig.getDic())
        {
            if (v != null && v.unitType == unitType)
            {
                if (v.isOpen)
                {
                    //直接打开
                    useData.equips.openSlots.add(v.id);
                }
            }
        }
    }
    /** 是否可穿戴装备 */
    public bool canPutOnEquip(int slot, ItemData data, bool needNotice)
    {
        if (!isSlotEnabled(slot))
        {
            if (needNotice)
            {
                me.warnLog("装备位置未开放", slot);
            }

            return(false);
        }

        if (data.config.type != ItemType.Equip)
        {
            if (needNotice)
            {
                me.warnLog("不是装备", data.id);
            }

            return(false);
        }

        if (getEquip(slot) != null)
        {
            if (needNotice)
            {
                me.warnLog("装备位置已存在", slot);
            }

            return(false);
        }

        if (data.config.isUnique && _equipNumDic.get(data.id) > 0)
        {
            if (needNotice)
            {
                me.warnLog("已存在唯一装备", data.id);
            }

            return(false);
        }

        //类型不匹配
        if (EquipSlotTypeConfig.get(slot).equipType != data.config.secondType)
        {
            if (needNotice)
            {
                me.warnLog("装备类型不匹配", data.id);
            }

            return(false);
        }

        //不满足使用条件
        if (!me.role.checkRoleConditions(data.config.useConditions, needNotice))
        {
            return(false);
        }

        return(true);
    }