英雄属性

This commit is contained in:
chenxi 2023-04-13 14:32:47 +08:00
parent c955bc3e26
commit f79124999a

View File

@ -4,8 +4,6 @@ function HeroEntity:ctor(cfgId, lv)
self.id = cfgId self.id = cfgId
self.cfgId = cfgId self.cfgId = cfgId
self.data.lv = lv self.data.lv = lv
self.atkKey = nil
self.hpKey = nil
self.attrDirty = false self.attrDirty = false
self.config = ConfigManager:getConfig("hero")[self.cfgId] self.config = ConfigManager:getConfig("hero")[self.cfgId]
@ -28,8 +26,6 @@ function HeroEntity:setLv(lv)
return return
end end
self.data.lv = lv self.data.lv = lv
self.atkKey = nil
self.hpKey = nil
self:setDirty() self:setDirty()
end end
@ -66,22 +62,13 @@ function HeroEntity:updateAttr()
end end
function HeroEntity:updateBaseAttr() function HeroEntity:updateBaseAttr()
self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config[self:getHpKey()] or 0 if self.data.lv <= 0 then
self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = self.config[self:getAtkKey()] or 0 self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = 0
end self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = 0
else
function HeroEntity:getHpKey() self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config.hp[self.data.lv] or self.config.hp[#self.config.hp]
if self.hpKey == nil then self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = self.config.atk[self.data.lv] or self.config.atk[#self.config.atk]
self.hpKey = "hp_" .. self.data.lv
end end
return self.hpKey
end
function HeroEntity:getAtkKey()
if self.atkKey == nil then
self.atkKey = "atk_" .. self.data.lv
end
return self.atkKey
end end
function HeroEntity:getAtk() function HeroEntity:getAtk()