英雄界面

This commit is contained in:
puxuan 2025-06-26 21:33:39 +08:00
parent 5e2e5b6f63
commit 22ba335f36
9 changed files with 216 additions and 185 deletions

View File

@ -174,6 +174,7 @@ GConst.TYPEOF_LUA_CLASS = {
SCROLL_RECT_CENTER = "app/ui/common/scrollrect/scrollrect_center", SCROLL_RECT_CENTER = "app/ui/common/scrollrect/scrollrect_center",
SCROLL_RECT_OLD = "app/ui/common/scrollrect/scrollrect_old", SCROLL_RECT_OLD = "app/ui/common/scrollrect/scrollrect_old",
BASE_CELL = "app/ui/common/cell/base_cell", BASE_CELL = "app/ui/common/cell/base_cell",
STAR_CELL = "app/ui/hero/cell/star_cell",
-- 引导 -- 引导
TUTORIAL_UI = "app/ui/tutorial/tutorial_ui", TUTORIAL_UI = "app/ui/tutorial/tutorial_ui",

View File

@ -1954,6 +1954,15 @@ function GFunc.getStarImg(starType)
end end
end end
function GFunc.getHeroQltImg(qlt)
return GConst.ATLAS_PATH.HERO, "hero_quality_" .. qlt
end
function GFunc.getHeroQltStr(qlt)
return I18N:getGlobalText("QLT_DESC_" .. qlt)
end
-- 获取计算了加成的最终属性值全部属性固定属性id加成属性id -- 获取计算了加成的最终属性值全部属性固定属性id加成属性id
function GFunc.getFinalAttrValue(allAttrs, fixedId, factorId) function GFunc.getFinalAttrValue(allAttrs, fixedId, factorId)
local fixedValue = allAttrs[fixedId] or 0 local fixedValue = allAttrs[fixedId] or 0

View File

@ -2,48 +2,28 @@ local StarCell = class("StarCell", BaseCell)
function StarCell:init() function StarCell:init()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
self.starBg = uiMap["cell.star_bg"]
self.descTx = uiMap["cell.desc_tx"]
self.starImgs = {} self.starImgs = {}
for i = 1, 5 do for i = 1, 5 do
self.starImgs[i] = uiMap["cell.star_bg.star_img_" .. i] self.starImgs[i] = uiMap["star_cell.star_img_" .. i]
end
end end
-- self:addClickListener(function() function StarCell:refresh(currStar)
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.SKIN_SELECT, self.skinId) local starType = math.ceil(currStar / 5)
-- end)
end
function StarCell:refresh(heroEntity, idx)
self.heroEntity = heroEntity
if not self.heroEntity then
return
end
local star = self.heroEntity:getStar()
local starType = math.ceil(idx / 5)
for i, v in ipairs(self.starImgs) do for i, v in ipairs(self.starImgs) do
local star = (idx - 1)%5 + 1 local star = (currStar - 1)%5 + 1
if i <= star then if currStar > 0 and i <= star then
v:setActive(true) v:setActive(true)
v:setSprite(GFunc.getStarImg(starType)) v:setSprite(GFunc.getStarImg(starType))
else else
v:setActive(false) v:setActive(false)
end end
end end
if idx <= star then self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_board_quality_3")
else
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_board_quality_2")
end end
self.starBg:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_HORIZONTAL_OR_VERTICAL_LAYOUT):RefreshLayout()
local attr = heroEntity:getStarAttrCfg(idx) function StarCell:setActive(active)
local descTx = GFunc.getAttrDesc(attr.type, attr.num) self.baseObject:setActive(active)
if not table.containValue(GConst.MATCH_ALL_ATKP_NAME, attr.type) then
descTx = heroEntity:getName() .. descTx
end
self.descTx:setText(descTx)
end end
return StarCell return StarCell

View File

