英雄红点fix

This commit is contained in:
Fang 2023-07-26 18:23:12 +08:00
parent 260b6f0c95
commit e688bfd26d
2 changed files with 21 additions and 6 deletions

View File

@ -28,22 +28,23 @@ function HeroCell:init()
self.clickCallback() self.clickCallback()
end end
end) end)
self:bind(DataManager.BagData.ItemData, "dirty", function()
self:refreshRedPoint()
end)
end end
function HeroCell:refresh(heroEntity, isGray) function HeroCell:refresh(heroEntity, isGray)
self.heroEntity = heroEntity self.heroEntity = heroEntity
self:bind(self.heroEntity, "isDirty", function()
self:refreshRedPoint()
end)
self.selfNode:setVisible(true) self.selfNode:setVisible(true)
self.otherNode:setVisible(false) self.otherNode:setVisible(false)
local heroInfo = heroEntity:getConfig() local heroInfo = heroEntity:getConfig()
self:_refresh(heroInfo, isGray) self:_refresh(heroInfo, isGray)
if DataManager.EquipData:canUpgradeEquip(self.heroEntity:getCfgId()) then
self.selfNode:addRedPoint(55, -35, 0.64)
else
self.selfNode:removeRedPoint()
end
local canLvUp = heroEntity:canLvUp() local canLvUp = heroEntity:canLvUp()
self.lvUpArrow:setVisible(canLvUp) self.lvUpArrow:setVisible(canLvUp)
if canLvUp then if canLvUp then
@ -85,6 +86,19 @@ function HeroCell:refresh(heroEntity, isGray)
end end
end end
end end
self:refreshRedPoint()
end
-- 刷新红点
function HeroCell:refreshRedPoint()
if self.heroEntity == nil then
return
end
if DataManager.EquipData:canUpgradeEquip(self.heroEntity:getCfgId()) then
self.selfNode:addRedPoint(55, -35, 0.64)
else
self.selfNode:removeRedPoint()
end
end end
function HeroCell:getHeroId() function HeroCell:getHeroId()

View File

@ -108,6 +108,7 @@ function ItemData:addItemCost(cost, itemGetType)
CACHE_ITEM.id = GFunc.getRewardId(cost) CACHE_ITEM.id = GFunc.getRewardId(cost)
CACHE_ITEM.count = -GFunc.getRewardNum(cost) CACHE_ITEM.count = -GFunc.getRewardNum(cost)
self:addItem(CACHE_ITEM, itemGetType) self:addItem(CACHE_ITEM, itemGetType)
self:setDirty()
end end
function ItemData:addItemCosts(costs, itemGetType) function ItemData:addItemCosts(costs, itemGetType)