This commit is contained in:
Fang 2023-07-14 17:35:55 +08:00
parent b2dba1de2e
commit e2ef9ea208
5 changed files with 56 additions and 3 deletions

View File

@ -70,6 +70,13 @@ function HeroComp:init()
self.heroBgSpineObj[index]:playAnim("idle", true, false) self.heroBgSpineObj[index]:playAnim("idle", true, false)
end end
end end
self:bind(DataManager.CollectionData, "dirtyHero", function()
self:refreshCollectEntrance()
end)
self:bind(DataManager.HeroData, "isDirty", function()
self:refreshCollectEntrance()
end)
end end
function HeroComp:refresh(battleType) function HeroComp:refresh(battleType)
@ -77,6 +84,7 @@ function HeroComp:refresh(battleType)
self:clearAdapt() self:clearAdapt()
self:adapt() self:adapt()
self:refreshCollectEntrance()
if self.battleType == GConst.BattleConst.FORMATION_TYPE.STAGE then if self.battleType == GConst.BattleConst.FORMATION_TYPE.STAGE then
self:refreshStageFormation() self:refreshStageFormation()
elseif self.battleType == GConst.BattleConst.FORMATION_TYPE.ARENA_ATTACK then elseif self.battleType == GConst.BattleConst.FORMATION_TYPE.ARENA_ATTACK then
@ -91,7 +99,6 @@ function HeroComp:refreshStageFormation()
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_BTN_2)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_BTN_2))
self.rimgTopBG:setTexture("assets/arts/textures/background/hero/hero_bg_1.png") self.rimgTopBG:setTexture("assets/arts/textures/background/hero/hero_bg_1.png")
self.curFormation = DataManager.FormationData:getStageFormation() self.curFormation = DataManager.FormationData:getStageFormation()
self.btnCollection:setVisible(DataManager.CollectionData:isOpen(GConst.CollectionConst.TYPE.HERO))
self.onClickUseFunc = function(id, type) self.onClickUseFunc = function(id, type)
ModuleManager.FormationManager:upHeroToStageFormation(id, type) ModuleManager.FormationManager:upHeroToStageFormation(id, type)
@ -105,7 +112,6 @@ function HeroComp:refreshArenaFightFormation()
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_10)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_10))
self.rimgTopBG:setTexture("assets/arts/textures/background/arena/arena_bg_2.png") self.rimgTopBG:setTexture("assets/arts/textures/background/arena/arena_bg_2.png")
self.curFormation = DataManager.FormationData:getArenaAttackFormation() self.curFormation = DataManager.FormationData:getArenaAttackFormation()
self.btnCollection:setVisible(false)
self.onClickUseFunc = function(id, type) self.onClickUseFunc = function(id, type)
DataManager.FormationData:upHeroToFormation(self.battleType, type, id) DataManager.FormationData:upHeroToFormation(self.battleType, type, id)
@ -120,7 +126,6 @@ function HeroComp:refreshArenaDefendFormation()
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_9)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.ARENA_DESC_9))
self.rimgTopBG:setTexture("assets/arts/textures/background/arena/arena_bg_2.png") self.rimgTopBG:setTexture("assets/arts/textures/background/arena/arena_bg_2.png")
self.curFormation = DataManager.FormationData:getArenaDefendFormation() self.curFormation = DataManager.FormationData:getArenaDefendFormation()
self.btnCollection:setVisible(false)
self.onClickUseFunc = function(id, type) self.onClickUseFunc = function(id, type)
DataManager.FormationData:upHeroToFormation(self.battleType, type, id) DataManager.FormationData:upHeroToFormation(self.battleType, type, id)
@ -279,4 +284,18 @@ function HeroComp:getHeroCell(heroId)
return targetCell return targetCell
end end
-- 刷新图鉴入口
function HeroComp:refreshCollectEntrance()
if self.battleType == GConst.BattleConst.FORMATION_TYPE.STAGE then
self.btnCollection:setVisible(DataManager.CollectionData:isOpen(GConst.CollectionConst.TYPE.HERO))
if DataManager.CollectionData:hasRedPoint(GConst.CollectionConst.TYPE.HERO) then
self.btnCollection:addRedPoint(25, 30, 0.6)
else
self.btnCollection:removeRedPoint()
end
else
self.btnCollection:setVisible(false)
end
end
return HeroComp return HeroComp

View File

@ -6,6 +6,11 @@ local CollectionBaseEntity = class("CollectionBaseEntity", BaseData)
function CollectionBaseEntity:init(data) function CollectionBaseEntity:init(data)
end end
-- 是否有红点
function CollectionBaseEntity:hasRedPoint()
return nil
end
-- 获取当前收集值 -- 获取当前收集值
function CollectionBaseEntity:getCurCollectPoint() function CollectionBaseEntity:getCurCollectPoint()
return nil return nil

View File

@ -61,6 +61,11 @@ function CollectionData:getCollectEntity(type)
return self.dataCollects[type] return self.dataCollects[type]
end end
-- 是否有红点
function CollectionData:hasRedPoint(type)
return self.dataCollects[type]:hasRedPoint()
end
-- 获取当前收集值 -- 获取当前收集值
function CollectionData:getCurCollectPoint(type) function CollectionData:getCurCollectPoint(type)
return self.dataCollects[type]:getCurCollectPoint() return self.dataCollects[type]:getCurCollectPoint()

View File

@ -9,6 +9,26 @@ function CollectionHeroEntity:init(data)
self.curPoint = data.point self.curPoint = data.point
end end
-- 是否有红点
function CollectionHeroEntity:hasRedPoint()
-- 可领点数
for idx, data in pairs(self:getCollectList()) do
if self:getCanCollectPoint(data.id) > 0 then
return true
end
end
-- 可领奖励
for id, data in pairs(self:getRewardList()) do
if self:isMeetTargetPoint(id) and not self:isRewardReceived(id) then
return true
end
end
return false
end
-- 获取当前收集值 -- 获取当前收集值
function CollectionHeroEntity:getCurCollectPoint() function CollectionHeroEntity:getCurCollectPoint()
return self.curPoint return self.curPoint

View File

@ -173,6 +173,10 @@ function HeroData:getRp()
end end
end end
if DataManager.CollectionData:hasRedPoint(GConst.CollectionConst.TYPE.HERO) then
return true
end
return false return false
end end