c1_lua/lua/app/ui/hero/cell/attr_cell.lua
2025-10-09 19:56:15 +08:00

203 lines
7.4 KiB
Lua

local AttrCell = class("AttrCell", BaseCell)
function AttrCell:init()
local uiMap = self:getUIMap()
self.imgIcon = uiMap["attr_cell.img_icon"]
self.txDesc = uiMap["attr_cell.tx_desc"]
self.txValue = uiMap["attr_cell.tx_value"]
end
function AttrCell:refresh(heroEntity, nodeType, attrType)
self.heroEntity = heroEntity
self.nodeType = nodeType
self.attrName = attrType[self.heroEntity:getMatchType()]
if attrType == GConst.MATCH_HP_NAME or attrType == GConst.MATCH_HP_FIX_NAME then
self:showHp()
elseif attrType == GConst.MATCH_ATTACK_NAME then
self:showAtk()
elseif attrType == GConst.MATCH_NORMAL_HURT_NAME then
self:showNormalHurt()
elseif attrType == GConst.MATCH_SKILL_HURT_NAME then
self:showSkillHurt()
elseif attrType == GConst.MATCH_CRIT_NAME then
self:showCrit()
elseif attrType == GConst.MATCH_CRIT_TIME_NAME then
self:showCritAtk()
elseif attrType == GConst.MATCH_NORMAL_HURTP_NAME then
self:showNormalHurtp()
elseif attrType == GConst.MATCH_SKILL_HURTP_NAME then
self:showSkillHurtp()
elseif attrType == GConst.MATCH_CURED_NAME then
self:showCured()
end
end
-- 显示生命
function AttrCell:showHp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_1")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_HP))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
if self.heroEntity:isActived() then
value = self.heroEntity:getTotalAttrValue(self.attrName)
else
value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv())
end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
if self.heroEntity:isActived() then
value = self.heroEntity:getCfgHp(self.heroEntity:getLv())
else
value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv())
end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getHp(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示攻击力
function AttrCell:showAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_2")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_ATK))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
if self.heroEntity:isActived() then
value = self.heroEntity:getTotalAttrValue(self.attrName)
else
value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv())
end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
if self.heroEntity:isActived() then
value = self.heroEntity:getCfgAtk(self.heroEntity:getLv())
else
value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv())
end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getAttack(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示普攻增伤
function AttrCell:showNormalHurt()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_3")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getNormalHurt(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示技能增伤
function AttrCell:showSkillHurt()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_4")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getSkillHurt(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示暴击率
function AttrCell:showCrit()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_5")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getCritPercent(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示暴击伤害百分比
function AttrCell:showCritAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_6")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT_TIME))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示普攻增伤百分比
function AttrCell:showNormalHurtp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_7")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURTP))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
-- 特殊处理:显示总属性时,普攻百分比和技能百分比把所有伤害百分比加上
value = value + self.heroEntity:getTotalAttrValue(GConst.MATCH_ALL_HURTP_NAME[self.heroEntity:getMatchType()])
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getNormalHurtPercent(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示技能增伤百分比
function AttrCell:showSkillHurtp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_8")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURTP))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
-- 特殊处理:显示总属性时,普攻百分比和技能百分比把所有伤害百分比加上
value = value + self.heroEntity:getTotalAttrValue(GConst.MATCH_ALL_HURTP_NAME[self.heroEntity:getMatchType()])
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getSkillHurtPercent(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
-- 显示治疗效果提升百分比
function AttrCell:showCured()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_property_9")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CURED))
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = value + DataManager.SkinData:getHealPercent(self.heroEntity)
end
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end
return AttrCell