Пример #1
0
    bool OnItemAdd(COM_Item item)
    {
        if (item == null)
        {
            return(false);
        }
        ItemData data = ItemData.GetData((int)item.itemId_);

        if (data == null)
        {
            return(false);
        }
        if (data.mainType_ == ItemMainType.IMT_Equip)
        {
            JobType    jt         = (JobType)GamePlayer.Instance.GetIprop(PropertyType.PT_Profession);
            int        level      = GamePlayer.Instance.GetIprop(PropertyType.PT_ProfessionLevel);
            Profession profession = Profession.get(jt, level);
            ItemData   _itemData  = ItemData.GetData((int)item.itemId_);
            if (!profession.canuseItem(_itemData.subType_, _itemData.level_))
            {
                return(false);
            }

            if (GamePlayer.Instance.GetIprop(PropertyType.PT_Level) / 10 + 1 < _itemData.level_)
            {
                return(false);
            }

            if (data.slot_ == EquipmentSlot.ES_SingleHand)
            {
                if (GamePlayer.Instance.Equips[(int)EquipmentSlot.ES_DoubleHand] != null)
                {
                    return(false);
                }
            }

            if (data.slot_ == EquipmentSlot.ES_DoubleHand)
            {
                if (GamePlayer.Instance.Equips[(int)EquipmentSlot.ES_SingleHand] != null)
                {
                    return(false);
                }
            }

            float newForce = Define.CALC_BASE_FightingForce(item);
            float oldForce = Define.CALC_BASE_FightingForce(GamePlayer.Instance.Equips[(int)data.slot_]);
            if (newForce > oldForce)
            {
                return(true);
            }
        }

        return(false);
    }