源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

267 行
8.1 KiB

  1. --[[
  2. 使
  3. ]]
  4. SpecialEquipExpiredView = SpecialEquipExpiredView or BaseClass(BaseView)
  5. function SpecialEquipExpiredView:__init()
  6. self.base_file = "itemUse"
  7. self.layout_file = "SpecialEquipExpiredView"
  8. self.layer_name = "Top"
  9. self.is_set_zdepth = true
  10. self.destroy_imm = true
  11. self.change_scene_close = true
  12. self.use_background = true
  13. self.hide_maincancas = false
  14. self.model = ItemUseModel:getInstance()
  15. self.mainVo = RoleManager.Instance.mainRoleInfo
  16. --self.use_local_view = true
  17. self.gril_anima = "sheep"
  18. self:AddPreLoadList(self.gril_anima,{self.gril_anima})
  19. self.load_callback = function ()
  20. self:LoadSuccess()
  21. self:InitEvent()
  22. end
  23. self.open_callback = function ()
  24. self:UpdateView()
  25. if self.type_id and self.type_id == 1011000005 then
  26. --小恶魔体验版
  27. self.goBtn:SetActive(false)
  28. --self.renewBtn:SetActive(false)
  29. self.renewBtn:SetActive(true)
  30. else
  31. self.goBtn:SetActive(false)
  32. self.renewBtn:SetActive(true)
  33. end
  34. end
  35. self.close_callback = function ()
  36. if self.type == 2 then
  37. TreasureModel:getInstance():Fire(TreasureModel.OPEN_EXP_HINT_VIEW,"exp_hunt")
  38. end
  39. end
  40. self.destroy_callback = function ()
  41. self:Clear()
  42. end
  43. end
  44. function SpecialEquipExpiredView:Open(goods_id,type)
  45. self.type = type or 1
  46. self.goods_id = goods_id
  47. BaseView.Open(self)
  48. end
  49. function SpecialEquipExpiredView:Clear( )
  50. if self.awardItem then
  51. self.awardItem:DeleteMe()
  52. self.awardItem = nil
  53. end
  54. if self.anima then
  55. destroy(self.anima)
  56. self.anima = nil
  57. end
  58. end
  59. function SpecialEquipExpiredView:LoadSuccess( )
  60. self.itemCon
  61. = GetChildTransforms(self.transform,
  62. {
  63. "itemCon"
  64. })
  65. self.cost,
  66. self.renewBtn_text,
  67. self.renewBtn_dia_text,
  68. self.dia_cost,
  69. self.name
  70. = GetChildTexts(self.transform,
  71. {
  72. "renewBtn/cost",
  73. "renewBtn/Label2",
  74. "renewBtn1/Label2",
  75. "renewBtn1/cost",
  76. "name"
  77. })
  78. self.Image,
  79. self.flag,
  80. self.title,
  81. self.bg
  82. = GetChildImages(self.transform,
  83. {
  84. "renewBtn/Image",
  85. "Image",
  86. "title",
  87. "Window"
  88. })
  89. self.renewBtn,
  90. self.renewBtn_dia,
  91. self.goBtn
  92. = GetChildGameObjects(self.transform,
  93. {
  94. "renewBtn",
  95. "renewBtn1",
  96. "goBtn"
  97. })
  98. lua_resM:setOutsideImageSprite(self,self.bg,GameResPath.GetTreasureImage("mjsui_bg"),false)
  99. self.awardItem = AwardItem.New(self.itemCon)
  100. self.awardItem:SetItemSize(80, 80)
  101. self.awardItem.transform.anchoredPosition = Vector2.zero
  102. --if tonumber(AppConst.EnglineVer) >= 78 then
  103. local load_back = function(objs)
  104. if objs and objs[0] then
  105. self.anima = newObject(objs[0])
  106. self.anima.transform:SetParent(self.transform)
  107. SetLocalScale(self.anima.transform, 0.29)
  108. self.anima.transform.localEulerAngles = Vector3(0, 0, 0)
  109. SetLocalPosition(self.anima.transform, -321, -281, 0)
  110. end
  111. end
  112. --end
  113. lua_resM:loadPrefab(self,self.gril_anima,self.gril_anima, load_back, ASSETS_LEVEL.HIGHT)
  114. end
  115. function SpecialEquipExpiredView:InitEvent( )
  116. local function onBtnClickHandler(target)
  117. if target == self.renewBtn then
  118. if self.goods_id and self.price then
  119. local role = RoleManager.Instance.mainRoleInfo
  120. if RoleManager.Instance.mainRoleInfo:GetRealJin() < self.price then
  121. local function ok_callback()
  122. GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW, 1)
  123. self:Close()
  124. end
  125. Alert.show("您的彩钻不足,是否充值?", Alert.Type.Two, ok_callback, nil,"确定", "取消")
  126. else
  127. if self.type == 2 then
  128. ShopModel:getInstance():Fire(ShopModel.BUY_GOODS,20004,1)
  129. else
  130. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15006,self.goods_id,1)
  131. end
  132. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.SHOW_UES_EXP_EVIL_BTN,false)
  133. self:Close()
  134. end
  135. end
  136. elseif target == self.goBtn then
  137. if self.type_id and self.type_id == 1011000005 then
  138. GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, 3, 1011000001)
  139. else
  140. GlobalEventSystem:Fire(EventName.OPEN_SHOP_VIEW, 3, self.type_id)
  141. end
  142. self:Close()
  143. elseif target == self.renewBtn_dia then
  144. if self.goods_id and self.dia_price then
  145. local role = RoleManager.Instance.mainRoleInfo
  146. if role.jinLock < self.dia_price then
  147. local function ok_callback()
  148. GlobalEventSystem:Fire(EventName.OPEN_VIP_VIEW, 1)
  149. self:Close()
  150. end
  151. Alert.show("您的红钻不足,是否充值?", Alert.Type.Two, ok_callback, nil,"确定", "取消")
  152. else
  153. if self.type == 2 then
  154. ShopModel:getInstance():Fire(ShopModel.BUY_GOODS,20004,1)
  155. else
  156. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15006,self.goods_id,2)
  157. end
  158. BaseDungeonModel:getInstance():Fire(BaseDungeonModel.SHOW_UES_EXP_EVIL_BTN,false)
  159. self:Close()
  160. end
  161. end
  162. end
  163. end
  164. AddClickEvent(self.renewBtn,onBtnClickHandler)
  165. AddClickEvent(self.goBtn,onBtnClickHandler)
  166. AddClickEvent(self.renewBtn_dia,onBtnClickHandler)
  167. end
  168. function SpecialEquipExpiredView:UpdateView( )
  169. if self.type == 1 then
  170. --可能在背包也可能在身上
  171. --local goodsVo = GoodsModel:getInstance():GetBagGoodsInfoById(self.goods_id)
  172. local goodsVo = EquipModel:getInstance():GetEquipById(self.goods_id)
  173. if not goodsVo then
  174. goodsVo = GoodsModel:getInstance():GetBagGoodsInfoById(self.goods_id)
  175. end
  176. --PrintTable(goodsVo)
  177. if not goodsVo then return end
  178. if goodsVo.type_id == 1011000003 or goodsVo.type_id == 1011000004 then
  179. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goodsVo.type_id)
  180. self.renewBtn_dia:SetActive(false)
  181. self.renewBtn.transform.localPosition = Vector2(55,-186)
  182. self.type_id = goodsVo.type_id
  183. self.awardItem:SetData(basic.type_id, 1)
  184. self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
  185. self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
  186. self.price = Config.Goodsrenew[self.type_id.."@1"].price
  187. else
  188. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goodsVo.type_id)
  189. self.type_id = goodsVo.type_id
  190. self.awardItem:SetData(basic.type_id, 1)
  191. self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
  192. self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
  193. self.price = Config.Goodsrenew[self.type_id.."@1"].price
  194. self.dia_cost.text = Config.Goodsrenew[self.type_id.."@2"].price
  195. self.dia_price = Config.Goodsrenew[self.type_id.."@2"].price
  196. end
  197. else
  198. if goodsVo.type_id == 1011000003 or goodsVo.type_id == 1011000004 then
  199. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(goodsVo.type_id)
  200. self.renewBtn_dia:SetActive(false)
  201. self.renewBtn.transform.localPosition = Vector2(55,-186)
  202. self.type_id = goodsVo.type_id
  203. self.awardItem:SetData(basic.type_id, 1)
  204. self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
  205. self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
  206. self.price = Config.Goodsrenew[self.type_id.."@1"].price
  207. self.renewBtn_text.text = "购买"
  208. else
  209. local basic = GoodsModel:getInstance():GetGoodsBasicByTypeId(self.goods_id)
  210. self.type_id = self.goods_id
  211. self.awardItem:SetData(basic.type_id, 1)
  212. self.name.text = string.format("<color='%s'>%s</color>", ColorUtil:GetColor(basic.color), basic.goods_name)
  213. self.cost.text = Config.Goodsrenew[self.type_id.."@1"].price
  214. self.price = Config.Goodsrenew[self.type_id.."@1"].price
  215. self.dia_cost.text = Config.Goodsrenew[self.type_id.."@2"].price
  216. self.dia_price = Config.Goodsrenew[self.type_id.."@2"].price
  217. self.renewBtn_text.text = "购买"
  218. self.renewBtn_dia_text.text = "购买"
  219. end
  220. end
  221. local res,title_res
  222. if (self.type_id == 1011000001 or self.type_id == 1011000005) then
  223. res = "icon_bygz_1"
  224. title_res = "icon_jyjc"
  225. elseif self.type_id == 1011000003 then
  226. res = "icon_bygz_2"
  227. title_res = "icon_jyjc_2"
  228. elseif self.type_id == 1011000002 then
  229. res = "icon_byts"
  230. title_res = "icon_jyjc_1"
  231. else
  232. res = "icon_bygz_3"
  233. title_res = "icon_jyjc_3"
  234. end
  235. if not res then return end
  236. lua_resM:setImageSprite(self,self.flag,"treasureHunt_asset",res)
  237. lua_resM:setImageSprite(self,self.title,"treasureHunt_asset",title_res)
  238. end