@ -0,0 +1,35 @@
local StarCell = class("StarCell", BaseCell)
function StarCell:init()
local uiMap = self:getUIMap()
self.starBg = uiMap["cell.star_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL)
self.descTx = uiMap["cell.desc_tx"]
-- self:addClickListener(function()
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.SKIN_SELECT, self.skinId)
-- end)
end
function StarCell:refresh(heroEntity, idx)
self.heroEntity = heroEntity
if not self.heroEntity then
return
end
local star = self.heroEntity:getStar()
self.starBg:refresh(idx)
if idx <= star then
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_bg_7")
else
self.baseObject:setSprite(GConst.ATLAS_PATH.COMMON, "common_bg_8")
end
local attr = heroEntity:getStarAttrCfg(idx)
local descTx = GFunc.getAttrDesc(attr.type, attr.num)
if not table.containValue(GConst.MATCH_ALL_ATKP_NAME, attr.type) then
descTx = heroEntity:getName() .. descTx
end
self.descTx:setText(descTx)
end
return StarCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 3a141fca655a34a979f4697d7ee4b52a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -18,7 +18,7 @@ function HeroDetailUI:onPressBackspace()
end end
function HeroDetailUI:ctor(parmas) function HeroDetailUI:ctor(parmas)
self.panelType = parmas.panelType or GConst.HeroConst.PANEL_TYPE.HERO self.page = parmas.panelType or GConst.HeroConst.PANEL_TYPE.HERO
self.formationType = parmas.formationType self.formationType = parmas.formationType
self.onlyLook = parmas.onlyLook self.onlyLook = parmas.onlyLook
if parmas.heroEntity then if parmas.heroEntity then
@ -27,34 +27,38 @@ function HeroDetailUI:ctor(parmas)
local heroId = parmas.heroId local heroId = parmas.heroId
self.heroEntity = DataManager.HeroData:getHeroById(heroId) self.heroEntity = DataManager.HeroData:getHeroById(heroId)
end end
self:initList()
end end
function HeroDetailUI:onLoadRootComplete() function HeroDetailUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
uiMap["hero_detail_ui.common.close_btn"]:addClickListener(function()
self:closeUI()
end)
-- self.commonInfo = uiMap["hero_detail_ui.common"] -- self.commonInfo = uiMap["hero_detail_ui.common"]
self.heroInfo = uiMap["hero_detail_ui.hero_info"] self.heroInfo = uiMap["hero_detail_ui.hero_info"]
self.starInfo = uiMap["hero_detail_ui.star_info"] self.starInfo = uiMap["hero_detail_ui.star_info"]
self.skinInfo = uiMap["hero_detail_ui.skin_info"] self.skinInfo = uiMap["hero_detail_ui.skin_info"]
self.titleTx = uiMap["hero_detail_ui.common.name_tx"] self.titleTx = uiMap["hero_detail_ui.common.name_tx"]
self.closeBtn = uiMap["hero_detail_ui.common.close_btn"]
self.bg = uiMap["hero_detail_ui.common.bg"] self.bg = uiMap["hero_detail_ui.common.bg"]
self.btnHero = uiMap["hero_detail_ui.common.btns.btn_hero"] -- self.btnHero = uiMap["hero_detail_ui.common.btns.btn_hero"]
self.txHero1 = uiMap["hero_detail_ui.common.btns.btn_hero.tx_btn"] -- self.txHero1 = uiMap["hero_detail_ui.common.btns.btn_hero.tx_btn"]
self.selectHero = uiMap["hero_detail_ui.common.btns.btn_hero.select"] -- self.selectHero = uiMap["hero_detail_ui.common.btns.btn_hero.select"]
self.txHero2 = uiMap["hero_detail_ui.common.btns.btn_hero.select.tx_select"] -- self.txHero2 = uiMap["hero_detail_ui.common.btns.btn_hero.select.tx_select"]
self.btnStar = uiMap["hero_detail_ui.common.btns.btn_star"] -- self.btnStar = uiMap["hero_detail_ui.common.btns.btn_star"]
self.lockStar = uiMap["hero_detail_ui.common.btns.btn_star.content.img_lock"] -- self.lockStar = uiMap["hero_detail_ui.common.btns.btn_star.content.img_lock"]
self.txStar1 = uiMap["hero_detail_ui.common.btns.btn_star.content.tx_btn"] -- self.txStar1 = uiMap["hero_detail_ui.common.btns.btn_star.content.tx_btn"]
self.selectStar = uiMap["hero_detail_ui.common.btns.btn_star.select"] -- self.selectStar = uiMap["hero_detail_ui.common.btns.btn_star.select"]
self.txStar2 = uiMap["hero_detail_ui.common.btns.btn_star.select.tx_select"] -- self.txStar2 = uiMap["hero_detail_ui.common.btns.btn_star.select.tx_select"]
self.btnSkin = uiMap["hero_detail_ui.common.btns.btn_skin"] -- self.btnSkin = uiMap["hero_detail_ui.common.btns.btn_skin"]
self.lockSkin = uiMap["hero_detail_ui.common.btns.btn_skin.content.img_lock"] -- self.lockSkin = uiMap["hero_detail_ui.common.btns.btn_skin.content.img_lock"]
self.txSkin1 = uiMap["hero_detail_ui.common.btns.btn_skin.content.tx_btn"] -- self.txSkin1 = uiMap["hero_detail_ui.common.btns.btn_skin.content.tx_btn"]
self.selectSkin = uiMap["hero_detail_ui.common.btns.btn_skin.select"] -- self.selectSkin = uiMap["hero_detail_ui.common.btns.btn_skin.select"]
self.txSkin2 = uiMap["hero_detail_ui.common.btns.btn_skin.select.tx_select"] -- self.txSkin2 = uiMap["hero_detail_ui.common.btns.btn_skin.select.tx_select"]
self.btnLeft = uiMap["hero_detail_ui.common.btn_left"] self.leftBtn = uiMap["hero_detail_ui.common.left_btn"]
self.btnRight = uiMap["hero_detail_ui.common.btn_right"] self.rightBtn = uiMap["hero_detail_ui.common.right_btn"]
self.heroNode = uiMap["hero_detail_ui.hero_node"] self.heroNode = uiMap["hero_detail_ui.hero_node"]
self.elementBg = uiMap["hero_detail_ui.common.hero_node.element_bg"] self.elementBg = uiMap["hero_detail_ui.common.hero_node.element_bg"]
@ -62,67 +66,66 @@ function HeroDetailUI:onLoadRootComplete()
self.heroElement = uiMap["hero_detail_ui.common.hero_node.hero_element"] self.heroElement = uiMap["hero_detail_ui.common.hero_node.hero_element"]
self.spineObjAvatar = uiMap["hero_detail_ui.common.hero_node.ui_spine_obj_avatar"] self.spineObjAvatar = uiMap["hero_detail_ui.common.hero_node.ui_spine_obj_avatar"]
self.powerTx = uiMap["hero_detail_ui.common.power_img.power_tx"] self.powerTx = uiMap["hero_detail_ui.common.power_img.power_tx"]
self.qltBg = uiMap["hero_detail_ui.common.qlt_bg"]
self.qltBgTx = uiMap["hero_detail_ui.common.qlt_bg.qlt_tx"]
self.starComp = uiMap["hero_detail_ui.common.hero_node.star_cell"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL)
self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)) self.btnTxs = {I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4), "升星"}
self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)) self.pageBtns = {}
self.pageBtnTxs = {}
self.pageBtnLocks = {}
for i = 1, 2 do
self.pageBtns[i] = uiMap["hero_detail_ui.common.btns.page_btn_" .. i]
self.pageBtnTxs[i] = uiMap["hero_detail_ui.common.btns.page_btn_" .. i .. ".text"]
self.pageBtnLocks[i] = uiMap["hero_detail_ui.common.btns.page_btn_" .. i .. ".lock_img"]
if self.pageBtnLocks[i] then
self.pageBtnLocks[i]:setActive(not self:getIsOpen(i))
end
self.pageBtns[i] :addClickListener(function()
if not self:getIsOpen(i) or self.page == i then
return
end
self.page = i
self:onRefresh()
end)
end
-- self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
-- self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
-- self.txStar1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1)) -- self.txStar1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
-- self.txStar2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1)) -- self.txStar2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
-- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2)) -- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
-- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2)) -- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
self.txStar1:setText("升星") -- self.txStar1:setText("升星")
self.txStar2:setText("升星") -- self.txStar2:setText("升星")
self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN)) -- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN)) -- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
self.powerTx:setText(1313213) self.powerTx:setText(1313213)
if not DataManager.HeroData:isStarOpen() then -- if not DataManager.HeroData:isStarOpen() then
self.lockStar:setVisible(true) -- self.lockStar:setVisible(true)
GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5) -- GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5)
else -- else
self.lockStar:setVisible(false) -- self.lockStar:setVisible(false)
end -- end
if not DataManager.HeroData:isSkinOpen() then -- if not DataManager.HeroData:isSkinOpen() then
self.lockSkin:setVisible(true) -- self.lockSkin:setVisible(true)
GFunc.centerImgAndTx(self.lockSkin, self.txSkin1, 5) -- GFunc.centerImgAndTx(self.lockSkin, self.txSkin1, 5)
else -- else
self.lockSkin:setVisible(false) -- self.lockSkin:setVisible(false)
end -- end
self.leftBtn:addClickListener(function()
self.btnHero:addClickListener(function()
self.panelType = GConst.HeroConst.PANEL_TYPE.HERO
self:refreshShow()
end)
self.btnStar:addClickListener(function()
if not DataManager.HeroData:isStarOpen(true) then
return
end
self.panelType = GConst.HeroConst.PANEL_TYPE.STAR
self:refreshShow()
end)
self.btnSkin:addClickListener(function()
if not DataManager.HeroData:isSkinOpen(true) then
return
end
self.panelType = GConst.HeroConst.PANEL_TYPE.SKIN
self:refreshShow()
end)
self.closeBtn:addClickListener(function()
self:closeUI()
end)
self.btnLeft:addClickListener(function()
if not self:isShowLeftArrow() then if not self:isShowLeftArrow() then
return return
end end
self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxLast].cfgId) self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxLast].cfgId)
self:updateSide() self:onRefresh()
self:refreshShow()
end) end)
self.btnRight:addClickListener(function() self.rightBtn:addClickListener(function()
if not self:isShowRightArrow() then if not self:isShowRightArrow() then
return return
end end
self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxNext].cfgId) self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxNext].cfgId)
self:updateSide() self:onRefresh()
self:refreshShow()
end) end)
self:bind(DataManager.BagData.ItemData, "dirty", function() self:bind(DataManager.BagData.ItemData, "dirty", function()
self:refreshRedPoint() self:refreshRedPoint()
@ -153,11 +156,37 @@ function HeroDetailUI:onLoadRootComplete()
end) end)
end end
function HeroDetailUI:onRefresh() function HeroDetailUI:initList()
self.heroList = DataManager.HeroData:getAllHeroesSort(self.formationType) self.heroList = DataManager.HeroData:getAllHeroesSort(self.formationType)
self:updateSide() end
self:refreshShow()
function HeroDetailUI:getIsOpen(page)
if page == GConst.HeroConst.PANEL_TYPE.HERO then
return true
elseif page == GConst.HeroConst.PANEL_TYPE.STAR then
return DataManager.HeroData:isStarOpen()
end
return false
end
function HeroDetailUI:onRefresh()
self:updateHero() self:updateHero()
self:updateSide()
self:refreshPageInfo()
end
function HeroDetailUI:changePage(page)
self.page = page
self:onRefresh()
end
function HeroDetailUI:updateSide()
for index, data in ipairs(self.heroList) do
if data.cfgId == self.heroEntity:getCfgId() then
self.idxLast = index - 1
self.idxNext = index + 1
end
end
end end
function HeroDetailUI:updateHero() function HeroDetailUI:updateHero()
@ -176,58 +205,52 @@ function HeroDetailUI:updateHero()
self.spineObjAvatar:getSkeletonGraphic().enabled = true self.spineObjAvatar:getSkeletonGraphic().enabled = true
self.spineObjAvatar:playAnim("idle", true, true, true) self.spineObjAvatar:playAnim("idle", true, true, true)
end, true) end, true)
local qlt = self.heroEntity:getQlt()
self.starComp:refresh(self.heroEntity:getStar())
self.qltBg:setSprite(GFunc.getHeroQltImg(qlt))
self.qltBgTx:setText(GFunc.getHeroQltStr(qlt))
end end
function HeroDetailUI:updateSide() function HeroDetailUI:refreshPageInfo()
for index, data in ipairs(self.heroList) do
if data.cfgId == self.heroEntity:getCfgId() then
self.idxLast = index - 1
self.idxNext = index + 1
end
end
end
function HeroDetailUI:changePage(panelType)
self.panelType = panelType
self:refreshShow()
end
function HeroDetailUI:refreshShow()
self.titleTx:setText(self.heroEntity:getName()) self.titleTx:setText(self.heroEntity:getName())
if self.panelType == GConst.HeroConst.PANEL_TYPE.HERO then if self.page == GConst.HeroConst.PANEL_TYPE.HERO then
self:showHeroInfo() self:showHeroInfo()
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.STAR then elseif self.page == GConst.HeroConst.PANEL_TYPE.STAR then
self:showStarInfo() self:showStarInfo()
elseif self.panelType == GConst.HeroConst.PANEL_TYPE.SKIN then elseif self.page == GConst.HeroConst.PANEL_TYPE.SKIN then
self:showskinInfo() self:showskinInfo()
end end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮 if self.onlyLook then -- 仅查看的不显示升级和激活按钮
self.btnHero:setActive(false) self.leftBtn:setActive(false)
self.btnStar:setActive(false) self.rightBtn:setActive(false)
self.btnSkin:setActive(false) for i = 1, 2 do
self.btnLeft:setActive(false) self.pageBtns[i]:setActive(false)
self.btnRight:setActive(false) end
-- if self.panelType == GConst.HeroConst.PANEL_TYPE.HERO then
-- self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_LOOK_HERO)
-- end
else else
self.btnHero:setActive(true) self.leftBtn:setActive(self:isShowLeftArrow())
self.btnStar:setActive(true) self.rightBtn:setActive(self:isShowRightArrow())
self.btnSkin:setActive(true) for i = 1, 2 do
self.btnLeft:setActive(self:isShowLeftArrow()) self.pageBtns[i]:setActive(true)
self.btnRight:setActive(self:isShowRightArrow()) if self.page == i then
-- self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_HERO) self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_tab_1")
self.pageBtnTxs[i]:setText(self.btnTxs[i])
else
self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.COMMON, "common_tab_2")
self.pageBtnTxs[i]:setText("<color=#72778C>" .. self.btnTxs[i] .. "</color>")
end
end
self:refreshRedPoint() self:refreshRedPoint()
end end
end end
-- 刷新标签红点 -- 刷新标签红点
function HeroDetailUI:refreshRedPoint() function HeroDetailUI:refreshRedPoint()
if self.heroEntity:canLvUp() then -- if self.heroEntity:canLvUp() then
self.btnHero:addRedPoint(-55, 0, 0.6) -- self.btnHero:addRedPoint(-55, 0, 0.6)
else -- else
self.btnHero:removeRedPoint() -- self.btnHero:removeRedPoint()
end -- end
-- if DataManager.EquipData:canUpgradeStar(self.heroEntity:getCfgId()) then -- if DataManager.EquipData:canUpgradeStar(self.heroEntity:getCfgId()) then
-- self.btnStar:addRedPoint(-55, 0, 0.6) -- self.btnStar:addRedPoint(-55, 0, 0.6)
-- else -- else
@ -242,11 +265,11 @@ end
function HeroDetailUI:showHeroInfo() function HeroDetailUI:showHeroInfo()
self.heroInfo:setActive(true) self.heroInfo:setActive(true)
self.selectHero:setActive(true) -- self.selectHero:setActive(true)
self.starInfo:setActive(false) self.starInfo:setActive(false)
self.selectStar:setActive(false) -- self.selectStar:setActive(false)
self.skinInfo:setActive(false) self.skinInfo:setActive(false)
self.selectSkin:setActive(false) -- self.selectSkin:setActive(false)
self.bg:setActive(true) self.bg:setActive(true)
if not self.compHero then if not self.compHero then
@ -261,11 +284,11 @@ end
function HeroDetailUI:showStarInfo() function HeroDetailUI:showStarInfo()
self.heroInfo:setActive(false) self.heroInfo:setActive(false)
self.selectHero:setActive(false) -- self.selectHero:setActive(false)
self.starInfo:setActive(true) self.starInfo:setActive(true)
self.selectStar:setActive(true) -- self.selectStar:setActive(true)
self.skinInfo:setActive(false) self.skinInfo:setActive(false)
self.selectSkin:setActive(false) -- self.selectSkin:setActive(false)
self.bg:setActive(true) self.bg:setActive(true)
if not self.compStar then if not self.compStar then
@ -281,11 +304,11 @@ end
function HeroDetailUI:showskinInfo() function HeroDetailUI:showskinInfo()
self.heroInfo:setActive(false) self.heroInfo:setActive(false)
self.selectHero:setActive(false) -- self.selectHero:setActive(false)
self.starInfo:setActive(false) self.starInfo:setActive(false)
self.selectStar:setActive(false) -- self.selectStar:setActive(false)
self.skinInfo:setActive(true) self.skinInfo:setActive(true)
self.selectSkin:setActive(true) -- self.selectSkin:setActive(true)
self.bg:setActive(true) self.bg:setActive(true)
if not self.compSkin then if not self.compSkin then
@ -301,7 +324,7 @@ end
-- 是否显示左箭头 -- 是否显示左箭头
function HeroDetailUI:isShowLeftArrow() function HeroDetailUI:isShowLeftArrow()
if self.panelType == GConst.HeroConst.PANEL_TYPE.RUNES then if self.page == GConst.HeroConst.PANEL_TYPE.RUNES then
return false return false
end end
@ -310,7 +333,7 @@ end
-- 是否显示右箭头 -- 是否显示右箭头
function HeroDetailUI:isShowRightArrow() function HeroDetailUI:isShowRightArrow()
if self.panelType == GConst.HeroConst.PANEL_TYPE.RUNES then if self.page == GConst.HeroConst.PANEL_TYPE.RUNES then
return false return false
end end

