|
BagIconItem = BagIconItem or BaseClass(AwardItem)
|
|
function BagIconItem:__init()
|
|
self.bLock = false
|
|
self.sell_state = false
|
|
self.last_click_time = nil
|
|
end
|
|
|
|
function BagIconItem:Load_callback()
|
|
AwardItem.Load_callback(self)
|
|
|
|
--监听物品的动态信息事件,因为可洗炼的信息是放在物品的动态信息15000协议里面的,
|
|
local change_dynamic = function (goods_id)
|
|
if self._use_delete_method then return end
|
|
if goods_id and self.goodsVo and self.goodsVo.goods_id == goods_id then
|
|
local vo = GoodsModel:getInstance():GetBagGoodsInfoById(goods_id)
|
|
if vo then
|
|
-- EquipModel:getInstance():EquipDynamicField(vo)
|
|
-- GoodsModel:getInstance():IsEquipGoodsCanWash(true)
|
|
--市场里的背包不用获取物品动态信息
|
|
-- if self.goodsVo and self.goodsVo.pos_type and self.goodsVo.pos_type == GoodsModel.GOODS_POS_TYPE.market then
|
|
-- return
|
|
-- end
|
|
if ItemUseModel:getInstance():IsEquipSpecialType(vo.type_id) then --暂时只判断小恶魔
|
|
self:SetData(vo) --需要刷新,比如续费
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self.dynamic_event_id = GlobalEventSystem:Bind(GoodsModel.CHANGE_GOODS_DYNAMIC,change_dynamic)
|
|
end
|
|
|
|
function BagIconItem:__delete()
|
|
if self.dynamic_event_id then
|
|
GlobalEventSystem:UnBind(self.dynamic_event_id)
|
|
self.dynamic_event_id = nil
|
|
end
|
|
end
|
|
|
|
function BagIconItem:SetPos(pos)
|
|
self.pos = pos
|
|
end
|
|
|
|
function BagIconItem:SetSellState(flag)
|
|
self.sell_state = flag
|
|
end
|
|
|
|
function BagIconItem:SetData(vo,goods_num,mask_id,hide_effect, spe_color_effect, equip_key)
|
|
self.bLock = false
|
|
vo.goods_num = vo.goods_num or goods_num or 0
|
|
self.goodsVo = vo
|
|
local goods = GoodsModel:getInstance():GetZhuangBeiListVo(self.goodsVo.goods_id)
|
|
if goods then
|
|
EquipModel:getInstance():EquipDynamicField(goods)
|
|
end
|
|
|
|
if self.goodsVo.identify and self.goodsVo.identify > 0 then
|
|
self:ChangeIdentifyState(true)
|
|
else
|
|
self:ChangeIdentifyState(false)
|
|
end
|
|
local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(vo.type_id)
|
|
if basic == nil then
|
|
return
|
|
end
|
|
local stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(self.goodsVo)
|
|
stren_data.equip_key = equip_key or "EquipView"
|
|
stren_data.key_value = "show_bag_view"
|
|
self.stren_data = stren_data
|
|
AwardItem.SetData(self, vo.type_id, goods_num or vo.goods_num or 0, vo.color, stren_data, self.goodsVo.bind,nil,nil,mask_id,nil,hide_effect, spe_color_effect)
|
|
self:SetLimitState(BagModel:getInstance():GetGoodsLimitState(self.goodsVo))
|
|
|
|
if self.goodsVo.canWear then
|
|
self:ChangeWearState(true)
|
|
else
|
|
self:ChangeWearState(false)
|
|
end
|
|
|
|
if self.goodsVo.type == 13 then --圣印的升降禁 13这会为装扮,遂屏蔽
|
|
|
|
elseif self.goodsVo.type == 39 then --幻兽的升降禁、精炼显示
|
|
local flag = nil
|
|
|
|
self:ChangeEquipState(flag)
|
|
|
|
if self.goodsVo.goods_id then
|
|
local function callback(dynamic)
|
|
if dynamic.stren and dynamic.stren > 0 then
|
|
if self.stren and not self._use_delete_method then
|
|
self.stren.text = "+" .. dynamic.stren
|
|
end
|
|
else
|
|
if self.stren and not self._use_delete_method then
|
|
self.stren.text = ""
|
|
end
|
|
end
|
|
end
|
|
GoodsModel:getInstance():GetDynamic(self.goodsVo.goods_id, callback)
|
|
end
|
|
else --其他
|
|
if self.goodsVo.type == GoodsModel.TYPE.EQUIP and self.goodsVo.goods_num > 0 then
|
|
local can_tip, flag = EquipModel:getInstance():EquipCanShowGoodsTip(self.goodsVo)
|
|
self:ChangeEquipState(flag)
|
|
else
|
|
self:ChangeEquipState(nil)
|
|
end
|
|
end
|
|
|
|
if MarketModel:GetInstance():IsGoodsCanUpShelves(self.goodsVo) then--显示可上架角标
|
|
--本职业的显示绿环,非本职业的显示上架角标
|
|
if EquipModel:getInstance():SelfCareerIsOk( self.goodsVo.type_id ) then
|
|
self:SetNumLimitVisible(true,5)
|
|
else
|
|
self:SetNumLimitVisible(true,29)
|
|
end
|
|
elseif GoodsModel.getInstance():IsLimitGoodsInLimitState(self.goodsVo) then --限时道具 显示限时状态
|
|
self:ShowLimitIcon(true,1)
|
|
self:SetNumLimitVisible(false)
|
|
|
|
elseif GoodsModel.getInstance():IsLimitGoodsInExpireState(self.goodsVo) then --限时道具 显示已经过期状态
|
|
self:ShowLimitIcon(true,2)
|
|
self:SetNumLimitVisible(false)
|
|
|
|
elseif GoodsModel.getInstance():IsShowTipsUse(self.goodsVo.type, self.goodsVo.subtype, basic) then --显示可以使用
|
|
self:SetNumLimitVisible(true,22)
|
|
else
|
|
self:SetNumLimitVisible(false)
|
|
end
|
|
end
|
|
|
|
--这里显示背包中物品点击的tips响应事件
|
|
--要注意是否也需要在AwardItem的ClickCallFun()方法也加入点击tips事件,(如在商店或是邮件中显示的物品)
|
|
function BagIconItem:ClickCallFun(target, x, y)
|
|
if self.goodsVo and self.goodsVo.goods_num > 0 then
|
|
if self.sell_state and self.goodsVo.goods_num > 0 then --用于背包的一键出售
|
|
GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15021,1,self.goodsVo.goods_id, self.goodsVo.goods_num, self.goodsVo.type_id)
|
|
return
|
|
end
|
|
-- local function delayFunc()
|
|
if self.goodsVo.type == GoodsModel.TYPE.EQUIP then --装备
|
|
if self.goodsVo.subtype == 12 then --时装物品
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(self.goodsVo.type_id, x, y, self.goodsVo)
|
|
else
|
|
UIToolTipMgr:getInstance():AppendEquipTips(self.goods_basic.type_id, x, y,self.stren_data and self.stren_data.goods_vo,nil,nil,nil,self.stren_data and self.stren_data.key_value)
|
|
end
|
|
--elseif self.goodsVo.type == 13 then --圣印
|
|
-- UIToolTipMgr:getInstance():AppendSealTips(self.goodsVo.type_id, x, y, self.goodsVo, nil, nil, self.equip_tips_btns)
|
|
elseif self.goodsVo.type == 39 and self.goodsVo.subtype <= 50 then --幻兽装备
|
|
UIToolTipMgr:getInstance():AppendBeastTips(self.goodsVo.type_id, x, y, self.goodsVo)
|
|
else --普通物品
|
|
UIToolTipMgr:getInstance():AppendGoodsTips(self.goodsVo.type_id, x, y, self.goodsVo)
|
|
end
|
|
end
|
|
end
|
|
|
|
function BagIconItem:ChangeUnusableState(state)
|
|
if state then
|
|
if self.unusableImg == nil then
|
|
self.unusableImg = UiFactory.createChild(self.transform,UIType.Image,"unusableImg")
|
|
else
|
|
self.unusableImg:SetActive(true)
|
|
end
|
|
self.unusableImg.transform.pivot = Vector2(0,1)
|
|
self.unusableImg.transform.localPosition = Vector3(5,-5,0)
|
|
lua_resM:setImageSprite(self,self.unusableImg:GetComponent("Image"),"bag_asset","bag_ui_6",true)
|
|
|
|
if self.identifyImg then
|
|
self.identifyImg:SetActive(false)
|
|
end
|
|
else
|
|
if self.unusableImg then
|
|
self.unusableImg:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
--可鉴定
|
|
function BagIconItem:ChangeIdentifyState(state)
|
|
if state then
|
|
if self.identifyImg == nil then
|
|
self.identifyImg = UiFactory.createChild(self.transform,UIType.Image,"identifyImg")
|
|
else
|
|
self.identifyImg:SetActive(true)
|
|
end
|
|
self.identifyImg.transform.pivot = Vector2(0,1)
|
|
self.identifyImg.transform.localPosition = Vector3(0,0,0)
|
|
lua_resM:setImageSprite(self,self.identifyImg:GetComponent("Image"),"bag_asset","bag_ui_5",true)
|
|
else
|
|
if self.identifyImg then
|
|
self.identifyImg:SetActive(false)
|
|
end
|
|
end
|
|
end
|
|
|
|
--可穿戴状态
|
|
function BagIconItem:ChangeWearState(state)
|
|
if state then
|
|
if self.wearImg == nil then
|
|
self.wearImg = UiFactory.createChild(self.transform,UIType.Image,"wearImg")
|
|
else
|
|
self.wearImg:SetActive(true)
|
|
end
|
|
self.wearImg.transform.pivot = Vector2(0,1)
|
|
self.wearImg.transform.localPosition = Vector3(0,0,0)
|
|
lua_resM:setImageSprite(self,self.wearImg:GetComponent("Image"),"bag_asset","ba_kcd",true)
|
|
else
|
|
if self.wearImg then
|
|
self.wearImg:SetActive(false)
|
|
end
|
|
end
|
|
end
|