|
|
- BagView = BagView or BaseClass(BaseItem)
- function BagView:__init(parent_wnd, prefab_asset, layer_name)
- self.base_file = "bag"
- self.layout_file = "bagView"
-
- self.column_num = 4 --一行多少个图标
- self.mainVo = RoleManager.Instance.mainRoleInfo
- self.model = GoodsModel:getInstance()
- self.equip_model = EquipModel:getInstance()
- self.equip_item_list = {} --装备格子
- self.bagModel = BagModel:getInstance()
- self.is_delay_callback = true
- self.need_sort = true
- self.is_click_sort = false
- self.hide_clear_role_model = false
- self.visible = true
- self.click_item_index = false
- local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
- self.max_equip_suit = len
-
- self.full_screen = true
- self.ani_right = 400
- self.ani_left = -200
- self.adjust_mid = {left = 160, right = 780}
-
- --标题tabbar
- self.titleTabbar_list = {}
- self.titleTabbar_text = {}
- self.titleTabbar = {[1] = "全部",[2] = "常用",[3] = "礼包"}
- self.title_cur_index = 1
- self.loop_mgr = LoopScrowViewMgr.New()
-
- self.bag_item_list = {}
- self.event_list = {}
- self.suit_tab_list = {}
- self.timeout_goods_id_list = {} --超时的道具检测id缓存列表,在此列表中的道具,不再刷新道具过期标志
- self.equip_suit_id = self.model:GetBagEquipChooseIndex() or 1--装备套件ID
- EquipModel:getInstance().cur_choose_suit = 1 or RoleManager:getInstance():GetMainRoleVo().turn--装备套件ID
- self:Load()
- end
-
- --清除界面
- function BagView:__delete()
- self:Remove()
- end
-
- function BagView:Load_callback()
- self:LoadSuccess()
- self:InitEvent()
- end
-
- function BagView:Remove()
- TimeManager.GetInstance():CancelTime("BagView_SetEquipData")
- TimeManager.GetInstance():CancelTime("BagView_ClearTimeOutProps")
- self.bagModel:Fire(BagModel.OPEN_DEPOT_VIEW,true)
- self.bagModel:Fire(BagModel.CLOSE_SELL_VIEW)
- self.bagModel.IsOnClickSwallow = false
-
- lua_resM:clearRoleMode(self)
-
- UnregisterFraming(self)
- self:StopCountDown()
- for i = 1,#self.bag_item_list do
- self.bag_item_list[i]:DeleteMe()
- end
- self.bag_item_list = nil
-
- for i,v in ipairs(self.equip_item_list) do
- v:DeleteMe()
- v = nil
- end
- self.equip_item_list = {}
-
- for i,v in ipairs(self.suit_tab_list) do
- v:DeleteMe()
- v = nil
- end
- self.suit_tab_list = {}
-
- for k,v in pairs(self.event_list) do
- self.model:UnBind(v)
- end
- self.event_list = {}
-
- if self.level_item then
- self.level_item:DeleteMe()
- self.level_item = nil
- end
-
- if self.change_name_id then
- self.mainVo:UnBind(self.change_name_id)
- self.change_name_id = nil
- end
- if self.change_level_id then
- self.mainVo:UnBind(self.change_level_id)
- self.change_level_id = nil
- end
-
- if self.change_jin_id then
- self.mainVo:UnBind(self.change_jin_id)
- self.change_jin_id = nil
- end
-
- if self.change_lockJin_id then
- self.mainVo:UnBind(self.change_lockJin_id)
- self.change_lockJin_id = nil
- end
-
- if self.change_tong_id then
- self.mainVo:UnBind(self.change_tong_id)
- self.change_tong_id = nil
- end
-
- if self.change_honor_id then
- self.mainVo:UnBind(self.change_honor_id)
- self.change_honor_id = nil
- end
-
- self.mainVo = nil
-
- if self.dynamic_event_id then
- GlobalEventSystem:UnBind(self.dynamic_event_id)
- self.dynamic_event_id = nil
- end
-
- if self.loop_mgr then
- self.loop_mgr:DeleteMe()
- self.loop_mgr = nil
- end
-
- if self.maskID then
- self:UnRegisterMask(self.maskID)
- self.maskID = nil
- end
-
- if self.coinBar then
- self.coinBar:DeleteMe()
- self.coinBar = nil
- end
- if self.delay_load_id then
- GlobalTimerQuest:CancelQuest(self.delay_load_id)
- self.delay_load_id = false
- end
-
- if self.step_sort_bag_cd_id then
- GlobalTimerQuest:CancelQuest(self.step_sort_bag_cd_id)
- self.step_sort_bag_cd_id = nil
- end
-
- if self.evil_item then
- self.evil_item:DeleteMe()
- end
- if self.tabScroll_scroll then
- self.tabScroll_scroll.onValueChanged:RemoveAllListeners()
- end
-
- EquipModel:getInstance().cur_choose_suit = nil
-
- -- 如果存在模糊背景图,则需要传到C#中销毁
- -- if self.blur_bg_mask_screenshot then
- -- MainCamera.Instance:ClearScreenShotCache(self.blur_bg_mask_screenshot)
- -- end
- end
-
- function BagView:LoadSuccess()
- if self.mainVo == nil then
- print("报错了。。。主角数据为nil")
- end
-
- local nodes = {
- "mid/RolePanel/roleCon:obj",
- "mid/evilCon:obj",
- "right/contain/sortBtn:obj:img",
- "right/contain/currencyExchangeBtn:obj",
- "mid/RolePanel/allContent/stone:obj",
- "mid/RolePanel/allContent/star:obj",
- "mid/RolePanel/allContent/strength:obj",
- "mid/RolePanel/roleInfoBg/lblInfo:txt",
- "left:obj",
- "mid:obj",
- "left/left_equip_conta:obj",
- "right/contain/right_equip_conta:obj",
- "mid/mid_equip_conta:obj",
- "left/left_btn:obj",
- "right/contain/right_btn:obj",
- "left/star_tip_btn:obj",
- "left/star_tip_btn/star_tip_red_dot:obj",
- "left/star_tip_btn/star_tip_num:tmp",
- "left/tab_bg:obj",
- "left/tabScroll:scroll",
- "left/tabScroll/Viewport/tab_con",
- "mid/suit_pwoer:txt:obj",
- "mid/power_bg:obj",
- "mid/suit_power_bg:obj",
- "left/down_btn:obj",
- "mid/bg_mask:obj:rawex",
- "right/contain:obj",
- -- "left/star_tip_btn/star_tip_text:tmp",
- --宝石星级套装
- "left/suit_btn/suit_num:tmp",
- "left/suit_btn:obj",
- "left/suit_btn/suit_btn_red_dot:obj",
- --橙品套装
- "left/suitNumBtn:obj",
- -- "left/suitNumBtn/suitNumBtnText:tmp",
- "left/suitNumBtn/suitNumBtnNumText:tmp",
- "left/suitNumBtn/suitNumBtnRedDot:obj",
- -- 套装收集
- "left/equipCollectBtn:obj",
- "left/equipCollectBtn/equipCollectBtnNumText:tmp",
- "left/equipCollectBtn/equipCollectBtnRedDot:obj:img",
- }
- self:GetChildren(nodes)
-
- -- self.suitNumBtnText_tmp.text = "橙品套装 >>"
- -- self.star_tip_text_tmp.text = "装备星级 >>"
- self.bg_mask_rawex.alpha = 0.8
- self.bg_mask_obj:SetActive(false)
- self.bg_mask_rawex.transform.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight)
-
- self.scroll,self.scroll_content,self.con,self.level_con = GetChildTransforms(self.transform,
- {
- "right/contain/ScrollView","right/contain/ScrollView/Viewport/Content","right/contain/ScrollView/Viewport/Content/con","mid/RolePanel/roleInfoBg/con"
- })
- for i=1,#self.titleTabbar do
- table.insert(self.titleTabbar_list,self:GetChild("right/contain/titleBarCon/tabbar"..i).gameObject)
- table.insert(self.titleTabbar_text,self:GetChild("right/contain/titleBarCon/tabbar"..i.."/Background/Text"):GetComponent("TextMeshProUGUI"))
- end
-
- self.scroll_image = self:GetChild("right/contain/ScrollView/Viewport"):GetComponent("Image")
- self.sortBtn_txt = self:GetChild("right/contain/sortBtn/Text"):GetComponent("TextMeshProUGUI")
-
- self.currency_exchange_red = self:GetChild("right/contain/currencyExchangeBtn/red").gameObject
-
- self.maskID = self:RegisterMask(self.scroll_image)
- self:SetRoleLevelName()
- self:SetTextColor(self.title_cur_index)
- self:UpdateBagItems(true)
- self:ClearTimeOutProps()
- -- local b = GetModuleIsOpen(152,7, true)
- -- self.suit_btn_obj:SetActive(b)
-
- self:UpdateEquipCollectBtn()
- self:UpdateEquipCollectBtnRed()
-
- local function call_back()
- self:SetUIDepth(self.left_equip_conta.gameObject)
- self:SetUIDepth(self.right_equip_conta.gameObject)
- self:UpdateSuitTab()
- end
-
- local res_data = {
- father_node = self,
- transform = self.roleCon,
- fashion_type = FuncOpenModel.TypeId.Clothes,
- size = Vector2(720,720),
- position = Vector3.zero,
- scale = 270,
- ui_model_type = UIModelCommon.ModelType.BackModel,
- dynamic_bone = true,
- use_green_screen = true,
- green_screen_camera_type = 3, -- camera_type:1 主摄像机 2 UI摄像机 3 UIModel摄像机
- callBack = call_back,
- }
- FuncOpenModel:getInstance():SetModelRes(res_data)
-
- RegisterFraming(self,{
- -- self.UpdateBagItems,
- self.OnInitializeItem,
- self.UpdateItemState,
- },true,0.05)
-
- self:SetCustomVisible(self.visible)
-
- if self.tabScroll_scroll then
- self.tabScroll_scroll.onValueChanged:RemoveAllListeners()
- self.tabScroll_scroll.onValueChanged:AddListener(function()
- self:WrapContent()
- end)
- end
-
- self.bagModel:RequestCurrencyExchangeRed() --打开背包的时候,在检测一次免费兑换次数,刷新红点
-
- --幻光技能特效隐藏测试
- GlobalEventSystem:Fire(EventName.HIDE_LIGHT_EFFCT_ICON)
- self:UpdateSuitPower()
- end
-
- function BagView:InitEvent()
- local function onBtnClickHandler(target)
- if target == self.sortBtn_obj then
- self.need_sort = true
- self.is_click_sort = true
- if BagModel:getInstance():TrySortBag(GoodsModel.GOODS_POS_TYPE.bag) then
- self.model:DelayFire(GoodsModel.CHANGE_BAGLIST)
- end
- self:UpdateSortCD()
- elseif target == self.currencyExchangeBtn_obj then
- BagModel:getInstance():Fire(BagModel.OPEN_CURRENCY_EXCHANGE_VIEW)
- elseif target == self.stone_obj then
- self.bagModel:Fire(BagModel.OPEN_ALL_ADDITION_VIEW, 3)
- elseif target == self.star_obj then
- self.bagModel:Fire(BagModel.OPEN_ALL_ADDITION_VIEW, 2)
- elseif target == self.strength_obj then
- self.bagModel:Fire(BagModel.OPEN_ALL_ADDITION_VIEW, 1)
- elseif target == self.left_btn_obj then
- if self.equip_suit_id - 1 >= 0 then
- self:UpdateSuitState(self.equip_suit_id - 1)
- else
- Message.show("最左边了哦!")
- end
- elseif target == self.right_btn_obj then
- if self.equip_suit_id + 1 <= self.max_equip_suit then
- self:UpdateSuitState(self.equip_suit_id + 1)
- else
- Message.show("最右边了哦!")
- end
- elseif target == self.star_tip_btn_obj then
- OpenFun.Open(152,999)
- elseif target == self.left_btn_obj then
- if self.equip_suit_id - 1 >= 0 then
- self:UpdateSuitState(self.equip_suit_id - 1)
- else
- Message.show("最左边了哦!")
- end
- elseif target == self.right_btn_obj then
- if self.equip_suit_id + 1 <= self.max_equip_suit then
- self:UpdateSuitState(self.equip_suit_id + 1)
- else
- Message.show("最右边了哦!")
- end
- elseif target == self.down_btn_obj then
-
- self.tab_con.localPosition = Vector2(0, -2 + (#self.suit_tab_list- 1) * BagSuitTab.Height)
-
- elseif target == self.suit_btn_obj then
- self.equip_model:Fire(EquipModel.OPEN_GEMSTONE_SUIT_VIEW,self.equip_suit_id)
- elseif target == self.suitNumBtn_obj then
- BagModel:getInstance():Fire(BagModel.OPEN_EQUIP_ORANGE_SUIT_VIEW,self.equip_suit_id)
- elseif target == self.equipCollectBtn_obj then
- OpenFun.Open(145,1)
- else
- for i,v in ipairs(self.titleTabbar) do
- local obj = self.titleTabbar_list[i]
- if target == obj then
- self.title_cur_index = i
- self.click_item_index = false
- self:SetTextColor(self.title_cur_index)
- self:UpdateBagItems(true)
- self.loop_mgr:RestToBeginning()
- break
- end
- end
- end
- end
- AddClickEvent(self.sortBtn_obj,onBtnClickHandler)
- AddClickEvent(self.currencyExchangeBtn_obj,onBtnClickHandler)
- AddClickEvent(self.stone_obj, onBtnClickHandler)
- AddClickEvent(self.star_obj, onBtnClickHandler)
- AddClickEvent(self.strength_obj, onBtnClickHandler)
- AddClickEvent(self.left_btn_obj, onBtnClickHandler)
- AddClickEvent(self.right_btn_obj, onBtnClickHandler)
- AddClickEvent(self.star_tip_btn_obj, onBtnClickHandler)
- AddClickEvent(self.down_btn_obj, onBtnClickHandler)
- AddClickEvent(self.suit_btn_obj, onBtnClickHandler)
- AddClickEvent(self.suitNumBtn_obj, onBtnClickHandler)
- AddClickEvent(self.equipCollectBtn_obj, onBtnClickHandler)
-
- for i=1,#self.titleTabbar do
- AddClickEvent(self.titleTabbar_list[i],onBtnClickHandler)
- end
-
- local function onChangeBagListHandler()
- if self._use_delete_method then return end
- self:DelayShow()
- end
- self.event_list[1] = self.model:Bind(GoodsModel.CHANGE_BAGLIST,onChangeBagListHandler)
-
- local function onChangeBagListHandler2()
- self:DelayShow()
- end
- self.event_list[2] = self.model:BindOne("slot_info_pos_2",onChangeBagListHandler2)
-
- -- local update_equip = function ()
- -- if not self.is_loaded then return end
- -- local active_list = EquipModel:getInstance():GetCurSuitInfo()
- -- local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
- -- self.max_equip_suit = len
- -- local active_list = EquipModel:getInstance():GetCurSuitInfo()
- -- local config = Config.Equipmentseriesopen
- -- for i=1,self.equip_suit_tab_max do
- -- local item = self.suit_tab_list[i]
- -- if item then
- -- item:SetData(active_list[i],i,config[i], i == self.equip_suit_tab_max)
- -- end
- -- end
- -- end
- -- self.event_list[3] = self.model:Bind(GoodsModel.CHANGE_EQUIPLIST, update_equip)
-
-
- local click_fun = function (index,pos_type)
- if pos_type == GoodsModel.GOODS_POS_TYPE.bag then
- self.click_item_index = index
- self:UpdateItemState(index)
- end
- end
- self.event_list[4] = self.model:Bind(GoodsModel.CLICK_BAG_ITEM, click_fun)
-
- local function onChangeInfoHandler()
- self:SetRoleLevelName()
- self:UpdateEquipCollectBtn()
- end
- self.change_name_id = self.mainVo:BindOne("name",onChangeInfoHandler)
- self.change_level_id = RoleManager:getInstance().mainRoleInfo:Bind(EventName.CHANGE_LEVEL,onChangeInfoHandler)
-
-
- local function onChangeMoneyHandler()
- if self._use_delete_method then return end
- self:DoSetEquipData()
- end
- self.change_jin_id = self.mainVo:BindOne("jin",onChangeMoneyHandler)
- self.change_lockJin_id = self.mainVo:BindOne("jinLock",onChangeMoneyHandler)
- self.change_tong_id = self.mainVo:BindOne("tong",onChangeMoneyHandler)
- self.change_honor_id = self.mainVo:BindOne("honor",onChangeMoneyHandler)
-
- --更新星级套装红点
- local function equipStarRedFunc( ... )
- self:SetEquipStarTipRed()
- self:UpdateSuitTabRed()
- self:DoSetEquipData()
- end
- self:BindEvent(EquipModel:getInstance(), EquipModel.INFO_UPDATE, equipStarRedFunc)
- equipStarRedFunc()
-
- --装备升品操作
- local function onUpdateComposeEvent()
- self:DoSetEquipData()
- end
- self:BindEvent(ComposeModel:getInstance(), ComposeModel.UPDATE_COMPOSE_VIEW_RED, onUpdateComposeEvent)
-
- --装备战力变化
- local function onUpdateEquipPower()
- self:UpdateSuitPower()
- end
- self:BindEvent(EquipModel:getInstance(), EquipModel.UPDATE_EQUIP_POWER, onUpdateEquipPower)
-
- --更新星级套装红点
- local function updateSuitInde( ... )
- if not self.is_loaded then return end
- local suit_id = self.model:GetBagEquipChooseIndex()
- self:UpdateSuitState(suit_id)
- end
- self:BindEvent(GoodsModel:getInstance(),GoodsModel.UPDATE_BAG_EQUIP_SUIT_CHOOSE, updateSuitInde)
-
-
- local function UpdateEquipSeriesOrangeNum( ... )
- if not self.is_loaded then return end
- self.suitNumBtnNumText_tmp.text = string.format("%s/10",GoodsModel:getInstance():GetEquipCurSuitOrangeNum(self.equip_suit_id))
- self:UpdateEquipSuitRedDot()
- end
- self:BindEvent(GlobalEventSystem,EventName.UPDATE_BAG_RED,UpdateEquipSeriesOrangeNum)
-
- --更新宝石等级
- local function update_gamestone()
- if not self.is_loaded then return end
- -- self:UpdateEquipGemStone()
- self:UpdateEquipSuitRedDot()
- end
- self:BindEvent(EquipModel.getInstance(), EquipModel.UPDATE_VIEW_RED, update_gamestone)
- --刷新交易券兑换
- local function update_currency_exchange_red()
- self:UpdateSuitTabRed()
- self:SetCurrencyExchangeRed()
- end
- self:BindEvent(BagModel.Instance,BagModel.ANS_UPDATE_CURRENCY_EXCHANGE_RED,update_currency_exchange_red)
- self:BindEvent(GlobalEventSystem,EventName.UPDATE_BAG_RED,update_currency_exchange_red)
- update_currency_exchange_red()
-
-
- local function sort_bag_after_swallow()
- self.need_sort = true
- if BagModel:getInstance():TrySortBag(GoodsModel.GOODS_POS_TYPE.bag) then
- self.model:DelayFire(GoodsModel.CHANGE_BAGLIST)
- end
- self:UpdateSortCD()
- end
- self:BindEvent(BagModel.Instance,BagModel.SORT_BAG_AFTER_SWALLOW,sort_bag_after_swallow)
-
- local function update_bag_timeout_goods(goods_id)
- if self.timeout_goods_id_list[goods_id] then
- return
- end
- self.timeout_goods_id_list[goods_id] = true
- self:UpdateGoodsLimitTime()
- end
- self:BindEvent(GlobalEventSystem, EventName.UPDATE_BAG_TIMEOUT_GOODS, update_bag_timeout_goods)
-
-
- local function update_equip_max_series(suit_id)
- self:UpdateSuitState(suit_id)
- self:UpdateDownObj()
- end
- self:BindEvent(EquipModel.getInstance(), EquipModel.UPDATE_EQUIP_MAX_SERIES, update_equip_max_series)
-
- --更新装备穿戴特效
- local function onPlayWearEquipmentEffect(pos)
- self:AddEffect(pos)
- end
- self:BindEvent(GoodsModel:getInstance(),GoodsModel.PLAY_WEAR_EQUIPMENT_EFFECT, onPlayWearEquipmentEffect)
-
- ----------装备考核-start---------
- local function on_task_icon_open( task_id )--任务
- if Config.Moduleid[145].task_id == task_id then
- self:UpdateEquipCollectBtn()
- end
- end
- self:BindEvent(GlobalEventSystem, TaskEvent.ANS_FINISHED_TASK_LIST, on_task_icon_open)
-
- local function on_init_open_day( ... )
- self:UpdateEquipCollectBtn()
- end
- self:BindEvent(GlobalEventSystem, EventName.OPEN_DAY_INIT, on_init_open_day)
-
- local function on_update_equip_collect_btn_red( ... )
- self:UpdateEquipCollectNum()
- self:UpdateEquipCollectBtnRed()
- end
- self:BindEvent(EquipCollectModel:getInstance(), EquipCollectConst.ANS_UPDATE_EQUIP_COLLECT_RED_DOT, on_update_equip_collect_btn_red)
- ----------装备考核-end-----------
-
- local function on_update( ... )
- self:UpdateEquipCollectBtn()
- end
- self:BindEvent(self.model, EquipCollectConst.ANS_EQUIP_COLLECT_INFO, on_update)
- end
-
- function BagView:SetCurrencyExchangeRed( )
- -- local bool = BagModel:getInstance():GetCurrencyExchangeRed()
- -- self.currency_exchange_red:SetActive(bool)
- end
-
- function BagView:DelayShow( )
- self:StopCountDown()
- local function show( )
- self:StopCountDown()
- self:UpdateBagItems()
- end
- self.timer_countdown = TimerQuest.AddPeriodQuest(GlobalTimerQuest,show,0.4)
- end
-
- function BagView:StopCountDown()
- if self.timer_countdown then
- TimerQuest.CancelQuest(GlobalTimerQuest, self.timer_countdown)
- self.timer_countdown = nil
- end
- end
-
- function BagView:SetTextColor( )
- for i,v in ipairs(self.titleTabbar_text) do
- if self.title_cur_index == i then
- v.text = "<color=#ffffff>"..self.titleTabbar[i].."</color>"
- SetTMPSharedMaterial(v, ShaderTools.TMPSharedMaterialType.HKYTW7OutlineBlueTab)
- else
- v.text = "<color=#9eb3cf>"..self.titleTabbar[i].."</color>"
- SetTMPSharedMaterial(v, ShaderTools.TMPSharedMaterialType.HKYTW7FFDefault)
- end
- end
- end
-
- function BagView:UpdateBagItems(to_top)
- local item = nil
- local info = self.model.slot_info_pos_2
- local slot_num = info.slot_num or 0 --开放格子
- local all_slot = info.all_slot or 0 --总共格子
-
- self.curr_list = {}
- local bag_goods_list = self.model.bag_goods_list or {}
-
- if self.need_sort then
- self.need_sort = false
- self.model:SortBagListByBagView(bag_goods_list)
- self.model.bag_goods_list = bag_goods_list
- if self.is_click_sort then
- ItemUseModel:getInstance():InitBagGoodsDicOnSort(self.model.bag_goods_list)
- end
- self.is_click_sort = false
- end
-
- local m_index = 1
- for k,v in pairs(bag_goods_list) do
- if self.title_cur_index == 2 then --常用(消耗 3 和 碎片 4)
- if self.model:GetGoodsTab(v.type, v.subtype) == 3 or self.model:GetGoodsTab(v.type, v.subtype) == 4 then
- self.curr_list[m_index] = v
- self.curr_list[m_index].index = m_index
- m_index = m_index + 1
- end
- elseif self.title_cur_index == 3 then --礼包
- if self.model:GetGoodsTab(v.type, v.subtype) == 5 then
- self.curr_list[m_index] = v
- self.curr_list[m_index].index = m_index
- m_index = m_index + 1
- end
- else --全部
- self.curr_list[k] = v
- self.curr_list[k].index = k
- end
- end
- for k = #self.curr_list + 1,slot_num do
- self.curr_list[k] = {type_id = 0, goods_num = 0,index = k}
- end
- for k = slot_num + 1,all_slot do
- self.curr_list[k] = {lock_index = k - slot_num,index = k}
- end
-
- for k = 1,30 do
- local item = self.bag_item_list[k]
- if item == nil then
- item = BagItem.New(self.con,nil,self.maskID)
- self.bag_item_list[k] = item
- item:SetPosType(GoodsModel.GOODS_POS_TYPE.bag)
- end
- end
-
- if to_top then
- self.loop_mgr:Init(self.scroll,self.scroll_content,self.column_num,89.5,89.5,function(item,index,realIndex )
- self:OnInitializeItem(item,index,realIndex)
- end, 0, 0, {x=10,y=-6})
- self.loop_mgr:InitChildren(self.bag_item_list, #self.curr_list)
- self.loop_mgr:RestToBeginning()
- self.loop_mgr:SetContentSizeData()
- else
- self.loop_mgr:InitChildren(self.bag_item_list, #self.curr_list)
- self.loop_mgr:ForceUpdateCurrentItems()
- self.loop_mgr:SetContentSizeData()
- end
- end
-
- function BagView:OnInitializeItem(item,index,realIndex)
- if item and realIndex > 0 and realIndex <= #self.curr_list then
- local data = self.curr_list[realIndex]
- if data ~= nil then
- local spe_color
- if data.type == 12 then --时装在背包中特殊显示特效
- spe_color = data.color
- elseif data.type_id and data.type_id >= 36040001 and data.type_id <= 36040004 then
- spe_color = 3
- end
-
- local isHide = nil
- if data.color and data.color <= 3 then
- isHide = true
- else
- isHide = false
- end
- item:SetData(data, self.maskID, isHide, spe_color, "BagView")
- self:UpdateItemState()
- else
- item:SetVoid()
- end
- end
- end
-
- function BagView:UpdateItemState()
- if not self.click_item_index then return end
-
- for k,item in pairs(self.bag_item_list) do
- item:SetSelect(item.index == self.click_item_index)
- end
- end
-
- --设置装备数据
- function BagView:SetEquipData()
- local wear_suit_list = GoodsModel:getInstance().wear_equip_suit_list
- local list = GoodsModel:getInstance().wear_equip_suit_list[self.equip_suit_id] or {}
- local index_key_list = {}
- local empty_key_list = {}
- for k,v in pairs(Config.ConfigEquipShow) do
- empty_key_list[v.index] = {}
- empty_key_list[v.index].equip_suit_type = v.cell
- end
- for _,vo in pairs(list) do
- local index = Config.ConfigEquipShow[vo.equip_suit_type] and Config.ConfigEquipShow[vo.equip_suit_type].index or 0
- index_key_list[index] = vo
- end
- -- print("huangcong:BagView [start:414] index_key_list:", index_key_list)
- -- PrintTable(index_key_list)
- -- print("huangcong:BagView [end]")
- if self.delay_load_id then
- GlobalTimerQuest:CancelQuest(self.delay_load_id)
- self.delay_load_id = false
- end
- local frame_count = 0
- local pos_t =
- {
- [1] = {x = 955, y = -25, p = 1},
- [2] = {x = 1043, y = -25, p = 1},
- [3] = {x = 955, y = -116, p = 1},
- [4] = {x = 1043, y = -116, p = 1},
- [5] = {x = 955, y = -205, p = 1},
- [6] = {x = 1043, y = -205, p = 1},
- [7] = {x = 955, y = -295, p = 1},
- [8] = {x = 1043, y = -295, p = 1},
- [9] = {x = 955, y = -385, p = 1},
- [10] = {x = 1043, y = -385, p = 1},
- --[11] = {x = 1128, y = -295, p = 1},
- [11] = {x = 1128, y = -385, p = 1},
- }
-
- local function frame_func( )
- frame_count = frame_count + 1
- if frame_count == 12 then --结束
- -- item:SetRingShow()
- if self.delay_load_id then
- GlobalTimerQuest:CancelQuest(self.delay_load_id)
- self.delay_load_id = false
- end
- return
- end
- local item = self.equip_item_list[frame_count]
- if not item and pos_t[frame_count] then
- if pos_t[frame_count].p == 3 then
- item = EquipItem.New(self.mid_equip_conta, nil, self.layer_name, true)
- elseif pos_t[frame_count].p == 2 then
- item = EquipItem.New(self.right_equip_conta, nil, self.layer_name, true)
- else
- item = EquipItem.New(self.left_equip_conta, nil, self.layer_name, true)
- end
- self.equip_item_list[frame_count] = item
- item:SetEquipStyle(frame_count)
- local x = pos_t[frame_count].x
- local y = pos_t[frame_count].y
- item:SetPosition(x, y)
- end
- local vo = index_key_list[frame_count]
- --item:SetBgAlpha((vo and frame_count == 11) and 0 or 1)
- if vo then
- item:SetData(vo)
- item:SetPosType(vo.equip_suit_type, false, self.equip_suit_id, true)
- else
- item:ClearData()
- item:SetPosType(empty_key_list[frame_count].equip_suit_type, true, self.equip_suit_id , true)
- end
-
- --更新守护模型
- if frame_count == 11 then
- self:UpdateEvilMomodel(index_key_list[frame_count])
- end
- if frame_count == 12 then
- --羁绊信物显示
- item:SetRingShow()
- end
- end
- frame_func()
- if not self.delay_load_id then
- self.delay_load_id = GlobalTimerQuest:AddPeriodQuest(frame_func, 0.01)
- end
- end
-
- function BagView:SetRoleLevelName()
- if self.mainVo then
- local lv = WordManager:GetRoleLevel(self.mainVo.level,self.mainVo.turn,true,false)
- self.lblInfo_txt.text = self.mainVo.name.." "
- local name_len = self.lblInfo_txt.preferredWidth
- if WordManager:RoleLevelIsTop(self.mainVo.level,self.mainVo.turn) then
- self.lblInfo_txt.text = self.mainVo.name.." "..lv
- else
- self.lblInfo_txt.text = self.mainVo.name.." "..lv
- end
- local text_len = self.lblInfo_txt.preferredWidth
- local pos = name_len - text_len/2 + 3
- end
- end
-
- function BagView:UpdateSortCD( )
- if not self.is_loaded then return end
- local last_sort_bag_time = BagModel:getInstance():GetLastSortBagTime(GoodsModel.GOODS_POS_TYPE.bag)
- if not last_sort_bag_time then
- self.sortBtn_img.color = ColorUtilValue.WHITE
- self.sortBtn_txt.text = "整理"
- return
- end
-
- local function step_sort_bag_cd( ... )
- local left_cd = 5 - (Time.time - last_sort_bag_time)
- if left_cd > 0 then
- self.sortBtn_txt.text = math.ceil(left_cd)
- self.sortBtn_img.color = Color(148/255,148/255,148/255)
- else
- self.sortBtn_img.color = ColorUtilValue.WHITE
- self.sortBtn_txt.text = "整理"
- if self.step_sort_bag_cd_id then
- GlobalTimerQuest:CancelQuest(self.step_sort_bag_cd_id)
- self.step_sort_bag_cd_id = nil
- end
- end
- end
- step_sort_bag_cd()
- if not self.step_sort_bag_cd_id then
- self.step_sort_bag_cd_id = GlobalTimerQuest:AddPeriodQuest(step_sort_bag_cd, 1, -1)
- end
- end
-
- --隐藏装备区域
- function BagView:SetCustomVisible(b)
- self.visible = b
- if not self.is_loaded then return end
- -- self.right_btn_obj:SetActive(b)
- self.mid_obj:SetActive(b)
- self.left_obj:SetActive(b)
- self.right_equip_conta_obj:SetActive(b)
- end
-
- --显示背景模糊蒙版
- function BagView:SetBgMaskVisible(b)
- self.show_bgmask = b
- if not self.is_loaded then return end
- if self.show_bgmask then
- self.left_obj:SetActive(false)
- self.bg_mask_obj:SetActive(true)
- self.roleCon_obj:SetActive(false)
- self.evilCon_obj:SetActive(false)
- self.suit_pwoer_obj:SetActive(false)
- self.power_bg_obj:SetActive(false)
- self.suit_power_bg_obj:SetActive(false)
-
- -- local function create_bg_makk_blur()
- -- if self.blur_bg_mask_screenshot == false or not self.show_bgmask then -- 等待模糊背景返回/获取当前不需要显示该模糊背景
- -- self.bg_mask_rawex.alpha = 0
- -- elseif self.blur_bg_mask_screenshot then
- -- self.bg_mask_rawex.alpha = 1
- -- self.bg_mask_rawex.texture = self.blur_bg_mask_screenshot
- -- end
- -- self.bg_mask_rawex.transform.sizeDelta = Vector2(SrcScreenWidth, ScreenHeight)
- -- end
-
- -- if MainCamera.Instance:GetRenderSupport() then
- -- self:SetCustomVisible(true)
- -- self:SetContainVisible(false)
- -- -- 创建回调用来接收RenderTexture
- -- local function blur_screenshot_callback(renderTexture)
- -- MainCamera.Instance:ClearScreenShotCache(self.blur_bg_mask_screenshot)
- -- self.blur_bg_mask_screenshot = renderTexture
- -- if self._use_delete_method then return end
- -- self:SetCustomVisible(false)
- -- self:SetContainVisible(true)
- -- self.bg_mask_obj:SetActive(true)
- -- create_bg_makk_blur()
- -- end
- -- MainCamera.Instance:GetCameraBlurScreenShot(blur_screenshot_callback, self.blur_camera_type)
- -- else
- -- create_bg_makk_blur()
- -- end
- else
- self.roleCon_obj:SetActive(true)
- self.evilCon_obj:SetActive(true)
- self.left_obj:SetActive(true)
- self.bg_mask_obj:SetActive(false)
- self.suit_pwoer_obj:SetActive(true)
- self.power_bg_obj:SetActive(true)
- self.suit_power_bg_obj:SetActive(true)
- end
- end
-
- --隐藏右侧道具区域
- function BagView:SetContainVisible(b)
- if not self.is_loaded then return end
- self.contain_obj:SetActive(b)
- end
-
- --更新装备套件标签
- function BagView:UpdateSuitTab( )
- for k,v in pairs(self.suit_tab_list) do
- v:SetVisible(false)
- end
- local len,list = NewMainRoleModel:getInstance():GetRoleReinMaxTurn()
- self.max_equip_suit = len
- self:UpdateDrectionObj()
- local active_list = self.equip_model:GetCurSuitInfo()
- -- print("huangcong:BagView [start:532] :", active_list)
- -- PrintTable(active_list)
- -- print("huangcong:BagView [end]")
- local function call_back( equip_suit_id )
- self:UpdateSuitState(equip_suit_id)
- self:UpdateDownObj()
- self:UpdateEquipCollectNum()
- end
-
- local offer_x = 0
- local offer_y = 0
- local x = 0
- local y = 0
-
- for i=1,len do
- local item = self.suit_tab_list[i]
- if item == nil then
- item = BagSuitTab.New(self.tab_con,nil,self.layer_name)
- self.suit_tab_list[i] = item
- item:SetPosition(2,- 2 + ( - BagSuitTab.Height + 4) * (i - 1))
- item:SetCallBack(call_back)
- end
- item:SetData(active_list[i],i,list[i],len)
- item:SetVisible(true)
- end
-
- local Width = EquipModel.TabLenth[len > 5 and 5 or len]
- SetSizeDeltaY(self.tab_con,BagSuitTab.Height*len)
- self.tabScroll_scroll.enabled = len > 5
- self.tab_bg_obj:SetActive(len > 0)
-
- call_back(self.equip_suit_id)
- self:UpdateSuitTabRed()
- --新手引导处理
- self:AddToStageHandler()
- end
-
- --更新标签红点(怎么办 好多啊 我也很绝望啊 啊?)
- function BagView:UpdateSuitTabRed( )
- for k,v in pairs(self.suit_tab_list) do
- v:SetRedDot(false)
- end
-
- --------现在背包中,升品,升星,精炼,不需要显示红点------
-
- -- --升星
- -- local red_info = EquipModel:getInstance():GetEvolutionSuitTabRedInfo()
- -- if red_info then
- -- for k,v in ipairs(self.suit_tab_list) do
- -- if red_info[k] then
- -- v:SetRedDot(true)
- -- end
- -- end
- -- end
-
- -- --精炼
- -- local strength_red_info = EquipModel:getInstance().can_strength_info
- -- if strength_red_info then
- -- for k,v in ipairs(self.suit_tab_list) do
- -- local suit_id = k
- -- if strength_red_info[suit_id] then
- -- for kk,vv in pairs(strength_red_info[suit_id]) do
- -- if vv then
- -- v:SetRedDot(true)
- -- break
- -- end
- -- end
- -- end
- -- end
- -- end
-
- -- --升品
- -- local upquality_red_info = EquipModel:getInstance().can_up_quality_info
- -- if upquality_red_info then
- -- for k,v in ipairs(self.suit_tab_list) do
- -- local suit_id = k
- -- if upquality_red_info[suit_id] then
- -- for kk,vv in pairs(upquality_red_info[suit_id]) do
- -- if vv.can_up == true then
- -- v:SetRedDot(true)
- -- break
- -- end
- -- end
- -- end
- -- end
- -- end
-
- end
-
- function BagView:UpdateSuitState( equip_suit_id )
- self.equip_suit_id = equip_suit_id
- self.suitNumBtnNumText_tmp.text = string.format("%s/10",GoodsModel:getInstance():GetEquipCurSuitOrangeNum(self.equip_suit_id))
- self.model:SetBagEquipChooseIndex(self.equip_suit_id)
- EquipModel:getInstance().cur_choose_suit = self.equip_suit_id
- for k,v in pairs(self.suit_tab_list) do
- v:SetChoose(equip_suit_id)
- end
- self:DoSetEquipData()
- self:UpdateDrectionObj()
- self:UpdateEquipGemStone()
-
- end
-
- --装备延迟加载
- function BagView:DoSetEquipData( )
- local function callback( )
- self:SetEquipData()
- end
- TimeManager.GetInstance():StartTime("BagView_SetEquipData", 0.1, callback)
- end
-
- function BagView:SetEquipStarTipRed( )
- if self.is_loaded then
- local star_tip_red = EquipModel:getInstance():GetCurHaveStarRedDot()
- self.star_tip_red_dot_obj:SetActive(star_tip_red)
- self.star_tip_num_tmp.text = EquipModel:getInstance().equip_sum_stars
- end
- end
-
- --过期道具检测
- function BagView:ClearTimeOutProps( )
- if self.bagModel.show_drop_timeout_props_tips then
- local function callback()
- local bag_goods_list = self.model.bag_goods_list or {}
- local t = self.bagModel:GetTimeOutGoodsList(bag_goods_list)
- if #t > 0 then
- local function ok_callback(bool)
- self.bagModel.show_drop_timeout_props_tips = not bool
- GoodsModel:getInstance():Fire(GoodsModel.REQUEST_CCMD_EVENT,15051, 1 , t)
- end
- local function cancel_callback(bool)
- self.bagModel.show_drop_timeout_props_tips = not bool
- end
- local d =
- {
- show_content = "发现背包中有<color=#ff2e65>过期物品</color>堆积,是否丢弃?",
- ok_callback = ok_callback,
- alert_title = "背包清理",
- type = Alert.Type.Four,
- defalut_toggle = false,
- close_callback = cancel_callback,
- cancel_callback = cancel_callback,
- }
- Alert.showbytable(d)
- end
- for i,v in ipairs(t) do
- self.timeout_goods_id_list[v.goods_id] = true
- end
- end
- TimeManager.GetInstance():StartTime("BagView_ClearTimeOutProps", 0.5, callback)
- end
- end
-
- function BagView:UpdateGoodsLimitTime()
- for i,v in ipairs(self.bag_item_list) do
- local goods_id = v:UpdateLimitState()
- if goods_id then
- self.timeout_goods_id_list[goods_id] = true
- end
- end
- end
-
- function BagView:UpdateEvilMomodel(vo)
- if not self.evil_item then
- self.evil_item = BagEvilItem.New(self.evilCon,nil,self.layer_name)
- end
- self.evil_item:SetData(vo and vo.type_id or false)
- end
-
- function BagView:UpdateDrectionObj()
- self.left_btn_obj:SetActive(self.equip_suit_id ~= 1)
- self.right_btn_obj:SetActive(self.equip_suit_id ~= self.max_equip_suit - 1)
- end
-
- function BagView:UpdateSuitPower()
- self.suit_pwoer_txt.text = EquipModel:getInstance().equip_sum_power
- end
-
- function BagView:WrapContent()
- self:UpdateDownObj()
- end
-
- function BagView:UpdateDownObj()
- if #self.suit_tab_list > 5 then
- local _, y = GetAnchoredPosition(self.tab_con)
- self.down_btn_obj:SetActive(y < 50)
- else
- self.down_btn_obj:SetActive(false)
- end
- end
-
- function BagView:AddToStageHandler()
- local helpVo = GuideModel:getInstance():GetHelpVo(HelpType.TYPE_EQUIP_SUIT_ACTIVE,3)
- if not helpVo then return end
- local help_type = helpVo.help_type
- local step = helpVo.step
- local suit = tonumber(helpVo.param)
- if help_type == HelpType.TYPE_EQUIP_SUIT_ACTIVE and step == 3 and suit and suit > 5 then
- self.tab_con.localPosition = Vector2(0, -2 + (tonumber(helpVo.param)- 1) * BagSuitTab.Height)
- end
- end
-
- function BagView:AddEffect(pos)
- for k,v in pairs(self.equip_item_list) do
- if v:GetPosType() == pos then
- v:WillShowEffect(true)
- end
- end
- end
-
- function BagView:UpdateEquipGemStone()
- local cur_lv = self.equip_model:GetGemstoneLvBySeries(self.equip_suit_id) or 0
- self.suit_num_tmp.text = cur_lv
- local bool = self.equip_model.gems_suit_red_list and self.equip_model.gems_suit_red_list[self.equip_suit_id] == true or false
- self.suit_btn_red_dot_obj:SetActive(bool)
- end
-
- function BagView:UpdateEquipSuitRedDot( )
- local bool = EquipModel:getInstance():GetSuitAttrRedBool() or false
- self.suitNumBtnRedDot_obj:SetActive(bool)
- end
-
- ----------装备收集-start---------
- function BagView:UpdateEquipCollectBtn( )
- if GetModuleIsOpen(145) then
- self.equipCollectBtn_obj:SetActive(true)
- self:UpdateEquipCollectNum()
- else
- self.equipCollectBtn_obj:SetActive(false)
- end
- end
-
- function BagView:UpdateEquipCollectNum( )
- local has_get_count, total_count = EquipCollectModel:getInstance():GetCollectCountByID(self.equip_suit_id)
- self.equipCollectBtnNumText_tmp.text = string.format('%s/%s', has_get_count, total_count)
- end
-
- function BagView:UpdateEquipCollectBtnRed( )
- local red_dot_data = EquipCollectModel:getInstance():GetAllEquipExamRedDot()
- local bool = false
- if red_dot_data[EquipCollectConst.TAB_ID.COLLECT] then
- bool = true
- end
- self.equipCollectBtnRedDot_obj:SetActive(bool)
- end
- ----------装备收集-end-----------
|