local EquipResonateUI = class("EquipResonateUI", BaseUI) function EquipResonateUI:onClose() end function EquipResonateUI:isFullScreen() return false end function EquipResonateUI:ctor(params) params = params or {} self.page = params.page or GConst.EquipConst.RESONATE_PAGE.LV_UP self.slotId = params and params.slotId end function EquipResonateUI:getPrefabPath() return "assets/prefabs/ui/equip/equip_resonate_ui.prefab" end function EquipResonateUI:onLoadRootComplete() local uiMap = self.root:genAllChildren() uiMap["equip_resonate_ui.mask"]:addClickListener(function() self:closeUI() end) uiMap["equip_resonate_ui.bg.close_btn"]:addClickListener(function() self:closeUI() end) if not self.equipCells then self.equipCells = {} for i = 1, 6 do local cell = uiMap["equip_resonate_ui.bg.equip_list.equip_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.EQUIP_CELL) cell:addClickListener(function() local uid = DataManager.EquipData:getPartEquipUid(self.slotId, self.part) if uid ~= 0 then self.part = i self:onRefresh() end end) table.insert(self.equipCells, cell) end end self.lvTx = uiMap["equip_resonate_ui.bg.page_info.lv_tx"] self.tipsTx = uiMap["equip_resonate_ui.bg.page_info.tips_tx"] self.attrNameTxe = uiMap["equip_resonate_ui.bg.page_info.attr_bg.attr_name_tx"] self.attrCurrValueTx = uiMap["equip_resonate_ui.bg.page_info.attr_bg.layout.attr_curr_value_tx"] self.arrowImg = uiMap["equip_resonate_ui.bg.page_info.attr_bg.layout.arrow_img"] self.attrNextValueTx = uiMap["equip_resonate_ui.bg.page_info.attr_bg.layout.attr_next_value_tx"] self.layout = uiMap["equip_resonate_ui.bg.page_info.attr_bg.layout"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT) uiMap["equip_resonate_ui.bg.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_HERO_DESC_4)) uiMap["equip_resonate_ui.bg.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_HERO_DESC_6)) self.btnTxs = {I18N:getGlobalText(I18N.GlobalConst.EQUIP_HERO_1), I18N:getGlobalText(I18N.GlobalConst.EQUIP_HERO_2), I18N:getGlobalText(I18N.GlobalConst.EQUIP_HERO_3)} self.pageBtns = {} self.pageBtnTxs = {} for i = 1, 3 do self.pageBtns[i] = uiMap["equip_resonate_ui.bg.page_btn_" .. i] self.pageBtnTxs[i] = uiMap["equip_resonate_ui.bg.page_btn_" .. i .. ".text"] self.pageBtns[i]:addClickListener(function() if self.page == i then return end self.page = i self:onRefresh() end) end self:bind(DataManager.EquipData, "isDirty", function() self:onRefresh() end) end function EquipResonateUI:onRefresh() self:refreshEquipCell() self:refreshPageBtn() self:refreshPage() end function EquipResonateUI:refreshEquipCell() for part = 1, 6 do local eid = DataManager.EquipData:getPartEquipUid(self.slotId, part) if eid and eid > 0 then local equipEntity = DataManager.EquipData:getEquipByUid(eid) self.equipCells[part]:refresh(equipEntity, self.slotId) else self.equipCells[part]:refreshEmpty(part) end end end function EquipResonateUI:refreshPageBtn() for i = 1, 3 do if self.page == i then self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_menu_1") self.pageBtnTxs[i]:setText(self.btnTxs[i]) else self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_menu_2") self.pageBtnTxs[i]:setText(self.btnTxs[i]) end end end function EquipResonateUI:refreshPage() if self.page == GConst.EquipConst.RESONATE_PAGE.LV_UP then self:refreshPageLv() elseif self.page == GConst.EquipConst.RESONATE_PAGE.QLT then self:refreshPageQlt() elseif self.page == GConst.EquipConst.RESONATE_PAGE.REFINE then self:refreshPageRefine() end end function EquipResonateUI:refreshPageLv() local lv, nextLv, attrNum, attrNextNum = DataManager.EquipData:getResonateLevel(self.page, self.slotId) self:refreshUI(lv, nextLv, attrNum, attrNextNum, DataManager.EquipData:getResonateMaxLevel(1)) end function EquipResonateUI:refreshPageQlt() local lv, nextLv, attrNum, attrNextNum = DataManager.EquipData:getResonateLevel(self.page, self.slotId, self.part) self:refreshUI(lv, nextLv, attrNum, attrNextNum, DataManager.EquipData:getResonateMaxLevel(2)) end function EquipResonateUI:refreshPageRefine() local lv, nextLv, attrNum, attrNextNum = DataManager.EquipData:getResonateLevel(self.page, self.slotId) self:refreshUI(lv, nextLv, attrNum, attrNextNum, DataManager.EquipData:getResonateMaxLevel(3)) end function EquipResonateUI:refreshUI(lv, nextLv, attrNum, attrNextNum, maxLevel) self.lvTx:setText(I18N:getGlobalText(I18N.GlobalConst.LV_POINT) .. lv) self.attrNameTxe:setText(GFunc.getAttrNameByType("attr_atk")) self.attrCurrValueTx:setText(attrNum) local meshProCompNow = self.attrCurrValueTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO) local nowTipsNowX = meshProCompNow.preferredWidth self.attrCurrValueTx:setSizeDeltaX(nowTipsNowX) if maxLevel ~= nil and lv >= maxLevel then self.arrowImg:setActive(false) self.attrNextValueTx:setActive(false) self.tipsTx:setText(I18N:getGlobalText(I18N.GlobalConst.PET_DESC_15)) else if nextLv == nil then self.tipsTx:setText(I18N:getGlobalText(I18N.GlobalConst.PET_DESC_15)) else if self.page == GConst.EquipConst.RESONATE_PAGE.QLT then self.tipsTx:setText(I18N:getGlobalText("EQUIP_HERO_M_" .. self.page, I18N:getGlobalText("EQUIP_QLT_DESC_" .. nextLv[1], nextLv[2]))) else self.tipsTx:setText(I18N:getGlobalText("EQUIP_HERO_M_" .. self.page, nextLv[1])) end end self.attrNextValueTx:setText(attrNextNum) self.arrowImg:setActive(true) self.attrNextValueTx:setActive(true) local meshProCompNext = self.attrNextValueTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO) local nowTipsNextX = meshProCompNext.preferredWidth self.attrNextValueTx:setSizeDeltaX(nowTipsNextX) end self.layout:RefreshLayout() end return EquipResonateUI