源战役客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

209 行
7.3 KiB

  1. BagIconItem = BagIconItem or BaseClass(AwardItem)
  2. function BagIconItem:__init()
  3. self.bLock = false
  4. self.sell_state = false
  5. self.last_click_time = nil
  6. end
  7. function BagIconItem:Load_callback()
  8. AwardItem.Load_callback(self)
  9. --监听物品的动态信息事件,因为可洗炼的信息是放在物品的动态信息15000协议里面的,
  10. local change_dynamic = function (goods_id)
  11. if self._use_delete_method then return end
  12. if goods_id and self.goodsVo and self.goodsVo.goods_id == goods_id then
  13. local vo = GoodsModel:getInstance():GetBagGoodsInfoById(goods_id)
  14. if vo then
  15. -- EquipModel:getInstance():EquipDynamicField(vo)
  16. -- GoodsModel:getInstance():IsEquipGoodsCanWash(true)
  17. --市场里的背包不用获取物品动态信息
  18. -- if self.goodsVo and self.goodsVo.pos_type and self.goodsVo.pos_type == GoodsModel.GOODS_POS_TYPE.market then
  19. -- return
  20. -- end
  21. if ItemUseModel:getInstance():IsEquipSpecialType(vo.type_id) then --暂时只判断小恶魔
  22. self:SetData(vo) --需要刷新,比如续费
  23. end
  24. end
  25. end
  26. end
  27. self.dynamic_event_id = GlobalEventSystem:Bind(GoodsModel.CHANGE_GOODS_DYNAMIC,change_dynamic)
  28. end
  29. function BagIconItem:__delete()
  30. if self.dynamic_event_id then
  31. GlobalEventSystem:UnBind(self.dynamic_event_id)
  32. self.dynamic_event_id = nil
  33. end
  34. end
  35. function BagIconItem:SetPos(pos)
  36. self.pos = pos
  37. end
  38. function BagIconItem:SetSellState(flag)
  39. self.sell_state = flag
  40. end
  41. function BagIconItem:SetData(vo,goods_num,mask_id,hide_effect, spe_color_effect, equip_key)
  42. self.bLock = false
  43. vo.goods_num = vo.goods_num or goods_num or 0
  44. self.goodsVo = vo
  45. local goods = GoodsModel:getInstance():GetZhuangBeiListVo(self.goodsVo.goods_id)
  46. if goods then
  47. EquipModel:getInstance():EquipDynamicField(goods)
  48. end
  49. if self.goodsVo.identify and self.goodsVo.identify > 0 then
  50. self:ChangeIdentifyState(true)
  51. else
  52. self:ChangeIdentifyState(false)
  53. end
  54. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(vo.type_id)
  55. if basic == nil then
  56. return
  57. end
  58. local stren_data = EquipModel:getInstance():GetBagEquipAwaraItemInfo(self.goodsVo)
  59. stren_data.equip_key = equip_key or "EquipView"
  60. stren_data.key_value = "show_bag_view"
  61. self.stren_data = stren_data
  62. 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)
  63. self:SetLimitState(BagModel:getInstance():GetGoodsLimitState(self.goodsVo))
  64. if self.goodsVo.canWear then
  65. self:ChangeWearState(true)
  66. else
  67. self:ChangeWearState(false)
  68. end
  69. if self.goodsVo.type == 13 then --圣印的升降禁 13这会为装扮,遂屏蔽
  70. elseif self.goodsVo.type == 39 then --幻兽的升降禁、精炼显示
  71. local flag = nil
  72. self:ChangeEquipState(flag)
  73. if self.goodsVo.goods_id then
  74. local function callback(dynamic)
  75. if dynamic.stren and dynamic.stren > 0 then
  76. if self.stren and not self._use_delete_method then
  77. self.stren.text = "+" .. dynamic.stren
  78. end
  79. else
  80. if self.stren and not self._use_delete_method then
  81. self.stren.text = ""
  82. end
  83. end
  84. end
  85. GoodsModel:getInstance():GetDynamic(self.goodsVo.goods_id, callback)
  86. end
  87. else --其他
  88. if self.goodsVo.type == GoodsModel.TYPE.EQUIP and self.goodsVo.goods_num > 0 then
  89. local can_tip, flag = EquipModel:getInstance():EquipCanShowGoodsTip(self.goodsVo)
  90. self:ChangeEquipState(flag)
  91. else
  92. self:ChangeEquipState(nil)
  93. end
  94. end
  95. if MarketModel:GetInstance():IsGoodsCanUpShelves(self.goodsVo) then--显示可上架角标
  96. --本职业的显示绿环,非本职业的显示上架角标
  97. if EquipModel:getInstance():SelfCareerIsOk( self.goodsVo.type_id ) then
  98. self:SetNumLimitVisible(true,5)
  99. else
  100. self:SetNumLimitVisible(true,29)
  101. end
  102. elseif GoodsModel.getInstance():IsLimitGoodsInLimitState(self.goodsVo) then --限时道具 显示限时状态
  103. self:ShowLimitIcon(true,1)
  104. self:SetNumLimitVisible(false)
  105. elseif GoodsModel.getInstance():IsLimitGoodsInExpireState(self.goodsVo) then --限时道具 显示已经过期状态
  106. self:ShowLimitIcon(true,2)
  107. self:SetNumLimitVisible(false)
  108. elseif GoodsModel.getInstance():IsShowTipsUse(self.goodsVo.type, self.goodsVo.subtype, basic) then --显示可以使用
  109. self:SetNumLimitVisible(true,22)
  110. else
  111. self:SetNumLimitVisible(false)
  112. end
  113. end
  114. --这里显示背包中物品点击的tips响应事件
  115. --要注意是否也需要在AwardItem的ClickCallFun()方法也加入点击tips事件,(如在商店或是邮件中显示的物品)
  116. function BagIconItem:ClickCallFun(target, x, y)
  117. if self.goodsVo and self.goodsVo.goods_num > 0 then
  118. if self.sell_state and self.goodsVo.goods_num > 0 then --用于背包的一键出售
  119. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15021,1,self.goodsVo.goods_id, self.goodsVo.goods_num, self.goodsVo.type_id)
  120. return
  121. end
  122. -- local function delayFunc()
  123. if self.goodsVo.type == GoodsModel.TYPE.EQUIP then --装备
  124. if self.goodsVo.subtype == 12 then --时装物品
  125. UIToolTipMgr:getInstance():AppendGoodsTips(self.goodsVo.type_id, x, y, self.goodsVo)
  126. else
  127. 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)
  128. end
  129. --elseif self.goodsVo.type == 13 then --圣印
  130. -- UIToolTipMgr:getInstance():AppendSealTips(self.goodsVo.type_id, x, y, self.goodsVo, nil, nil, self.equip_tips_btns)
  131. elseif self.goodsVo.type == 39 and self.goodsVo.subtype <= 50 then --幻兽装备
  132. UIToolTipMgr:getInstance():AppendBeastTips(self.goodsVo.type_id, x, y, self.goodsVo)
  133. else --普通物品
  134. UIToolTipMgr:getInstance():AppendGoodsTips(self.goodsVo.type_id, x, y, self.goodsVo)
  135. end
  136. end
  137. end
  138. function BagIconItem:ChangeUnusableState(state)
  139. if state then
  140. if self.unusableImg == nil then
  141. self.unusableImg = UiFactory.createChild(self.transform,UIType.Image,"unusableImg")
  142. else
  143. self.unusableImg:SetActive(true)
  144. end
  145. self.unusableImg.transform.pivot = Vector2(0,1)
  146. self.unusableImg.transform.localPosition = Vector3(5,-5,0)
  147. lua_resM:setImageSprite(self,self.unusableImg:GetComponent("Image"),"bag_asset","bag_ui_6",true)
  148. if self.identifyImg then
  149. self.identifyImg:SetActive(false)
  150. end
  151. else
  152. if self.unusableImg then
  153. self.unusableImg:SetActive(false)
  154. end
  155. end
  156. end
  157. --可鉴定
  158. function BagIconItem:ChangeIdentifyState(state)
  159. if state then
  160. if self.identifyImg == nil then
  161. self.identifyImg = UiFactory.createChild(self.transform,UIType.Image,"identifyImg")
  162. else
  163. self.identifyImg:SetActive(true)
  164. end
  165. self.identifyImg.transform.pivot = Vector2(0,1)
  166. self.identifyImg.transform.localPosition = Vector3(0,0,0)
  167. lua_resM:setImageSprite(self,self.identifyImg:GetComponent("Image"),"bag_asset","bag_ui_5",true)
  168. else
  169. if self.identifyImg then
  170. self.identifyImg:SetActive(false)
  171. end
  172. end
  173. end
  174. --可穿戴状态
  175. function BagIconItem:ChangeWearState(state)
  176. if state then
  177. if self.wearImg == nil then
  178. self.wearImg = UiFactory.createChild(self.transform,UIType.Image,"wearImg")
  179. else
  180. self.wearImg:SetActive(true)
  181. end
  182. self.wearImg.transform.pivot = Vector2(0,1)
  183. self.wearImg.transform.localPosition = Vector3(0,0,0)
  184. lua_resM:setImageSprite(self,self.wearImg:GetComponent("Image"),"bag_asset","ba_kcd",true)
  185. else
  186. if self.wearImg then
  187. self.wearImg:SetActive(false)
  188. end
  189. end
  190. end