英雄属性
This commit is contained in:
parent
c955bc3e26
commit
f79124999a
@ -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
|
||||||
|
self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = 0
|
||||||
|
else
|
||||||
|
self.baseAttrOriginal[GConst.ATTR_TYPE.hp] = self.config.hp[self.data.lv] or self.config.hp[#self.config.hp]
|
||||||
|
self.baseAttrOriginal[GConst.ATTR_TYPE.atk] = self.config.atk[self.data.lv] or self.config.atk[#self.config.atk]
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroEntity:getHpKey()
|
|
||||||
if self.hpKey == nil then
|
|
||||||
self.hpKey = "hp_" .. self.data.lv
|
|
||||||
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()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user