271 lines
13 KiB
Lua
271 lines
13 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.runesEntity = self.heroEntity:getRunes()
|
|
self.weaponEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON)
|
|
self.hatEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT)
|
|
self.clothesEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES)
|
|
self.beltEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT)
|
|
self.handguardEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD)
|
|
|
|
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_attribute_2")
|
|
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_WEAPON then
|
|
value = (self.weaponEntity and self.weaponEntity:getHp() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
value = value + (self.hatEntity and self.hatEntity:getHp() or 0)
|
|
value = value + (self.clothesEntity and self.clothesEntity:getHp() or 0)
|
|
value = value + (self.beltEntity and self.beltEntity:getHp() or 0)
|
|
value = value + (self.handguardEntity and self.handguardEntity:getHp() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getHp(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示攻击力
|
|
function AttrCell:showAtk()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_1")
|
|
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_WEAPON then
|
|
value = (self.weaponEntity and self.weaponEntity:getAttack() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
value = value + (self.hatEntity and self.hatEntity:getAttack() or 0)
|
|
value = value + (self.clothesEntity and self.clothesEntity:getAttack() or 0)
|
|
value = value + (self.beltEntity and self.beltEntity:getAttack() or 0)
|
|
value = value + (self.handguardEntity and self.handguardEntity:getAttack() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getAttack(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示普攻增伤
|
|
function AttrCell:showNormalHurt()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_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_WEAPON then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
value = value + (self.hatEntity and self.hatEntity:getNormalHurt() or 0)
|
|
value = value + (self.clothesEntity and self.clothesEntity:getNormalHurt() or 0)
|
|
value = value + (self.beltEntity and self.beltEntity:getNormalHurt() or 0)
|
|
value = value + (self.handguardEntity and self.handguardEntity:getNormalHurt() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getNormalHurt(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示技能增伤
|
|
function AttrCell:showSkillHurt()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_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_WEAPON then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
value = value + (self.hatEntity and self.hatEntity:getSkillHurt() or 0)
|
|
value = value + (self.clothesEntity and self.clothesEntity:getSkillHurt() or 0)
|
|
value = value + (self.beltEntity and self.beltEntity:getSkillHurt() or 0)
|
|
value = value + (self.handguardEntity and self.handguardEntity:getSkillHurt() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getSkillHurt(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示暴击率
|
|
function AttrCell:showCrit()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_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_WEAPON then
|
|
value = (self.weaponEntity and self.weaponEntity:getCritPercent() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getCritPercent(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示暴击伤害百分比
|
|
function AttrCell:showCritAtk()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_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_WEAPON then
|
|
value = (self.weaponEntity and self.weaponEntity:getCritHurtPercent() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示普攻增伤百分比
|
|
function AttrCell:showNormalHurtp()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3")
|
|
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_WEAPON then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
-- 套装属性,防具只用计算一次
|
|
value = value + (self.hatEntity and self.hatEntity:getNormalHurtPercent() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getNormalHurtPercent(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示技能增伤百分比
|
|
function AttrCell:showSkillHurtp()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4")
|
|
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_WEAPON then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
-- 套装属性,防具只用计算一次
|
|
value = value + (self.hatEntity and self.hatEntity:getSkillHurtPercent() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getSkillHurtPercent(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
-- 显示治疗效果提升百分比
|
|
function AttrCell:showCured()
|
|
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_7")
|
|
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_WEAPON then
|
|
value = (self.weaponEntity and self.weaponEntity:getHealPercent() or 0)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
|
|
value = value + DataManager.SkinData:getHealPercent(self.heroEntity)
|
|
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_RUNES then
|
|
value = value + (self.runesEntity and self.runesEntity:getAttrValue(self.attrName) or 0)
|
|
end
|
|
|
|
self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
|
|
end
|
|
|
|
return AttrCell |