源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1123 lines
35 KiB

  1. BagView = BagView or BaseClass(BaseItem)
  2. function BagView:__init(parent_wnd, prefab_asset, layer_name)
  3. self.base_file = "bag"
  4. self.layout_file = "bagView"
  5. self.column_num = 4 --一行多少个图标
  6. self.mainVo = RoleManager.Instance.mainRoleInfo
  7. self.model = GoodsModel:getInstance()
  8. self.equip_model = EquipModel:getInstance()
  9. self.equip_item_list = {} --装备格子
  10. self.bagModel = BagModel:getInstance()
  11. self.is_delay_callback = true
  12. self.need_sort = true
  13. self.is_click_sort = false
  14. self.hide_clear_role_model = false
  15. self.visible = true
  16. self.click_item_index = false
  17. local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  18. self.max_equip_suit = len
  19. self.full_screen = true
  20. self.ani_right = 400
  21. self.ani_left = -200
  22. self.adjust_mid = {left = 160, right = 780}
  23. --标题tabbar
  24. self.titleTabbar_list = {}
  25. self.titleTabbar_text = {}
  26. self.titleTabbar = {[1] = "全部",[2] = "常用",[3] = "礼包"}
  27. self.title_cur_index = 1
  28. self.loop_mgr = LoopScrowViewMgr.New()
  29. self.bag_item_list = {}
  30. self.event_list = {}
  31. self.suit_tab_list = {}
  32. self.timeout_goods_id_list = {} --超时的道具检测id缓存列表,在此列表中的道具,不再刷新道具过期标志
  33. self.equip_suit_id = self.model:GetBagEquipChooseIndex() or 1--装备套件ID
  34. EquipModel:getInstance().cur_choose_suit = 1 or RoleManager:getInstance():GetMainRoleVo().turn--装备套件ID
  35. self:Load()
  36. end
  37. --清除界面
  38. function BagView:__delete()
  39. self:Remove()
  40. end
  41. function BagView:Load_callback()
  42. self:LoadSuccess()
  43. self:InitEvent()
  44. end
  45. function BagView:Remove()
  46. TimeManager.GetInstance():CancelTime("BagView_SetEquipData")
  47. TimeManager.GetInstance():CancelTime("BagView_ClearTimeOutProps")
  48. self.bagModel:Fire(BagModel.OPEN_DEPOT_VIEW,true)
  49. self.bagModel:Fire(BagModel.CLOSE_SELL_VIEW)
  50. self.bagModel.IsOnClickSwallow = false
  51. lua_resM:clearRoleMode(self)
  52. UnregisterFraming(self)
  53. self:StopCountDown()
  54. for i = 1,#self.bag_item_list do
  55. self.bag_item_list[i]:DeleteMe()
  56. end
  57. self.bag_item_list = nil
  58. for i,v in ipairs(self.equip_item_list) do
  59. v:DeleteMe()
  60. v = nil
  61. end
  62. self.equip_item_list = {}
  63. for i,v in ipairs(self.suit_tab_list) do
  64. v:DeleteMe()
  65. v = nil
  66. end
  67. self.suit_tab_list = {}
  68. for k,v in pairs(self.event_list) do
  69. self.model:UnBind(v)
  70. end
  71. self.event_list = {}
  72. if self.level_item then
  73. self.level_item:DeleteMe()
  74. self.level_item = nil
  75. end
  76. if self.change_name_id then
  77. self.mainVo:UnBind(self.change_name_id)
  78. self.change_name_id = nil
  79. end
  80. if self.change_level_id then
  81. self.mainVo:UnBind(self.change_level_id)
  82. self.change_level_id = nil
  83. end
  84. if self.change_jin_id then
  85. self.mainVo:UnBind(self.change_jin_id)
  86. self.change_jin_id = nil
  87. end
  88. if self.change_lockJin_id then
  89. self.mainVo:UnBind(self.change_lockJin_id)
  90. self.change_lockJin_id = nil
  91. end
  92. if self.change_tong_id then
  93. self.mainVo:UnBind(self.change_tong_id)
  94. self.change_tong_id = nil
  95. end
  96. if self.change_honor_id then
  97. self.mainVo:UnBind(self.change_honor_id)
  98. self.change_honor_id = nil
  99. end
  100. self.mainVo = nil
  101. if self.dynamic_event_id then
  102. GlobalEventSystem:UnBind(self.dynamic_event_id)
  103. self.dynamic_event_id = nil
  104. end
  105. if self.loop_mgr then
  106. self.loop_mgr:DeleteMe()
  107. self.loop_mgr = nil
  108. end
  109. if self.maskID then
  110. self:UnRegisterMask(self.maskID)
  111. self.maskID = nil
  112. end
  113. if self.coinBar then
  114. self.coinBar:DeleteMe()
  115. self.coinBar = nil
  116. end
  117. if self.delay_load_id then
  118. GlobalTimerQuest:CancelQuest(self.delay_load_id)
  119. self.delay_load_id = false
  120. end
  121. if self.step_sort_bag_cd_id then
  122. GlobalTimerQuest:CancelQuest(self.step_sort_bag_cd_id)
  123. self.step_sort_bag_cd_id = nil
  124. end
  125. if self.evil_item then
  126. self.evil_item:DeleteMe()
  127. end
  128. if self.tabScroll_scroll then
  129. self.tabScroll_scroll.onValueChanged:RemoveAllListeners()
  130. end
  131. EquipModel:getInstance().cur_choose_suit = nil
  132. -- 如果存在模糊背景图,则需要传到C#中销毁
  133. -- if self.blur_bg_mask_screenshot then
  134. -- MainCamera.Instance:ClearScreenShotCache(self.blur_bg_mask_screenshot)
  135. -- end
  136. end
  137. function BagView:LoadSuccess()
  138. if self.mainVo == nil then
  139. print("报错了。。。主角数据为nil")
  140. end
  141. local nodes = {
  142. "mid/RolePanel/roleCon:obj",
  143. "mid/evilCon:obj",
  144. "right/contain/sortBtn:obj:img",
  145. "right/contain/currencyExchangeBtn:obj",
  146. "mid/RolePanel/allContent/stone:obj",
  147. "mid/RolePanel/allContent/star:obj",
  148. "mid/RolePanel/allContent/strength:obj",
  149. "mid/RolePanel/roleInfoBg/lblInfo:txt",
  150. "left:obj",
  151. "mid:obj",
  152. "left/left_equip_conta:obj",
  153. "right/contain/right_equip_conta:obj",
  154. "mid/mid_equip_conta:obj",
  155. "left/left_btn:obj",
  156. "right/contain/right_btn:obj",
  157. "left/star_tip_btn:obj",
  158. "left/star_tip_btn/star_tip_red_dot:obj",
  159. "left/star_tip_btn/star_tip_num:tmp",
  160. "left/tab_bg:obj",
  161. "left/tabScroll:scroll",
  162. "left/tabScroll/Viewport/tab_con",
  163. "mid/suit_pwoer:txt:obj",
  164. "mid/power_bg:obj",
  165. "mid/suit_power_bg:obj",
  166. "left/down_btn:obj",
  167. "mid/bg_mask:obj:rawex",
  168. "right/contain:obj",
  169. -- "left/star_tip_btn/star_tip_text:tmp",
  170. --宝石星级套装
  171. "left/suit_btn/suit_num:tmp",
  172. "left/suit_btn:obj",
  173. "left/suit_btn/suit_btn_red_dot:obj",
  174. --橙品套装
  175. "left/suitNumBtn:obj",
  176. -- "left/suitNumBtn/suitNumBtnText:tmp",
  177. "left/suitNumBtn/suitNumBtnNumText:tmp",
  178. "left/suitNumBtn/suitNumBtnRedDot:obj",
  179. -- 套装收集
  180. "left/equipCollectBtn:obj",
  181. "left/equipCollectBtn/equipCollectBtnNumText:tmp",
  182. "left/equipCollectBtn/equipCollectBtnRedDot:obj:img",
  183. }
  184. self:GetChildren(nodes)
  185. -- self.suitNumBtnText_tmp.text = "橙品套装 >>"
  186. -- self.star_tip_text_tmp.text = "装备星级 >>"
  187. self.bg_mask_rawex.alpha = 0.8
  188. self.bg_mask_obj:SetActive(false)
  189. self.bg_mask_rawex.transform.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight)
  190. self.scroll,self.scroll_content,self.con,self.level_con = GetChildTransforms(self.transform,
  191. {
  192. "right/contain/ScrollView","right/contain/ScrollView/Viewport/Content","right/contain/ScrollView/Viewport/Content/con","mid/RolePanel/roleInfoBg/con"
  193. })
  194. for i=1,#self.titleTabbar do
  195. table.insert(self.titleTabbar_list,self:GetChild("right/contain/titleBarCon/tabbar"..i).gameObject)
  196. table.insert(self.titleTabbar_text,self:GetChild("right/contain/titleBarCon/tabbar"..i.."/Background/Text"):GetComponent("TextMeshProUGUI"))
  197. end
  198. self.scroll_image = self:GetChild("right/contain/ScrollView/Viewport"):GetComponent("Image")
  199. self.sortBtn_txt = self:GetChild("right/contain/sortBtn/Text"):GetComponent("TextMeshProUGUI")
  200. self.currency_exchange_red = self:GetChild("right/contain/currencyExchangeBtn/red").gameObject
  201. self.maskID = self:RegisterMask(self.scroll_image)
  202. self:SetRoleLevelName()
  203. self:SetTextColor(self.title_cur_index)
  204. self:UpdateBagItems(true)
  205. self:ClearTimeOutProps()
  206. -- local b = GetModuleIsOpen(152,7, true)
  207. -- self.suit_btn_obj:SetActive(b)
  208. self:UpdateEquipCollectBtn()
  209. self:UpdateEquipCollectBtnRed()
  210. local function call_back()
  211. self:SetUIDepth(self.left_equip_conta.gameObject)
  212. self:SetUIDepth(self.right_equip_conta.gameObject)
  213. self:UpdateSuitTab()
  214. end
  215. local res_data = {
  216. father_node = self,
  217. transform = self.roleCon,
  218. fashion_type = FuncOpenModel.TypeId.Clothes,
  219. size = Vector2(720,720),
  220. position = Vector3.zero,
  221. scale = 270,
  222. ui_model_type = UIModelCommon.ModelType.BackModel,
  223. dynamic_bone = true,
  224. use_green_screen = true,
  225. green_screen_camera_type = 3, -- camera_type:1 主摄像机 2 UI摄像机 3 UIModel摄像机
  226. callBack = call_back,
  227. }
  228. FuncOpenModel:getInstance():SetModelRes(res_data)
  229. RegisterFraming(self,{
  230. -- self.UpdateBagItems,
  231. self.OnInitializeItem,
  232. self.UpdateItemState,
  233. },true,0.05)
  234. self:SetCustomVisible(self.visible)
  235. if self.tabScroll_scroll then
  236. self.tabScroll_scroll.onValueChanged:RemoveAllListeners()
  237. self.tabScroll_scroll.onValueChanged:AddListener(function()
  238. self:WrapContent()
  239. end)
  240. end
  241. self.bagModel:RequestCurrencyExchangeRed() --打开背包的时候,在检测一次免费兑换次数,刷新红点
  242. --幻光技能特效隐藏测试
  243. GlobalEventSystem:Fire(EventName.HIDE_LIGHT_EFFCT_ICON)
  244. self:UpdateSuitPower()
  245. end
  246. function BagView:InitEvent()
  247. local function onBtnClickHandler(target)
  248. if target == self.sortBtn_obj then
  249. self.need_sort = true
  250. self.is_click_sort = true
  251. if BagModel:getInstance():TrySortBag(GoodsModel.GOODS_POS_TYPE.bag) then
  252. self.model:DelayFire(GoodsModel.CHANGE_BAGLIST)
  253. end
  254. self:UpdateSortCD()
  255. elseif target == self.currencyExchangeBtn_obj then
  256. BagModel:getInstance():Fire(BagModel.OPEN_CURRENCY_EXCHANGE_VIEW)
  257. elseif target == self.stone_obj then
  258. self.bagModel:Fire(BagModel.OPEN_ALL_ADDITION_VIEW, 3)
  259. elseif target == self.star_obj then
  260. self.bagModel:Fire(BagModel.OPEN_ALL_ADDITION_VIEW, 2)
  261. elseif target == self.strength_obj then
  262. self.bagModel:Fire(BagModel.OPEN_ALL_ADDITION_VIEW, 1)
  263. elseif target == self.left_btn_obj then
  264. if self.equip_suit_id - 1 >= 0 then
  265. self:UpdateSuitState(self.equip_suit_id - 1)
  266. else
  267. Message.show("最左边了哦!")
  268. end
  269. elseif target == self.right_btn_obj then
  270. if self.equip_suit_id + 1 <= self.max_equip_suit then
  271. self:UpdateSuitState(self.equip_suit_id + 1)
  272. else
  273. Message.show("最右边了哦!")
  274. end
  275. elseif target == self.star_tip_btn_obj then
  276. OpenFun.Open(152,999)
  277. elseif target == self.left_btn_obj then
  278. if self.equip_suit_id - 1 >= 0 then
  279. self:UpdateSuitState(self.equip_suit_id - 1)
  280. else
  281. Message.show("最左边了哦!")
  282. end
  283. elseif target == self.right_btn_obj then
  284. if self.equip_suit_id + 1 <= self.max_equip_suit then
  285. self:UpdateSuitState(self.equip_suit_id + 1)
  286. else
  287. Message.show("最右边了哦!")
  288. end
  289. elseif target == self.down_btn_obj then
  290. self.tab_con.localPosition = Vector2(0, -2 + (#self.suit_tab_list- 1) * BagSuitTab.Height)
  291. elseif target == self.suit_btn_obj then
  292. self.equip_model:Fire(EquipModel.OPEN_GEMSTONE_SUIT_VIEW,self.equip_suit_id)
  293. elseif target == self.suitNumBtn_obj then
  294. BagModel:getInstance():Fire(BagModel.OPEN_EQUIP_ORANGE_SUIT_VIEW,self.equip_suit_id)
  295. elseif target == self.equipCollectBtn_obj then
  296. OpenFun.Open(145,1)
  297. else
  298. for i,v in ipairs(self.titleTabbar) do
  299. local obj = self.titleTabbar_list[i]
  300. if target == obj then
  301. self.title_cur_index = i
  302. self.click_item_index = false
  303. self:SetTextColor(self.title_cur_index)
  304. self:UpdateBagItems(true)
  305. self.loop_mgr:RestToBeginning()
  306. break
  307. end
  308. end
  309. end
  310. end
  311. AddClickEvent(self.sortBtn_obj,onBtnClickHandler)
  312. AddClickEvent(self.currencyExchangeBtn_obj,onBtnClickHandler)
  313. AddClickEvent(self.stone_obj, onBtnClickHandler)
  314. AddClickEvent(self.star_obj, onBtnClickHandler)
  315. AddClickEvent(self.strength_obj, onBtnClickHandler)
  316. AddClickEvent(self.left_btn_obj, onBtnClickHandler)
  317. AddClickEvent(self.right_btn_obj, onBtnClickHandler)
  318. AddClickEvent(self.star_tip_btn_obj, onBtnClickHandler)
  319. AddClickEvent(self.down_btn_obj, onBtnClickHandler)
  320. AddClickEvent(self.suit_btn_obj, onBtnClickHandler)
  321. AddClickEvent(self.suitNumBtn_obj, onBtnClickHandler)
  322. AddClickEvent(self.equipCollectBtn_obj, onBtnClickHandler)
  323. for i=1,#self.titleTabbar do
  324. AddClickEvent(self.titleTabbar_list[i],onBtnClickHandler)
  325. end
  326. local function onChangeBagListHandler()
  327. if self._use_delete_method then return end
  328. self:DelayShow()
  329. end
  330. self.event_list[1] = self.model:Bind(GoodsModel.CHANGE_BAGLIST,onChangeBagListHandler)
  331. local function onChangeBagListHandler2()
  332. self:DelayShow()
  333. end
  334. self.event_list[2] = self.model:BindOne("slot_info_pos_2",onChangeBagListHandler2)
  335. -- local update_equip = function ()
  336. -- if not self.is_loaded then return end
  337. -- local active_list = EquipModel:getInstance():GetCurSuitInfo()
  338. -- local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  339. -- self.max_equip_suit = len
  340. -- local active_list = EquipModel:getInstance():GetCurSuitInfo()
  341. -- local config = Config.Equipmentseriesopen
  342. -- for i=1,self.equip_suit_tab_max do
  343. -- local item = self.suit_tab_list[i]
  344. -- if item then
  345. -- item:SetData(active_list[i],i,config[i], i == self.equip_suit_tab_max)
  346. -- end
  347. -- end
  348. -- end
  349. -- self.event_list[3] = self.model:Bind(GoodsModel.CHANGE_EQUIPLIST, update_equip)
  350. local click_fun = function (index,pos_type)
  351. if pos_type == GoodsModel.GOODS_POS_TYPE.bag then
  352. self.click_item_index = index
  353. self:UpdateItemState(index)
  354. end
  355. end
  356. self.event_list[4] = self.model:Bind(GoodsModel.CLICK_BAG_ITEM, click_fun)
  357. local function onChangeInfoHandler()
  358. self:SetRoleLevelName()
  359. self:UpdateEquipCollectBtn()
  360. end
  361. self.change_name_id = self.mainVo:BindOne("name",onChangeInfoHandler)
  362. self.change_level_id = RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL,onChangeInfoHandler)
  363. local function onChangeMoneyHandler()
  364. if self._use_delete_method then return end
  365. self:DoSetEquipData()
  366. end
  367. self.change_jin_id = self.mainVo:BindOne("jin",onChangeMoneyHandler)
  368. self.change_lockJin_id = self.mainVo:BindOne("jinLock",onChangeMoneyHandler)
  369. self.change_tong_id = self.mainVo:BindOne("tong",onChangeMoneyHandler)
  370. self.change_honor_id = self.mainVo:BindOne("honor",onChangeMoneyHandler)
  371. --更新星级套装红点
  372. local function equipStarRedFunc( ... )
  373. self:SetEquipStarTipRed()
  374. self:UpdateSuitTabRed()
  375. self:DoSetEquipData()
  376. end
  377. self:BindEvent(EquipModel:getInstance(), EquipModel.INFO_UPDATE, equipStarRedFunc)
  378. equipStarRedFunc()
  379. --装备升品操作
  380. local function onUpdateComposeEvent()
  381. self:DoSetEquipData()
  382. end
  383. self:BindEvent(ComposeModel:getInstance(), ComposeModel.UPDATE_COMPOSE_VIEW_RED, onUpdateComposeEvent)
  384. --装备战力变化
  385. local function onUpdateEquipPower()
  386. self:UpdateSuitPower()
  387. end
  388. self:BindEvent(EquipModel:getInstance(), EquipModel.UPDATE_EQUIP_POWER, onUpdateEquipPower)
  389. --更新星级套装红点
  390. local function updateSuitInde( ... )
  391. if not self.is_loaded then return end
  392. local suit_id = self.model:GetBagEquipChooseIndex()
  393. self:UpdateSuitState(suit_id)
  394. end
  395. self:BindEvent(GoodsModel:getInstance(),GoodsModel.UPDATE_BAG_EQUIP_SUIT_CHOOSE, updateSuitInde)
  396. local function UpdateEquipSeriesOrangeNum( ... )
  397. if not self.is_loaded then return end
  398. self.suitNumBtnNumText_tmp.text = string.format("%s/10",GoodsModel:getInstance():GetEquipCurSuitOrangeNum(self.equip_suit_id))
  399. self:UpdateEquipSuitRedDot()
  400. end
  401. self:BindEvent(GlobalEventSystem,EventName.UPDATE_BAG_RED,UpdateEquipSeriesOrangeNum)
  402. --更新宝石等级
  403. local function update_gamestone()
  404. if not self.is_loaded then return end
  405. -- self:UpdateEquipGemStone()
  406. self:UpdateEquipSuitRedDot()
  407. end
  408. self:BindEvent(EquipModel.getInstance(), EquipModel.UPDATE_VIEW_RED, update_gamestone)
  409. --刷新交易券兑换
  410. local function update_currency_exchange_red()
  411. self:UpdateSuitTabRed()
  412. self:SetCurrencyExchangeRed()
  413. end
  414. self:BindEvent(BagModel.Instance,BagModel.ANS_UPDATE_CURRENCY_EXCHANGE_RED,update_currency_exchange_red)
  415. self:BindEvent(GlobalEventSystem,EventName.UPDATE_BAG_RED,update_currency_exchange_red)
  416. update_currency_exchange_red()
  417. local function sort_bag_after_swallow()
  418. self.need_sort = true
  419. if BagModel:getInstance():TrySortBag(GoodsModel.GOODS_POS_TYPE.bag) then
  420. self.model:DelayFire(GoodsModel.CHANGE_BAGLIST)
  421. end
  422. self:UpdateSortCD()
  423. end
  424. self:BindEvent(BagModel.Instance,BagModel.SORT_BAG_AFTER_SWALLOW,sort_bag_after_swallow)
  425. local function update_bag_timeout_goods(goods_id)
  426. if self.timeout_goods_id_list[goods_id] then
  427. return
  428. end
  429. self.timeout_goods_id_list[goods_id] = true
  430. self:UpdateGoodsLimitTime()
  431. end
  432. self:BindEvent(GlobalEventSystem, EventName.UPDATE_BAG_TIMEOUT_GOODS, update_bag_timeout_goods)
  433. local function update_equip_max_series(suit_id)
  434. self:UpdateSuitState(suit_id)
  435. self:UpdateDownObj()
  436. end
  437. self:BindEvent(EquipModel.getInstance(), EquipModel.UPDATE_EQUIP_MAX_SERIES, update_equip_max_series)
  438. --更新装备穿戴特效
  439. local function onPlayWearEquipmentEffect(pos)
  440. self:AddEffect(pos)
  441. end
  442. self:BindEvent(GoodsModel:getInstance(),GoodsModel.PLAY_WEAR_EQUIPMENT_EFFECT, onPlayWearEquipmentEffect)
  443. ----------装备考核-start---------
  444. local function on_task_icon_open( task_id )--任务
  445. if Config.Moduleid[145].task_id == task_id then
  446. self:UpdateEquipCollectBtn()
  447. end
  448. end
  449. self:BindEvent(GlobalEventSystem, TaskEvent.ANS_FINISHED_TASK_LIST, on_task_icon_open)
  450. local function on_init_open_day( ... )
  451. self:UpdateEquipCollectBtn()
  452. end
  453. self:BindEvent(GlobalEventSystem, EventName.OPEN_DAY_INIT, on_init_open_day)
  454. local function on_update_equip_collect_btn_red( ... )
  455. self:UpdateEquipCollectNum()
  456. self:UpdateEquipCollectBtnRed()
  457. end
  458. self:BindEvent(EquipCollectModel:getInstance(), EquipCollectConst.ANS_UPDATE_EQUIP_COLLECT_RED_DOT, on_update_equip_collect_btn_red)
  459. ----------装备考核-end-----------
  460. local function on_update( ... )
  461. self:UpdateEquipCollectBtn()
  462. end
  463. self:BindEvent(self.model, EquipCollectConst.ANS_EQUIP_COLLECT_INFO, on_update)
  464. end
  465. function BagView:SetCurrencyExchangeRed( )
  466. -- local bool = BagModel:getInstance():GetCurrencyExchangeRed()
  467. -- self.currency_exchange_red:SetActive(bool)
  468. end
  469. function BagView:DelayShow( )
  470. self:StopCountDown()
  471. local function show( )
  472. self:StopCountDown()
  473. self:UpdateBagItems()
  474. end
  475. self.timer_countdown = TimerQuest.AddPeriodQuest(GlobalTimerQuest,show,0.4)
  476. end
  477. function BagView:StopCountDown()
  478. if self.timer_countdown then
  479. TimerQuest.CancelQuest(GlobalTimerQuest, self.timer_countdown)
  480. self.timer_countdown = nil
  481. end
  482. end
  483. function BagView:SetTextColor( )
  484. for i,v in ipairs(self.titleTabbar_text) do
  485. if self.title_cur_index == i then
  486. v.text = "<color=#ffffff>"..self.titleTabbar[i].."</color>"
  487. SetTMPSharedMaterial(v, ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab)
  488. else
  489. v.text = "<color=#9eb3cf>"..self.titleTabbar[i].."</color>"
  490. SetTMPSharedMaterial(v, ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
  491. end
  492. end
  493. end
  494. function BagView:UpdateBagItems(to_top)
  495. local item = nil
  496. local info = self.model.slot_info_pos_2
  497. local slot_num = info.slot_num or 0 --开放格子
  498. local all_slot = info.all_slot or 0 --总共格子
  499. self.curr_list = {}
  500. local bag_goods_list = self.model.bag_goods_list or {}
  501. if self.need_sort then
  502. self.need_sort = false
  503. self.model:SortBagListByBagView(bag_goods_list)
  504. self.model.bag_goods_list = bag_goods_list
  505. if self.is_click_sort then
  506. ItemUseModel:getInstance():InitBagGoodsDicOnSort(self.model.bag_goods_list)
  507. end
  508. self.is_click_sort = false
  509. end
  510. local m_index = 1
  511. for k,v in pairs(bag_goods_list) do
  512. if self.title_cur_index == 2 then --常用(消耗 3 和 碎片 4)
  513. if self.model:GetGoodsTab(v.type, v.subtype) == 3 or self.model:GetGoodsTab(v.type, v.subtype) == 4 then
  514. self.curr_list[m_index] = v
  515. self.curr_list[m_index].index = m_index
  516. m_index = m_index + 1
  517. end
  518. elseif self.title_cur_index == 3 then --礼包
  519. if self.model:GetGoodsTab(v.type, v.subtype) == 5 then
  520. self.curr_list[m_index] = v
  521. self.curr_list[m_index].index = m_index
  522. m_index = m_index + 1
  523. end
  524. else --全部
  525. self.curr_list[k] = v
  526. self.curr_list[k].index = k
  527. end
  528. end
  529. for k = #self.curr_list + 1,slot_num do
  530. self.curr_list[k] = {type_id = 0, goods_num = 0,index = k}
  531. end
  532. for k = slot_num + 1,all_slot do
  533. self.curr_list[k] = {lock_index = k - slot_num,index = k}
  534. end
  535. for k = 1,30 do
  536. local item = self.bag_item_list[k]
  537. if item == nil then
  538. item = BagItem.New(self.con,nil,self.maskID)
  539. self.bag_item_list[k] = item
  540. item:SetPosType(GoodsModel.GOODS_POS_TYPE.bag)
  541. end
  542. end
  543. if to_top then
  544. self.loop_mgr:Init(self.scroll,self.scroll_content,self.column_num,89.5,89.5,function(item,index,realIndex )
  545. self:OnInitializeItem(item,index,realIndex)
  546. end, 0, 0, {x=10,y=-6})
  547. self.loop_mgr:InitChildren(self.bag_item_list, #self.curr_list)
  548. self.loop_mgr:RestToBeginning()
  549. self.loop_mgr:SetContentSizeData()
  550. else
  551. self.loop_mgr:InitChildren(self.bag_item_list, #self.curr_list)
  552. self.loop_mgr:ForceUpdateCurrentItems()
  553. self.loop_mgr:SetContentSizeData()
  554. end
  555. end
  556. function BagView:OnInitializeItem(item,index,realIndex)
  557. if item and realIndex > 0 and realIndex <= #self.curr_list then
  558. local data = self.curr_list[realIndex]
  559. if data ~= nil then
  560. local spe_color
  561. if data.type == 12 then --时装在背包中特殊显示特效
  562. spe_color = data.color
  563. elseif data.type_id and data.type_id >= 36040001 and data.type_id <= 36040004 then
  564. spe_color = 3
  565. end
  566. local isHide = nil
  567. if data.color and data.color <= 3 then
  568. isHide = true
  569. else
  570. isHide = false
  571. end
  572. item:SetData(data, self.maskID, isHide, spe_color, "BagView")
  573. self:UpdateItemState()
  574. else
  575. item:SetVoid()
  576. end
  577. end
  578. end
  579. function BagView:UpdateItemState()
  580. if not self.click_item_index then return end
  581. for k,item in pairs(self.bag_item_list) do
  582. item:SetSelect(item.index == self.click_item_index)
  583. end
  584. end
  585. --设置装备数据
  586. function BagView:SetEquipData()
  587. local wear_suit_list = GoodsModel:getInstance().wear_equip_suit_list
  588. local list = GoodsModel:getInstance().wear_equip_suit_list[self.equip_suit_id] or {}
  589. local index_key_list = {}
  590. local empty_key_list = {}
  591. for k,v in pairs(Config.ConfigEquipShow) do
  592. empty_key_list[v.index] = {}
  593. empty_key_list[v.index].equip_suit_type = v.cell
  594. end
  595. for _,vo in pairs(list) do
  596. local index = Config.ConfigEquipShow[vo.equip_suit_type] and Config.ConfigEquipShow[vo.equip_suit_type].index or 0
  597. index_key_list[index] = vo
  598. end
  599. -- print("huangcong:BagView [start:414] index_key_list:", index_key_list)
  600. -- PrintTable(index_key_list)
  601. -- print("huangcong:BagView [end]")
  602. if self.delay_load_id then
  603. GlobalTimerQuest:CancelQuest(self.delay_load_id)
  604. self.delay_load_id = false
  605. end
  606. local frame_count = 0
  607. local pos_t =
  608. {
  609. [1] = {x = 955, y = -25, p = 1},
  610. [2] = {x = 1043, y = -25, p = 1},
  611. [3] = {x = 955, y = -116, p = 1},
  612. [4] = {x = 1043, y = -116, p = 1},
  613. [5] = {x = 955, y = -205, p = 1},
  614. [6] = {x = 1043, y = -205, p = 1},
  615. [7] = {x = 955, y = -295, p = 1},
  616. [8] = {x = 1043, y = -295, p = 1},
  617. [9] = {x = 955, y = -385, p = 1},
  618. [10] = {x = 1043, y = -385, p = 1},
  619. --[11] = {x = 1128, y = -295, p = 1},
  620. [11] = {x = 1128, y = -385, p = 1},
  621. }
  622. local function frame_func( )
  623. frame_count = frame_count + 1
  624. if frame_count == 12 then --结束
  625. -- item:SetRingShow()
  626. if self.delay_load_id then
  627. GlobalTimerQuest:CancelQuest(self.delay_load_id)
  628. self.delay_load_id = false
  629. end
  630. return
  631. end
  632. local item = self.equip_item_list[frame_count]
  633. if not item and pos_t[frame_count] then
  634. if pos_t[frame_count].p == 3 then
  635. item = EquipItem.New(self.mid_equip_conta, nil, self.layer_name, true)
  636. elseif pos_t[frame_count].p == 2 then
  637. item = EquipItem.New(self.right_equip_conta, nil, self.layer_name, true)
  638. else
  639. item = EquipItem.New(self.left_equip_conta, nil, self.layer_name, true)
  640. end
  641. self.equip_item_list[frame_count] = item
  642. item:SetEquipStyle(frame_count)
  643. local x = pos_t[frame_count].x
  644. local y = pos_t[frame_count].y
  645. item:SetPosition(x, y)
  646. end
  647. local vo = index_key_list[frame_count]
  648. --item:SetBgAlpha((vo and frame_count == 11) and 0 or 1)
  649. if vo then
  650. item:SetData(vo)
  651. item:SetPosType(vo.equip_suit_type, false, self.equip_suit_id, true)
  652. else
  653. item:ClearData()
  654. item:SetPosType(empty_key_list[frame_count].equip_suit_type, true, self.equip_suit_id , true)
  655. end
  656. --更新守护模型
  657. if frame_count == 11 then
  658. self:UpdateEvilMomodel(index_key_list[frame_count])
  659. end
  660. if frame_count == 12 then
  661. --羁绊信物显示
  662. item:SetRingShow()
  663. end
  664. end
  665. frame_func()
  666. if not self.delay_load_id then
  667. self.delay_load_id = GlobalTimerQuest:AddPeriodQuest(frame_func, 0.01)
  668. end
  669. end
  670. function BagView:SetRoleLevelName()
  671. if self.mainVo then
  672. local lv = WordManager:GetRoleLevel(self.mainVo.level,self.mainVo.turn,true,false)
  673. self.lblInfo_txt.text = self.mainVo.name.." "
  674. local name_len = self.lblInfo_txt.preferredWidth
  675. if WordManager:RoleLevelIsTop(self.mainVo.level,self.mainVo.turn) then
  676. self.lblInfo_txt.text = self.mainVo.name.." "..lv
  677. else
  678. self.lblInfo_txt.text = self.mainVo.name.." "..lv
  679. end
  680. local text_len = self.lblInfo_txt.preferredWidth
  681. local pos = name_len - text_len/2 + 3
  682. end
  683. end
  684. function BagView:UpdateSortCD( )
  685. if not self.is_loaded then return end
  686. local last_sort_bag_time = BagModel:getInstance():GetLastSortBagTime(GoodsModel.GOODS_POS_TYPE.bag)
  687. if not last_sort_bag_time then
  688. self.sortBtn_img.color = ColorUtilValue.WHITE
  689. self.sortBtn_txt.text = "整理"
  690. return
  691. end
  692. local function step_sort_bag_cd( ... )
  693. local left_cd = 5 - (Time.time - last_sort_bag_time)
  694. if left_cd > 0 then
  695. self.sortBtn_txt.text = math.ceil(left_cd)
  696. self.sortBtn_img.color = Color(148/255,148/255,148/255)
  697. else
  698. self.sortBtn_img.color = ColorUtilValue.WHITE
  699. self.sortBtn_txt.text = "整理"
  700. if self.step_sort_bag_cd_id then
  701. GlobalTimerQuest:CancelQuest(self.step_sort_bag_cd_id)
  702. self.step_sort_bag_cd_id = nil
  703. end
  704. end
  705. end
  706. step_sort_bag_cd()
  707. if not self.step_sort_bag_cd_id then
  708. self.step_sort_bag_cd_id = GlobalTimerQuest:AddPeriodQuest(step_sort_bag_cd, 1, -1)
  709. end
  710. end
  711. --隐藏装备区域
  712. function BagView:SetCustomVisible(b)
  713. self.visible = b
  714. if not self.is_loaded then return end
  715. -- self.right_btn_obj:SetActive(b)
  716. self.mid_obj:SetActive(b)
  717. self.left_obj:SetActive(b)
  718. self.right_equip_conta_obj:SetActive(b)
  719. end
  720. --显示背景模糊蒙版
  721. function BagView:SetBgMaskVisible(b)
  722. self.show_bgmask = b
  723. if not self.is_loaded then return end
  724. if self.show_bgmask then
  725. self.left_obj:SetActive(false)
  726. self.bg_mask_obj:SetActive(true)
  727. self.roleCon_obj:SetActive(false)
  728. self.evilCon_obj:SetActive(false)
  729. self.suit_pwoer_obj:SetActive(false)
  730. self.power_bg_obj:SetActive(false)
  731. self.suit_power_bg_obj:SetActive(false)
  732. -- local function create_bg_makk_blur()
  733. -- if self.blur_bg_mask_screenshot == false or not self.show_bgmask then -- 等待模糊背景返回/获取当前不需要显示该模糊背景
  734. -- self.bg_mask_rawex.alpha = 0
  735. -- elseif self.blur_bg_mask_screenshot then
  736. -- self.bg_mask_rawex.alpha = 1
  737. -- self.bg_mask_rawex.texture = self.blur_bg_mask_screenshot
  738. -- end
  739. -- self.bg_mask_rawex.transform.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight)
  740. -- end
  741. -- if MainCamera.Instance:GetRenderSupport() then
  742. -- self:SetCustomVisible(true)
  743. -- self:SetContainVisible(false)
  744. -- -- 创建回调用来接收RenderTexture
  745. -- local function blur_screenshot_callback(renderTexture)
  746. -- MainCamera.Instance:ClearScreenShotCache(self.blur_bg_mask_screenshot)
  747. -- self.blur_bg_mask_screenshot = renderTexture
  748. -- if self._use_delete_method then return end
  749. -- self:SetCustomVisible(false)
  750. -- self:SetContainVisible(true)
  751. -- self.bg_mask_obj:SetActive(true)
  752. -- create_bg_makk_blur()
  753. -- end
  754. -- MainCamera.Instance:GetCameraBlurScreenShot(blur_screenshot_callback, self.blur_camera_type)
  755. -- else
  756. -- create_bg_makk_blur()
  757. -- end
  758. else
  759. self.roleCon_obj:SetActive(true)
  760. self.evilCon_obj:SetActive(true)
  761. self.left_obj:SetActive(true)
  762. self.bg_mask_obj:SetActive(false)
  763. self.suit_pwoer_obj:SetActive(true)
  764. self.power_bg_obj:SetActive(true)
  765. self.suit_power_bg_obj:SetActive(true)
  766. end
  767. end
  768. --隐藏右侧道具区域
  769. function BagView:SetContainVisible(b)
  770. if not self.is_loaded then return end
  771. self.contain_obj:SetActive(b)
  772. end
  773. --更新装备套件标签
  774. function BagView:UpdateSuitTab( )
  775. for k,v in pairs(self.suit_tab_list) do
  776. v:SetVisible(false)
  777. end
  778. local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
  779. self.max_equip_suit = len
  780. self:UpdateDrectionObj()
  781. local active_list = self.equip_model:GetCurSuitInfo()
  782. -- print("huangcong:BagView [start:532] :", active_list)
  783. -- PrintTable(active_list)
  784. -- print("huangcong:BagView [end]")
  785. local function call_back( equip_suit_id )
  786. self:UpdateSuitState(equip_suit_id)
  787. self:UpdateDownObj()
  788. self:UpdateEquipCollectNum()
  789. end
  790. local offer_x = 0
  791. local offer_y = 0
  792. local x = 0
  793. local y = 0
  794. for i=1,len do
  795. local item = self.suit_tab_list[i]
  796. if item == nil then
  797. item = BagSuitTab.New(self.tab_con,nil,self.layer_name)
  798. self.suit_tab_list[i] = item
  799. item:SetPosition(2,- 2 + ( - BagSuitTab.Height + 4) * (i - 1))
  800. item:SetCallBack(call_back)
  801. end
  802. item:SetData(active_list[i],i,list[i],len)
  803. item:SetVisible(true)
  804. end
  805. local Width = EquipModel.TabLenth[len > 5 and 5 or len]
  806. SetSizeDeltaY(self.tab_con,BagSuitTab.Height*len)
  807. self.tabScroll_scroll.enabled = len > 5
  808. self.tab_bg_obj:SetActive(len > 0)
  809. call_back(self.equip_suit_id)
  810. self:UpdateSuitTabRed()
  811. --新手引导处理
  812. self:AddToStageHandler()
  813. end
  814. --更新标签红点(怎么办 好多啊 我也很绝望啊 啊?)
  815. function BagView:UpdateSuitTabRed( )
  816. for k,v in pairs(self.suit_tab_list) do
  817. v:SetRedDot(false)
  818. end
  819. --------现在背包中,升品,升星,精炼,不需要显示红点------
  820. -- --升星
  821. -- local red_info = EquipModel:getInstance():GetEvolutionSuitTabRedInfo()
  822. -- if red_info then
  823. -- for k,v in ipairs(self.suit_tab_list) do
  824. -- if red_info[k] then
  825. -- v:SetRedDot(true)
  826. -- end
  827. -- end
  828. -- end
  829. -- --精炼
  830. -- local strength_red_info = EquipModel:getInstance().can_strength_info
  831. -- if strength_red_info then
  832. -- for k,v in ipairs(self.suit_tab_list) do
  833. -- local suit_id = k
  834. -- if strength_red_info[suit_id] then
  835. -- for kk,vv in pairs(strength_red_info[suit_id]) do
  836. -- if vv then
  837. -- v:SetRedDot(true)
  838. -- break
  839. -- end
  840. -- end
  841. -- end
  842. -- end
  843. -- end
  844. -- --升品
  845. -- local upquality_red_info = EquipModel:getInstance().can_up_quality_info
  846. -- if upquality_red_info then
  847. -- for k,v in ipairs(self.suit_tab_list) do
  848. -- local suit_id = k
  849. -- if upquality_red_info[suit_id] then
  850. -- for kk,vv in pairs(upquality_red_info[suit_id]) do
  851. -- if vv.can_up == true then
  852. -- v:SetRedDot(true)
  853. -- break
  854. -- end
  855. -- end
  856. -- end
  857. -- end
  858. -- end
  859. end
  860. function BagView:UpdateSuitState( equip_suit_id )
  861. self.equip_suit_id = equip_suit_id
  862. self.suitNumBtnNumText_tmp.text = string.format("%s/10",GoodsModel:getInstance():GetEquipCurSuitOrangeNum(self.equip_suit_id))
  863. self.model:SetBagEquipChooseIndex(self.equip_suit_id)
  864. EquipModel:getInstance().cur_choose_suit = self.equip_suit_id
  865. for k,v in pairs(self.suit_tab_list) do
  866. v:SetChoose(equip_suit_id)
  867. end
  868. self:DoSetEquipData()
  869. self:UpdateDrectionObj()
  870. self:UpdateEquipGemStone()
  871. end
  872. --装备延迟加载
  873. function BagView:DoSetEquipData( )
  874. local function callback( )
  875. self:SetEquipData()
  876. end
  877. TimeManager.GetInstance():StartTime("BagView_SetEquipData", 0.1, callback)
  878. end
  879. function BagView:SetEquipStarTipRed( )
  880. if self.is_loaded then
  881. local star_tip_red = EquipModel:getInstance():GetCurHaveStarRedDot()
  882. self.star_tip_red_dot_obj:SetActive(star_tip_red)
  883. self.star_tip_num_tmp.text = EquipModel:getInstance().equip_sum_stars
  884. end
  885. end
  886. --过期道具检测
  887. function BagView:ClearTimeOutProps( )
  888. if self.bagModel.show_drop_timeout_props_tips then
  889. local function callback()
  890. local bag_goods_list = self.model.bag_goods_list or {}
  891. local t = self.bagModel:GetTimeOutGoodsList(bag_goods_list)
  892. if #t > 0 then
  893. local function ok_callback(bool)
  894. self.bagModel.show_drop_timeout_props_tips = not bool
  895. GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15051, 1 , t)
  896. end
  897. local function cancel_callback(bool)
  898. self.bagModel.show_drop_timeout_props_tips = not bool
  899. end
  900. local d =
  901. {
  902. show_content = "发现背包中有<color=#ff2e65>过期物品</color>堆积,是否丢弃?",
  903. ok_callback = ok_callback,
  904. alert_title = "背包清理",
  905. type = Alert.Type.Four,
  906. defalut_toggle = false,
  907. close_callback = cancel_callback,
  908. cancel_callback = cancel_callback,
  909. }
  910. Alert.showbytable(d)
  911. end
  912. for i,v in ipairs(t) do
  913. self.timeout_goods_id_list[v.goods_id] = true
  914. end
  915. end
  916. TimeManager.GetInstance():StartTime("BagView_ClearTimeOutProps", 0.5, callback)
  917. end
  918. end
  919. function BagView:UpdateGoodsLimitTime()
  920. for i,v in ipairs(self.bag_item_list) do
  921. local goods_id = v:UpdateLimitState()
  922. if goods_id then
  923. self.timeout_goods_id_list[goods_id] = true
  924. end
  925. end
  926. end
  927. function BagView:UpdateEvilMomodel(vo)
  928. if not self.evil_item then
  929. self.evil_item = BagEvilItem.New(self.evilCon,nil,self.layer_name)
  930. end
  931. self.evil_item:SetData(vo and vo.type_id or false)
  932. end
  933. function BagView:UpdateDrectionObj()
  934. self.left_btn_obj:SetActive(self.equip_suit_id ~= 1)
  935. self.right_btn_obj:SetActive(self.equip_suit_id ~= self.max_equip_suit - 1)
  936. end
  937. function BagView:UpdateSuitPower()
  938. self.suit_pwoer_txt.text = EquipModel:getInstance().equip_sum_power
  939. end
  940. function BagView:WrapContent()
  941. self:UpdateDownObj()
  942. end
  943. function BagView:UpdateDownObj()
  944. if #self.suit_tab_list > 5 then
  945. local _, y = GetAnchoredPosition(self.tab_con)
  946. self.down_btn_obj:SetActive(y < 50)
  947. else
  948. self.down_btn_obj:SetActive(false)
  949. end
  950. end
  951. function BagView:AddToStageHandler()
  952. local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EQUIP_SUIT_ACTIVE,3)
  953. if not helpVo then return end
  954. local help_type = helpVo.help_type
  955. local step = helpVo.step
  956. local suit = tonumber(helpVo.param)
  957. if help_type == HelpType.TYPE_EQUIP_SUIT_ACTIVE and step == 3 and suit and suit > 5 then
  958. self.tab_con.localPosition = Vector2(0, -2 + (tonumber(helpVo.param)- 1) * BagSuitTab.Height)
  959. end
  960. end
  961. function BagView:AddEffect(pos)
  962. for k,v in pairs(self.equip_item_list) do
  963. if v:GetPosType() == pos then
  964. v:WillShowEffect(true)
  965. end
  966. end
  967. end
  968. function BagView:UpdateEquipGemStone()
  969. local cur_lv = self.equip_model:GetGemstoneLvBySeries(self.equip_suit_id) or 0
  970. self.suit_num_tmp.text = cur_lv
  971. local bool = self.equip_model.gems_suit_red_list and self.equip_model.gems_suit_red_list[self.equip_suit_id] == true or false
  972. self.suit_btn_red_dot_obj:SetActive(bool)
  973. end
  974. function BagView:UpdateEquipSuitRedDot( )
  975. local bool = EquipModel:getInstance():GetSuitAttrRedBool() or false
  976. self.suitNumBtnRedDot_obj:SetActive(bool)
  977. end
  978. ----------装备收集-start---------
  979. function BagView:UpdateEquipCollectBtn( )
  980. if GetModuleIsOpen(145) then
  981. self.equipCollectBtn_obj:SetActive(true)
  982. self:UpdateEquipCollectNum()
  983. else
  984. self.equipCollectBtn_obj:SetActive(false)
  985. end
  986. end
  987. function BagView:UpdateEquipCollectNum( )
  988. local has_get_count, total_count = EquipCollectModel:getInstance():GetCollectCountByID(self.equip_suit_id)
  989. self.equipCollectBtnNumText_tmp.text = string.format('%s/%s', has_get_count, total_count)
  990. end
  991. function BagView:UpdateEquipCollectBtnRed( )
  992. local red_dot_data = EquipCollectModel:getInstance():GetAllEquipExamRedDot()
  993. local bool = false
  994. if red_dot_data[EquipCollectConst.TAB_ID.COLLECT] then
  995. bool = true
  996. end
  997. self.equipCollectBtnRedDot_obj:SetActive(bool)
  998. end
  999. ----------装备收集-end-----------