View File

@ -56,7 +56,10 @@ function HeroInfoComp:init()
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity) ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity)
end) end)
self.btnUp5:addClickListener(function() self.btnUp5:addClickListener(function()
local canLvUpLv = self.heroEntity:getLvUpLv() local canLvUpLv, canLvUp = self.heroEntity:getLvUpLv()
if not canLvUp then
return
end
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity, canLvUpLv) ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity, canLvUpLv)
end) end)
self.btnskillDescTxs:addClickListener(function() self.btnskillDescTxs:addClickListener(function()

View File

@ -1,6 +1,6 @@
local StarInfoComp = class("StarInfoComp", LuaComponent) local StarInfoComp = class("StarInfoComp", LuaComponent)
local STAR_CELL = "app/ui/hero/cell/star_cell" local STAR_CELL = "app/ui/hero/cell/star_info_cell"
function StarInfoComp:init() function StarInfoComp:init()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
@ -15,14 +15,8 @@ function StarInfoComp:init()
self.costCells[i] = uiMap["star_info.upgrade.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL) self.costCells[i] = uiMap["star_info.upgrade.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
end end
self.currStarImgs = {} self.currStarBg = uiMap["star_info.info_node.curr_star_bg"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL)
self.nextStarImgs = {} self.nextStarBg = uiMap["star_info.info_node.next_star_bg"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.STAR_CELL)
for i = 1, 5 do
self.currStarImgs[i] = uiMap["star_info.info_node.curr_star_bg.star_img_" .. i]
self.nextStarImgs[i] = uiMap["star_info.info_node.next_star_bg.star_img_" .. i]
end
self.currStarBg = uiMap["star_info.info_node.curr_star_bg"]
self.nextStarBg = uiMap["star_info.info_node.next_star_bg"]
self.currLvTx = uiMap["star_info.info_node.curr_lv_tx"] self.currLvTx = uiMap["star_info.info_node.curr_lv_tx"]
self.nextLvTx = uiMap["star_info.info_node.next_lv_tx"] self.nextLvTx = uiMap["star_info.info_node.next_lv_tx"]
@ -73,16 +67,7 @@ function StarInfoComp:refreshInfo()
self.currLvTx:setActive(true) self.currLvTx:setActive(true)
self.nextLvTx:setActive(false) self.nextLvTx:setActive(false)
local currStar = self.heroEntity:getStar() local currStar = self.heroEntity:getStar()
local starType = math.ceil(currStar / 5) self.currStarBg:refresh(currStar)
for i = 1, 5 do
local star = (currStar - 1)%5 + 1
if i <= star then
self.currStarImgs[i]:setActive(true)
self.currStarImgs[i]:setSprite(GFunc.getStarImg(starType))
else
self.currStarImgs[i]:setActive(false)
end
end
local lv = self.heroEntity:getMaxLv() local lv = self.heroEntity:getMaxLv()
self.currLvTx:setText(lv .. "/" .. lv) self.currLvTx:setText(lv .. "/" .. lv)
else else
@ -92,29 +77,14 @@ function StarInfoComp:refreshInfo()
self.nextLvTx:setActive(true) self.nextLvTx:setActive(true)
local currStar = self.heroEntity:getStar() local currStar = self.heroEntity:getStar()
local nextStar = currStar + 1 local nextStar = currStar + 1
local starType = math.ceil(currStar / 5) self.currStarBg:refresh(currStar)
local starTypeNext = math.ceil(nextStar / 5) self.nextStarBg:refresh(nextStar)
for i = 1, 5 do
local star = (currStar - 1)%5 + 1
if i <= star then
self.currStarImgs[i]:setActive(true)
self.currStarImgs[i]:setSprite(GFunc.getStarImg(starType))
else
self.currStarImgs[i]:setActive(false)
end
local star2 = (nextStar - 1)%5 + 1
if i <= star2 then
self.nextStarImgs[i]:setActive(true)
self.nextStarImgs[i]:setSprite(GFunc.getStarImg(starTypeNext))
else
self.nextStarImgs[i]:setActive(false)
end
end
local lv = self.heroEntity:getLv() local lv = self.heroEntity:getLv()
local maxLv = self.heroEntity:getCurrMaxLv() local maxLv = self.heroEntity:getCurrMaxLv()
local nextMaxLv = self.heroEntity:getNextMaxLv() local nextMaxLv = self.heroEntity:getNextMaxLv()
self.currLvTx:setText(lv .. "/" .. maxLv) local lvStr = I18N:getGlobalText(I18N.GlobalConst.ACT_DESC_12)
self.nextLvTx:setText(lv .. "/" .. nextMaxLv) self.currLvTx:setText(lvStr .. "<color=#D82F2D>" .. lv .. "</color>" .. "/" .. maxLv)
self.nextLvTx:setText(lvStr .. lv .. "/" .. "<color=#54E845>" .. nextMaxLv .. "</color>")
end end
end end

View File

@ -435,7 +435,7 @@ function HeroEntity:getLvUpLv()
end end
count = count + 1 count = count + 1
end end
return count return count + self.data.lv, count == 0
end end
-- endregion -- endregion