From 015de6fc7091e301a287deb9e88b151c3c86261a Mon Sep 17 00:00:00 2001 From: Fang Date: Thu, 20 Jul 2023 21:23:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8B=B1=E9=9B=84=E5=8D=87=E7=BA=A7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E3=80=81=E6=88=98=E6=96=97=E6=8A=A5=E9=94=99fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/component/battle_unit_comp.lua | 2 +- lua/app/ui/hero/hero_info_comp.lua | 6 +-- lua/app/userdata/equip/equip_data.lua | 2 +- lua/app/userdata/hero/hero_entity.lua | 41 +++++++------------ 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index 92496c0b..a3085979 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -1728,7 +1728,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d local team = self.battleController:getOtherSideTeam(self.side) team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN) end - if self.unitEntity:getTotalAttrValue(BattleConst.ATTR_NAME.BLEED) > 0 then + if self.unitEntity:getAttrValue(BattleConst.ATTR_NAME.BLEED) > 0 then local team = self.battleController:getOtherSideTeam(self.side) team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_WITH_BLEED) end diff --git a/lua/app/ui/hero/hero_info_comp.lua b/lua/app/ui/hero/hero_info_comp.lua index add7a364..d8632552 100644 --- a/lua/app/ui/hero/hero_info_comp.lua +++ b/lua/app/ui/hero/hero_info_comp.lua @@ -57,7 +57,7 @@ end function HeroInfoComp:setHeroData(heroEntity, onlyLook) self.heroEntity = heroEntity self.onlyLook = onlyLook - self:bind(self.heroEntity, "lv", function() + self:bind(self.heroEntity, "isDirty", function() self:refresh(true) end) end @@ -140,8 +140,8 @@ function HeroInfoComp:refresh(lvChange) str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4) local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR - local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp - local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk + local addHp = (self.heroEntity:getCfgHp(lv + 1) - self.heroEntity:getCfgHp()) // DEFAULT_FACTOR + local addAtk = (self.heroEntity:getCfgAtk(lv + 1) - self.heroEntity:getCfgAtk()) // DEFAULT_FACTOR if addHp <= 0 then hpStr = curHp else diff --git a/lua/app/userdata/equip/equip_data.lua b/lua/app/userdata/equip/equip_data.lua index 906cba66..0a677b7c 100644 --- a/lua/app/userdata/equip/equip_data.lua +++ b/lua/app/userdata/equip/equip_data.lua @@ -79,7 +79,7 @@ function EquipData:onUpgradeEquip(heroId, part) return end entity:onLevelUp() - DataManager.HeroData:getHeroById(heroId):setEquipAttrDirty() + DataManager.HeroData:getHeroById(heroId):onEquipAttrChange() EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS) end diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index 7cb0e3db..48daa0f5 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -3,10 +3,9 @@ local ATTR_NAME = GConst.BattleConst.ATTR_NAME function HeroEntity:ctor(cfgId, lv, collectionLevel) self.cfgId = cfgId + self.data.isDirty = false self.data.lv = lv self.data.collectionLevel = collectionLevel - self.baseAttrDirty = false - self.equipAttrDirty = false self.config = ConfigManager:getConfig("hero")[self.cfgId] self.beginLv = self.config.begin_lv -- 初始等级 end @@ -36,34 +35,23 @@ function HeroEntity:initAttr() self:updateAllAttr() end -function HeroEntity:setBaseAttrDirty() - self.baseAttrDirty = true +function HeroEntity:onBaseAttrChange() + self:updateBaseAttr() + self:updateTotalAttr() + self:setDirty() end -function HeroEntity:setEquipAttrDirty() - self.equipAttrDirty = true +function HeroEntity:onEquipAttrChange() + self:updateEquipAttr() + self:updateTotalAttr() + self:setDirty() +end + +function HeroEntity:setDirty() + self.data.isDirty = not self.data.isDirty end function HeroEntity:getAllAttr() - if self.allAttr == nil then - self:initAttr() - end - local needUpdate = false - - if self.baseAttrDirty == true then - needUpdate = true - self.baseAttrDirty = false - self:updateBaseAttr() - end - if self.equipAttrDirty == true then - needUpdate = true - self.equipAttrDirty = false - self:updateEquipAttr() - end - - if needUpdate then - self:updateTotalAttr() - end return self.allAttr end @@ -154,6 +142,7 @@ function HeroEntity:updateTotalAttr() end function HeroEntity:setTotalAttrValue(name, value) + -- Logger.logHighlight("set "..name..":"..value) self.allAttr[name] = GFunc.encryptNumber(value or 0) end @@ -182,8 +171,8 @@ function HeroEntity:setLv(lv) return end self.data.lv = lv + self:onBaseAttrChange() ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv) - self:setBaseAttrDirty() end function HeroEntity:getCfgId()