local EquipInfoComp = class("EquipInfoComp", LuaComponent) function EquipInfoComp:init() local uiMap = self:getUIMap() self.atkNameTx = uiMap["equip_info.bg_5.atk_name_tx"] self.atkTx = uiMap["equip_info.bg_5.atk_tx"] self.hpNameTx = uiMap["equip_info.bg_6.hp_name_tx"] self.hpTx = uiMap["equip_info.bg_6.hp_tx"] self.attrBtn = uiMap["equip_info.bg_6.attr_btn"] self.descTx = uiMap["equip_info.equip_node.up.desc_tx"] self.descTx1 = uiMap["equip_info.equip_node.up.desc_tx_1"] self.infoBtn = uiMap["equip_info.equip_node.up.info_btn"] self.autoWaerBtn = uiMap["equip_info.equip_node.auto_waer_btn"] self.autoWaerBtnTx = uiMap["equip_info.equip_node.auto_waer_btn.text"] self.upBtn = uiMap["equip_info.equip_node.up_btn"] self.upBtnTx = uiMap["equip_info.equip_node.up_btn.text"] self.equipNode = uiMap["equip_info.equip_node"] self.emptyTx = uiMap["equip_info.empty_tx"] self.hpNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2)) self.atkNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3)) self.emptyTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_29)) self.upBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_32)) self.autoWaerBtnTx:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_31)) self.equipCells = {} self.suitTxs = {} for i = 1, 6 do self.suitTxs[i] = uiMap["equip_info.equip_node.up.suit_tx_" .. i] self.equipCells[i] = uiMap["equip_info.equip_node.equip_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.EQUIP_CELL) self.equipCells[i]:addClickListener(function() ModuleManager.EquipManager:showEquipListUI(self.heroEntity, i) end) end self.autoWaerBtn:addClickListener(function() local soltId = self.heroEntity:getMatchType() local listUids = {} for i = 1, 6 do local equip = DataManager.EquipData:getEquipMaxScore(soltId, i) if equip ~= nil then table.insert(listUids, equip:getUid()) end end ModuleManager.EquipManager:onEquipWearReq(soltId, listUids) end) self.upBtn:addClickListener(function() -- UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity}) GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_32)) end) self.attrBtn:addClickListener(function() UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity}) end) end function EquipInfoComp:setParentUI(ui) self.uiRoot = ui end function EquipInfoComp:setHeroData(heroEntity) self.heroEntity = heroEntity self.selectPart = self.selectPart or GConst.EquipConst.PART_TYPE.EQUIP_1 end function EquipInfoComp:refresh() self:refreshAttr() self:refreshEquip() end function EquipInfoComp:refreshAttr() self.hpNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2)) self.atkNameTx:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3)) local lv = self.heroEntity:getLv() local hpStr local atkStr if not self.heroEntity:isActived() then hpStr = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) // GConst.DEFAULT_FACTOR atkStr = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) // GConst.DEFAULT_FACTOR else local curHp = self.heroEntity:getHp() // GConst.DEFAULT_FACTOR local curAtk = self.heroEntity:getAtk() // GConst.DEFAULT_FACTOR local addHp = (self.heroEntity:getCfgHp(lv + 1) - self.heroEntity:getCfgHp()) // GConst.DEFAULT_FACTOR local addAtk = (self.heroEntity:getCfgAtk(lv + 1) - self.heroEntity:getCfgAtk()) // GConst.DEFAULT_FACTOR if addHp <= 0 then hpStr = curHp else hpStr = curHp .. "+" .. addHp .. "" end if addAtk <= 0 then atkStr = curAtk else atkStr = curAtk .. "+" .. addAtk .. "" end end self.hpTx:setText(hpStr) self.atkTx:setText(atkStr) end function EquipInfoComp:refreshEquip() self.curFormation = DataManager.FormationData:getStageFormation() if self.curFormation[self.heroEntity:getMatchType()] ~= self.heroEntity:getCfgId() then self.emptyTx:setActive(true) self.equipNode:setActive(false) return end self.emptyTx:setActive(false) self.equipNode:setActive(true) for part = 1, 6 do local eid = DataManager.EquipData:getPartEquipUid(self.heroEntity:getMatchType(), part) if eid and eid > 0 then local equipEntity = DataManager.EquipData:getEquipByUid(eid) self.equipCells[part]:refresh(equipEntity, part) else -- self.equipCells[part]:refreshByCustom(nil, part) self.equipCells[part]:refreshEmpty(part) end end end return EquipInfoComp