From e688bfd26d5b401e3e97321462461d033c603a4a Mon Sep 17 00:00:00 2001 From: Fang Date: Wed, 26 Jul 2023 18:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E7=BA=A2=E7=82=B9fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/app/ui/common/cell/hero_cell.lua | 26 ++++++++++++++++++++------ lua/app/userdata/bag/item_data.lua | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/lua/app/ui/common/cell/hero_cell.lua b/lua/app/ui/common/cell/hero_cell.lua index 4adc77d3..54758ab2 100644 --- a/lua/app/ui/common/cell/hero_cell.lua +++ b/lua/app/ui/common/cell/hero_cell.lua @@ -28,22 +28,23 @@ function HeroCell:init() self.clickCallback() end end) + self:bind(DataManager.BagData.ItemData, "dirty", function() + self:refreshRedPoint() + end) end function HeroCell:refresh(heroEntity, isGray) self.heroEntity = heroEntity + self:bind(self.heroEntity, "isDirty", function() + self:refreshRedPoint() + end) + self.selfNode:setVisible(true) self.otherNode:setVisible(false) local heroInfo = heroEntity:getConfig() 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() self.lvUpArrow:setVisible(canLvUp) if canLvUp then @@ -85,6 +86,19 @@ function HeroCell:refresh(heroEntity, isGray) 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 function HeroCell:getHeroId() diff --git a/lua/app/userdata/bag/item_data.lua b/lua/app/userdata/bag/item_data.lua index 0ad9cf8f..e2423d54 100644 --- a/lua/app/userdata/bag/item_data.lua +++ b/lua/app/userdata/bag/item_data.lua @@ -108,6 +108,7 @@ function ItemData:addItemCost(cost, itemGetType) CACHE_ITEM.id = GFunc.getRewardId(cost) CACHE_ITEM.count = -GFunc.getRewardNum(cost) self:addItem(CACHE_ITEM, itemGetType) + self:setDirty() end function ItemData:addItemCosts(costs, itemGetType)