英雄升级显示、战斗报错fix

This commit is contained in:
Fang 2023-07-20 21:23:02 +08:00
parent 95aa50bb42
commit 015de6fc70
4 changed files with 20 additions and 31 deletions

View File

@ -1728,7 +1728,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
local team = self.battleController:getOtherSideTeam(self.side) local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN) team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN)
end 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) local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_WITH_BLEED) team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_WITH_BLEED)
end end

View File

@ -57,7 +57,7 @@ end
function HeroInfoComp:setHeroData(heroEntity, onlyLook) function HeroInfoComp:setHeroData(heroEntity, onlyLook)
self.heroEntity = heroEntity self.heroEntity = heroEntity
self.onlyLook = onlyLook self.onlyLook = onlyLook
self:bind(self.heroEntity, "lv", function() self:bind(self.heroEntity, "isDirty", function()
self:refresh(true) self:refresh(true)
end) end)
end end
@ -140,8 +140,8 @@ function HeroInfoComp:refresh(lvChange)
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4) str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)
local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR
local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR
local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp local addHp = (self.heroEntity:getCfgHp(lv + 1) - self.heroEntity:getCfgHp()) // DEFAULT_FACTOR
local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk local addAtk = (self.heroEntity:getCfgAtk(lv + 1) - self.heroEntity:getCfgAtk()) // DEFAULT_FACTOR
if addHp <= 0 then if addHp <= 0 then
hpStr = curHp hpStr = curHp
else else

View File

@ -79,7 +79,7 @@ function EquipData:onUpgradeEquip(heroId, part)
return return
end end
entity:onLevelUp() entity:onLevelUp()
DataManager.HeroData:getHeroById(heroId):setEquipAttrDirty() DataManager.HeroData:getHeroById(heroId):onEquipAttrChange()
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS) EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS)
end end

View File

@ -3,10 +3,9 @@ local ATTR_NAME = GConst.BattleConst.ATTR_NAME
function HeroEntity:ctor(cfgId, lv, collectionLevel) function HeroEntity:ctor(cfgId, lv, collectionLevel)
self.cfgId = cfgId self.cfgId = cfgId
self.data.isDirty = false
self.data.lv = lv self.data.lv = lv
self.data.collectionLevel = collectionLevel self.data.collectionLevel = collectionLevel
self.baseAttrDirty = false
self.equipAttrDirty = false
self.config = ConfigManager:getConfig("hero")[self.cfgId] self.config = ConfigManager:getConfig("hero")[self.cfgId]
self.beginLv = self.config.begin_lv -- 初始等级 self.beginLv = self.config.begin_lv -- 初始等级
end end
@ -36,34 +35,23 @@ function HeroEntity:initAttr()
self:updateAllAttr() self:updateAllAttr()
end end
function HeroEntity:setBaseAttrDirty() function HeroEntity:onBaseAttrChange()
self.baseAttrDirty = true self:updateBaseAttr()
self:updateTotalAttr()
self:setDirty()
end end
function HeroEntity:setEquipAttrDirty() function HeroEntity:onEquipAttrChange()
self.equipAttrDirty = true self:updateEquipAttr()
self:updateTotalAttr()
self:setDirty()
end
function HeroEntity:setDirty()
self.data.isDirty = not self.data.isDirty
end end
function HeroEntity:getAllAttr() 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 return self.allAttr
end end
@ -154,6 +142,7 @@ function HeroEntity:updateTotalAttr()
end end
function HeroEntity:setTotalAttrValue(name, value) function HeroEntity:setTotalAttrValue(name, value)
-- Logger.logHighlight("set "..name..":"..value)
self.allAttr[name] = GFunc.encryptNumber(value or 0) self.allAttr[name] = GFunc.encryptNumber(value or 0)
end end
@ -182,8 +171,8 @@ function HeroEntity:setLv(lv)
return return
end end
self.data.lv = lv self.data.lv = lv
self:onBaseAttrChange()
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv) ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
self:setBaseAttrDirty()
end end
function HeroEntity:getCfgId() function HeroEntity:getCfgId()