c1_lua/lua/app/ui/hero/cell/attr_cell.lua
2023-07-20 10:15:42 +08:00

236 lines
10 KiB
Lua

local AttrCell = class("AttrCell", BaseCell)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
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(heroId, nodeType, attrType)
self.heroEntity = DataManager.HeroData:getHeroById(heroId)
self.weaponEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.WEAPON)
self.hatEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT)
self.clothesEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES)
self.beltEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT)
self.handguardEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD)
self.nodeType = nodeType
self.attrName = attrType[self.heroEntity:getMatchType()]
if attrType == GConst.MATCH_HP_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 totalBaseValue = 0
totalBaseValue = totalBaseValue + self.heroEntity:getAttrValue(self.attrName)
totalBaseValue = totalBaseValue + self.weaponEntity:getHp()
totalBaseValue = totalBaseValue + DataManager.EquipData:getTotalArmorHp(self.heroEntity:getCfgId())
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
value = self.heroEntity:getCfgHp(self.heroEntity:getLv())
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getHp()
value = value + totalBaseValue * self.weaponEntity:getHpPercent() // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = DataManager.EquipData:getTotalArmorHp(self.heroEntity:getCfgId())
value = value + totalBaseValue * DataManager.EquipData:getTotalArmorHpPercent(self.heroEntity:getCfgId()) // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示攻击力
function AttrCell:showAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_1")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_ATK))
local totalBaseValue = 0
totalBaseValue = totalBaseValue + self.heroEntity:getAttrValue(self.attrName)
totalBaseValue = totalBaseValue + self.weaponEntity:getHp()
totalBaseValue = totalBaseValue + DataManager.EquipData:getTotalArmorAttack(self.heroEntity:getCfgId())
local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
value = self.heroEntity:getCfgAtk(self.heroEntity:getLv())
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getAttack()
value = value + totalBaseValue * self.weaponEntity:getAtkPercent() // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = DataManager.EquipData:getTotalArmorAttack(self.heroEntity:getCfgId())
value = value + totalBaseValue * DataManager.EquipData:getTotalArmorAttackPercent(self.heroEntity:getCfgId()) // DEFAULT_FACTOR
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示普攻增伤
function AttrCell:showNormalHurt()
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:getAttrValue(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:getNormalHurt()
value = value + self.clothesEntity:getNormalHurt()
value = value + self.beltEntity:getNormalHurt()
value = value + self.handguardEntity:getNormalHurt()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示技能增伤
function AttrCell:showSkillHurt()
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:getAttrValue(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:getSkillHurt()
value = value + self.clothesEntity:getSkillHurt()
value = value + self.beltEntity:getSkillHurt()
value = value + self.handguardEntity:getSkillHurt()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
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:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getCritPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(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:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getCritHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value)
end
-- 显示普攻增伤百分比
function AttrCell:showNormalHurtp()
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:getAttrValue(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:getNormalHurtPercent()
value = value + self.clothesEntity:getNormalHurtPercent()
value = value + self.beltEntity:getNormalHurtPercent()
value = value + self.handguardEntity:getNormalHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
end
-- 显示技能增伤百分比
function AttrCell:showSkillHurtp()
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:getAttrValue(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:getSkillHurtPercent()
value = value + self.clothesEntity:getSkillHurtPercent()
value = value + self.beltEntity:getSkillHurtPercent()
value = value + self.handguardEntity:getSkillHurtPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value // DEFAULT_FACTOR)
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:getAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getHealPercent()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
end
self.txValue:setText(value)
end
return AttrCell