This commit is contained in:
puxuan 2025-05-25 23:31:37 +08:00
parent 10575642e1
commit e0cc3842a6
7 changed files with 401 additions and 501 deletions

View File

@ -49,23 +49,6 @@ HeroConst.ATTR_SHOW_BASE = {
GConst.MATCH_HP_NAME, -- 生命 GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击 GConst.MATCH_ATTACK_NAME, -- 攻击
} }
-- 武器
HeroConst.ATTR_SHOW_WEAPON = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
GConst.MATCH_CRIT_NAME, -- 暴击率百分比
GConst.MATCH_CRIT_TIME_NAME, -- 暴击伤害百分比
GConst.MATCH_CURED_NAME, -- 治疗效果提升百分比
}
-- 防具
HeroConst.ATTR_SHOW_ARMOR = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
GConst.MATCH_NORMAL_HURT_NAME, -- 普攻增伤
GConst.MATCH_SKILL_HURT_NAME, -- 技能增伤
GConst.MATCH_NORMAL_HURTP_NAME, -- 普攻增伤百分比
GConst.MATCH_SKILL_HURTP_NAME, -- 技能增伤百分比
}
-- 皮肤 -- 皮肤
HeroConst.ATTR_SHOW_SKIN = { HeroConst.ATTR_SHOW_SKIN = {
GConst.MATCH_HP_FIX_NAME, -- 生命 GConst.MATCH_HP_FIX_NAME, -- 生命
@ -78,26 +61,11 @@ HeroConst.ATTR_SHOW_SKIN = {
GConst.MATCH_SKILL_HURTP_NAME, -- 技能增伤百分比 GConst.MATCH_SKILL_HURTP_NAME, -- 技能增伤百分比
GConst.MATCH_CURED_NAME, -- 治疗效果提升百分比 GConst.MATCH_CURED_NAME, -- 治疗效果提升百分比
} }
-- 符文
HeroConst.ATTR_SHOW_RUNES = {
GConst.MATCH_HP_FIX_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
GConst.MATCH_NORMAL_HURT_NAME, -- 普攻增伤
GConst.MATCH_SKILL_HURT_NAME, -- 技能增伤
GConst.MATCH_CRIT_NAME, -- 暴击率百分比
GConst.MATCH_CRIT_TIME_NAME, -- 暴击伤害百分比
GConst.MATCH_NORMAL_HURTP_NAME, -- 普攻增伤百分比
GConst.MATCH_SKILL_HURTP_NAME, -- 技能增伤百分比
GConst.MATCH_CURED_NAME, -- 治疗效果提升百分比
}
-- 需要显示属性的模块 -- 需要显示属性的模块
HeroConst.SHOW_NODE = { HeroConst.SHOW_NODE = {
HeroConst.ATTR_SHOW_TOTAL, HeroConst.ATTR_SHOW_TOTAL,
HeroConst.ATTR_SHOW_BASE, HeroConst.ATTR_SHOW_BASE,
HeroConst.ATTR_SHOW_WEAPON,
HeroConst.ATTR_SHOW_ARMOR,
HeroConst.ATTR_SHOW_RUNES,
HeroConst.ATTR_SHOW_SKIN, HeroConst.ATTR_SHOW_SKIN,
} }

View File

@ -149,6 +149,10 @@ function RewardCell:_refreshItem(info, count)
self:showLight(false) self:showLight(false)
end end
function RewardCell:setIconSprite(atlas, res)
self.icon:setSprite(atlas, res)
end
function RewardCell:setNumTx(str) function RewardCell:setNumTx(str)
self.numTx:setText(str) self.numTx:setText(str)
end end

View File

@ -1,271 +1,203 @@
local AttrCell = class("AttrCell", BaseCell) local AttrCell = class("AttrCell", BaseCell)
function AttrCell:init() function AttrCell:init()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
self.imgIcon = uiMap["attr_cell.img_icon"] self.imgIcon = uiMap["attr_cell.img_icon"]
self.txDesc = uiMap["attr_cell.tx_desc"] self.txDesc = uiMap["attr_cell.tx_desc"]
self.txValue = uiMap["attr_cell.tx_value"] self.txValue = uiMap["attr_cell.tx_value"]
end end
function AttrCell:refresh(heroEntity, nodeType, attrType) function AttrCell:refresh(heroEntity, nodeType, attrType)
self.heroEntity = heroEntity self.heroEntity = heroEntity
self.runesEntity = self.heroEntity:getRunes() self.nodeType = nodeType
self.weaponEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON) self.attrName = attrType[self.heroEntity:getMatchType()]
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 if attrType == GConst.MATCH_HP_NAME or attrType == GConst.MATCH_HP_FIX_NAME then
self.attrName = attrType[self.heroEntity:getMatchType()] self:showHp()
elseif attrType == GConst.MATCH_ATTACK_NAME then
if attrType == GConst.MATCH_HP_NAME or attrType == GConst.MATCH_HP_FIX_NAME then self:showAtk()
self:showHp() elseif attrType == GConst.MATCH_NORMAL_HURT_NAME then
elseif attrType == GConst.MATCH_ATTACK_NAME then self:showNormalHurt()
self:showAtk() elseif attrType == GConst.MATCH_SKILL_HURT_NAME then
elseif attrType == GConst.MATCH_NORMAL_HURT_NAME then self:showSkillHurt()
self:showNormalHurt() elseif attrType == GConst.MATCH_CRIT_NAME then
elseif attrType == GConst.MATCH_SKILL_HURT_NAME then self:showCrit()
self:showSkillHurt() elseif attrType == GConst.MATCH_CRIT_TIME_NAME then
elseif attrType == GConst.MATCH_CRIT_NAME then self:showCritAtk()
self:showCrit() elseif attrType == GConst.MATCH_NORMAL_HURTP_NAME then
elseif attrType == GConst.MATCH_CRIT_TIME_NAME then self:showNormalHurtp()
self:showCritAtk() elseif attrType == GConst.MATCH_SKILL_HURTP_NAME then
elseif attrType == GConst.MATCH_NORMAL_HURTP_NAME then self:showSkillHurtp()
self:showNormalHurtp() elseif attrType == GConst.MATCH_CURED_NAME then
elseif attrType == GConst.MATCH_SKILL_HURTP_NAME then self:showCured()
self:showSkillHurtp() end
elseif attrType == GConst.MATCH_CURED_NAME then
self:showCured()
end
end end
-- 显示生命 -- 显示生命
function AttrCell:showHp() function AttrCell:showHp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_2") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_2")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_HP)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_HP))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
if self.heroEntity:isActived() then if self.heroEntity:isActived() then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
else else
value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv())
end end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
if self.heroEntity:isActived() then if self.heroEntity:isActived() then
value = self.heroEntity:getCfgHp(self.heroEntity:getLv()) value = self.heroEntity:getCfgHp(self.heroEntity:getLv())
else else
value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) value = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv())
end end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = (self.weaponEntity and self.weaponEntity:getHp() or 0) value = value + DataManager.SkinData:getHp(self.heroEntity)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示攻击力 -- 显示攻击力
function AttrCell:showAtk() function AttrCell:showAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_1") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_1")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_ATK)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_ATK))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
if self.heroEntity:isActived() then if self.heroEntity:isActived() then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
else else
value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv())
end end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then
if self.heroEntity:isActived() then if self.heroEntity:isActived() then
value = self.heroEntity:getCfgAtk(self.heroEntity:getLv()) value = self.heroEntity:getCfgAtk(self.heroEntity:getLv())
else else
value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) value = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv())
end end
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
value = (self.weaponEntity and self.weaponEntity:getAttack() or 0) value = value + DataManager.SkinData:getAttack(self.heroEntity)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示普攻增伤 -- 显示普攻增伤
function AttrCell:showNormalHurt() function AttrCell:showNormalHurt()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then 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_SKIN then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then value = value + DataManager.SkinData:getNormalHurt(self.heroEntity)
value = value + (self.hatEntity and self.hatEntity:getNormalHurt() or 0) end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示技能增伤 -- 显示技能增伤
function AttrCell:showSkillHurt() function AttrCell:showSkillHurt()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then 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_SKIN then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then value = value + DataManager.SkinData:getSkillHurt(self.heroEntity)
value = value + (self.hatEntity and self.hatEntity:getSkillHurt() or 0) end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示暴击率 -- 显示暴击率
function AttrCell:showCrit() function AttrCell:showCrit()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_5") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_5")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then 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_SKIN then
value = (self.weaponEntity and self.weaponEntity:getCritPercent() or 0) value = value + DataManager.SkinData:getCritPercent(self.heroEntity)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示暴击伤害百分比 -- 显示暴击伤害百分比
function AttrCell:showCritAtk() function AttrCell:showCritAtk()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_6") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_6")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT_TIME)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CRIT_TIME))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then 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_SKIN then
value = (self.weaponEntity and self.weaponEntity:getCritHurtPercent() or 0) value = value + DataManager.SkinData:getCritHurtPercent(self.heroEntity)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示普攻增伤百分比 -- 显示普攻增伤百分比
function AttrCell:showNormalHurtp() function AttrCell:showNormalHurtp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_3")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURTP)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURTP))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
-- 特殊处理:显示总属性时,普攻百分比和技能百分比把所有伤害百分比加上 -- 特殊处理:显示总属性时,普攻百分比和技能百分比把所有伤害百分比加上
value = value + self.heroEntity:getTotalAttrValue(GConst.MATCH_ALL_HURTP_NAME[self.heroEntity:getMatchType()]) 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_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then value = value + DataManager.SkinData:getNormalHurtPercent(self.heroEntity)
-- 套装属性,防具只用计算一次 end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示技能增伤百分比 -- 显示技能增伤百分比
function AttrCell:showSkillHurtp() function AttrCell:showSkillHurtp()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_4")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURTP)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURTP))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
-- 特殊处理:显示总属性时,普攻百分比和技能百分比把所有伤害百分比加上 -- 特殊处理:显示总属性时,普攻百分比和技能百分比把所有伤害百分比加上
value = value + self.heroEntity:getTotalAttrValue(GConst.MATCH_ALL_HURTP_NAME[self.heroEntity:getMatchType()]) 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_BASE then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_SKIN then
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then value = value + DataManager.SkinData:getSkillHurtPercent(self.heroEntity)
-- 套装属性,防具只用计算一次 end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
-- 显示治疗效果提升百分比 -- 显示治疗效果提升百分比
function AttrCell:showCured() function AttrCell:showCured()
self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_7") self.imgIcon:setSprite(GConst.ATLAS_PATH.HERO, "hero_attribute_7")
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CURED)) self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.ATTR_CURED))
local value = 0 local value = 0
if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then if self.nodeType == GConst.HeroConst.ATTR_SHOW_TOTAL then
value = self.heroEntity:getTotalAttrValue(self.attrName) value = self.heroEntity:getTotalAttrValue(self.attrName)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_BASE then 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_SKIN then
value = (self.weaponEntity and self.weaponEntity:getHealPercent() or 0) value = value + DataManager.SkinData:getHealPercent(self.heroEntity)
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then end
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)) self.txValue:setText(GFunc.getAttrShowValue(self.attrName, value))
end end
return AttrCell return AttrCell

View File

@ -3,54 +3,44 @@ local ATTR_CELL = "app/ui/hero/cell/attr_cell"
local ATTR_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_cell.prefab" local ATTR_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_cell.prefab"
function AttrNodeCell:init() function AttrNodeCell:init()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
self.txTitle = uiMap["total_node.tx_title"] self.txTitle = uiMap["total_node.tx_title"]
self.itemsRoot = uiMap["total_node.items"] self.itemsRoot = uiMap["total_node.items"]
end end
function AttrNodeCell:refresh(heroEntity, node) function AttrNodeCell:refresh(heroEntity, node)
if node == GConst.HeroConst.ATTR_SHOW_TOTAL then if node == GConst.HeroConst.ATTR_SHOW_TOTAL then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_13)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_13))
elseif node == GConst.HeroConst.ATTR_SHOW_BASE then elseif node == GConst.HeroConst.ATTR_SHOW_BASE then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_14)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_14))
elseif node == GConst.HeroConst.ATTR_SHOW_WEAPON then elseif node == GConst.HeroConst.ATTR_SHOW_SKIN then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_15)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_17))
elseif node == GConst.HeroConst.ATTR_SHOW_ARMOR then end
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
elseif node == GConst.HeroConst.ATTR_SHOW_SKIN then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_17))
elseif node == GConst.HeroConst.ATTR_SHOW_RUNES then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.RUNES_DESC_22))
end
self.attrCount = 0 self.attrCount = 0
for index, attr in ipairs(node) do for index, attr in ipairs(node) do
if self:isShowAttr(heroEntity, node, attr) then if self:isShowAttr(heroEntity, node, attr) then
self.attrCount = self.attrCount + 1 self.attrCount = self.attrCount + 1
CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell) CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell)
cell:refresh(heroEntity, node, attr) cell:refresh(heroEntity, node, attr)
end) end)
end end
end end
end end
-- 是否显示属性项 -- 是否显示属性项
function AttrNodeCell:isShowAttr(heroEntity, node, attr) function AttrNodeCell:isShowAttr(heroEntity, node, attr)
if node == GConst.HeroConst.ATTR_SHOW_SKIN then if node == GConst.HeroConst.ATTR_SHOW_SKIN then
return DataManager.SkinData:hasAttr(heroEntity, attr[heroEntity:getMatchType()]) return DataManager.SkinData:hasAttr(heroEntity, attr[heroEntity:getMatchType()])
end end
if node == GConst.HeroConst.ATTR_SHOW_RUNES then
local runesEntity = heroEntity:getRunes()
return runesEntity and runesEntity:hasAttr(attr[heroEntity:getMatchType()]) or false
end
return true return true
end end
--获取节点显示属性个数 --获取节点显示属性个数
function AttrNodeCell:getShowAttrCount() function AttrNodeCell:getShowAttrCount()
return self.attrCount return self.attrCount
end end
return AttrNodeCell return AttrNodeCell

View File

@ -7,11 +7,11 @@ local ATTR_CELL_HEIGHT = 80
local ATTR_CELL_SPACING_Y = 8 local ATTR_CELL_SPACING_Y = 8
function HeroAttrUI:isFullScreen() function HeroAttrUI:isFullScreen()
return false return false
end end
function HeroAttrUI:getPrefabPath() function HeroAttrUI:getPrefabPath()
return "assets/prefabs/ui/hero/hero_attr_ui.prefab" return "assets/prefabs/ui/hero/hero_attr_ui.prefab"
end end
function HeroAttrUI:onPressBackspace() function HeroAttrUI:onPressBackspace()
@ -19,58 +19,53 @@ function HeroAttrUI:onPressBackspace()
end end
function HeroAttrUI:onClose() function HeroAttrUI:onClose()
self.rootNodes:removeAllChildren() self.rootNodes:removeAllChildren()
end end
function HeroAttrUI:ctor(parmas) function HeroAttrUI:ctor(parmas)
self.heroEntity = parmas.heroEntity self.heroEntity = parmas.heroEntity
end end
function HeroAttrUI:onLoadRootComplete() function HeroAttrUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren() local uiMap = self.root:genAllChildren()
self.txTitle = uiMap["hero_attr_ui.content.tx_title"] self.txTitle = uiMap["hero_attr_ui.content.tx_title"]
self.btnClose = uiMap["hero_attr_ui.content.btn_close"] self.btnClose = uiMap["hero_attr_ui.content.btn_close"]
self.rootNodes = uiMap["hero_attr_ui.content.ScrollView.Viewport.Content"] self.rootNodes = uiMap["hero_attr_ui.content.ScrollView.Viewport.Content"]
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_18)) self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_18))
self.btnClose:addClickListener(function() self.btnClose:addClickListener(function()
self:closeUI() self:closeUI()
end) end)
end end
function HeroAttrUI:onRefresh() function HeroAttrUI:onRefresh()
local totalHeight = 0 local totalHeight = 0
for index, node in ipairs(GConst.HeroConst.SHOW_NODE) do for index, node in ipairs(GConst.HeroConst.SHOW_NODE) do
-- 有皮肤属性时才显示皮肤 -- 有皮肤属性时才显示皮肤
if self:isShowAttr(node) then if self:isShowAttr(node) then
CellManager:loadCellAsync(ATTR_NODE_CELL_PATH, ATTR_NODE_CELL, self.rootNodes, function(cell) CellManager:loadCellAsync(ATTR_NODE_CELL_PATH, ATTR_NODE_CELL, self.rootNodes, function(cell)
cell:refresh(self.heroEntity, node) cell:refresh(self.heroEntity, node)
local attrCount = cell:getShowAttrCount() local attrCount = cell:getShowAttrCount()
local nodeHeight = math.ceil(attrCount / 2) * ATTR_CELL_HEIGHT + (math.ceil(attrCount / 2) - 1) * ATTR_CELL_SPACING_Y + ATTR_CELLS_PADDING local nodeHeight = math.ceil(attrCount / 2) * ATTR_CELL_HEIGHT + (math.ceil(attrCount / 2) - 1) * ATTR_CELL_SPACING_Y + ATTR_CELLS_PADDING
cell.baseObject:setLocalPositionY(-totalHeight) cell.baseObject:setLocalPositionY(-totalHeight)
cell.baseObject:setSizeDeltaY(nodeHeight) cell.baseObject:setSizeDeltaY(nodeHeight)
totalHeight = totalHeight + nodeHeight totalHeight = totalHeight + nodeHeight
self.rootNodes:setSizeDeltaY(totalHeight) self.rootNodes:setSizeDeltaY(totalHeight)
end) end)
end end
end end
self.rootNodes:setAnchoredPositionY(0) self.rootNodes:setAnchoredPositionY(0)
end end
-- 是否显示属性块 -- 是否显示属性块
function HeroAttrUI:isShowAttr(node) function HeroAttrUI:isShowAttr(node)
if node == GConst.HeroConst.ATTR_SHOW_SKIN then if node == GConst.HeroConst.ATTR_SHOW_SKIN then
return #DataManager.SkinData:getOwnAllAttr(self.heroEntity) > 0 return #DataManager.SkinData:getOwnAllAttr(self.heroEntity) > 0
end end
if node == GConst.HeroConst.ATTR_SHOW_RUNES then return true
local runesEntity = self.heroEntity:getRunes()
return runesEntity and runesEntity:getAllAttr() and #runesEntity:getAllAttr() > 0 or false
end
return true
end end
return HeroAttrUI return HeroAttrUI

View File

@ -58,10 +58,14 @@ function HeroDetailUI:onLoadRootComplete()
self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)) self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)) self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
self.txStar1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1)) -- self.txStar1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
self.txStar2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1)) -- self.txStar2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2)) -- self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2)) -- self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
self.txStar1:setText("升星")
self.txStar2:setText("升星")
self.txSkin1:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
self.txSkin2:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN))
if not DataManager.HeroData:isStarOpen() then if not DataManager.HeroData:isStarOpen() then
self.lockStar:setVisible(true) self.lockStar:setVisible(true)
GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5) GFunc.centerImgAndTx(self.lockStar, self.txStar1, 5)

View File

@ -6,227 +6,234 @@ local SIZE_DELTA_Y_HERO = 942
local SIZE_DELTA_Y_LOOK = 802 local SIZE_DELTA_Y_LOOK = 802
function HeroInfoComp:init() function HeroInfoComp:init()
local uiMap = self:getUIMap() local uiMap = self:getUIMap()
self.slider = uiMap["hero_detail_ui.bg.fragment_bg.slider"] self.slider = uiMap["hero_info.fragment_bg.slider"]
self.imgElement = uiMap["hero_detail_ui.bg.hero_element"] self.imgElement = uiMap["hero_info.hero_element"]
self.imgSkill = uiMap["hero_detail_ui.bg.skill_node.skill_icon"] self.imgSkill = uiMap["hero_info.skill_node.skill_icon"]
self.imgFragment = uiMap["hero_detail_ui.bg.fragment_bg.fragment_icon"] self.imgFragment = uiMap["hero_info.fragment_bg.fragment_icon"]
self.btnUp = uiMap["hero_detail_ui.bg.up_btn"] self.btnUp = uiMap["hero_info.up.up_btn"]
self.imgUpIcon = uiMap["hero_detail_ui.bg.up_btn.icon"] self.txUpdesc = uiMap["hero_info.up.up_btn.text"]
self.txUpdesc = uiMap["hero_detail_ui.bg.up_btn.desc"] self.btnUp5 = uiMap["hero_info.up.up_5_btn"]
self.txUpNum = uiMap["hero_detail_ui.bg.up_btn.num"] self.txUpdesc5 = uiMap["hero_info.up.up_5_btn.text"]
self.txLv = uiMap["hero_detail_ui.bg.lv_desc"] self.txLv = uiMap["hero_info.lv_desc"]
self.txElement = uiMap["hero_detail_ui.bg.element_desc"] self.txElement = uiMap["hero_info.element_bg.element_desc"]
self.txSkill = uiMap["hero_detail_ui.bg.skill_desc"] self.txSkill = uiMap["hero_info.skill_desc"]
self.btnSkillDesc = uiMap["hero_info.skill_desc.btn_skill_desc"] self.btnSkillDesc = uiMap["hero_info.skill_desc.btn_skill_desc"]
self.txFragmentNum = uiMap["hero_detail_ui.bg.fragment_bg.fragment_num"] self.txFragmentNum = uiMap["hero_info.fragment_bg.fragment_num"]
self.txHpName = uiMap["hero_detail_ui.bg.hp_name"] self.txHpName = uiMap["hero_info.bg_6.hp_name"]
self.txAtkName = uiMap["hero_detail_ui.bg.atk_name"] self.txAtkName = uiMap["hero_info.atk_name"]
self.txHp = uiMap["hero_detail_ui.bg.hp"] self.txHp = uiMap["hero_info.bg_6.hp"]
self.txAtk = uiMap["hero_detail_ui.bg.atk"] self.txAtk = uiMap["hero_info.atk"]
self.bgFragment = uiMap["hero_detail_ui.bg.fragment_bg"] self.bgFragment = uiMap["hero_info.fragment_bg"]
self.spineObjSkill = uiMap["hero_detail_ui.bg.ui_spine_obj_skill"] self.spineObjSkill = uiMap["hero_info.ui_spine_obj_skill"]
self.spineObjLv = uiMap["hero_detail_ui.bg.ui_spine_obj_lv"] self.spineObjLv = uiMap["hero_info.ui_spine_obj_lv"]
self.spineObj = uiMap["hero_detail_ui.bg.ui_spine_obj"] self.spineObj = uiMap["hero_info.ui_spine_obj"]
self.spineObjAvatar = uiMap["hero_detail_ui.bg.ui_spine_obj_avatar"] self.spineObjAvatar = uiMap["hero_info.ui_spine_obj_avatar"]
self.upgrade = uiMap["hero_info.up"] self.upgrade = uiMap["hero_info.up"]
self.bgElement = uiMap["hero_detail_ui.bg.element_bg"] self.bgElement = uiMap["hero_info.element_bg"]
self.btnAttr = uiMap["hero_info.bg_6.btn_attr"] self.btnAttr = uiMap["hero_info.bg_6.btn_attr"]
self.fragmentNode = uiMap["hero_detail_ui.bg.fragment_bg"] self.fragmentNode = uiMap["hero_info.fragment_bg"]
self.btnSkin = uiMap["hero_info.up.btn_skin"]
self.txSkin = uiMap["hero_info.up.btn_skin.tx_skin"]
self.skill = {} self.skill = {}
self.skillIcon = {} self.skillIcon = {}
self.skillDesc = {} self.skillDesc = {}
for i = 1, 4 do for i = 1, 4 do
self.skill[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i] self.skill[i] = uiMap["hero_info.skill_up_" .. i]
self.skillIcon[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".icon"] self.skillIcon[i] = uiMap["hero_info.skill_up_" .. i .. ".icon"]
self.skillDesc[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"] self.skillDesc[i] = uiMap["hero_info.skill_up_" .. i .. ".desc"]
end end
self.spineObjSkill:setVisible(false) self.costCells = {}
self.spineObjLv:setVisible(false) for i = 1, 2 do
self.spineObj:setVisible(false) self.costCells[i] = uiMap["hero_info.up.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
self.txSkin:setText(I18N:getGlobalText(I18N.GlobalConst.SKIN)) end
self.btnSkin:setActive(DataManager.SkinData:isOpen())
self.btnSkin:addClickListener(function() self.spineObjSkill:setVisible(false)
ModuleManager.HeroManager:showHeroSkinUI(self.heroEntity:getCfgId()) self.spineObjLv:setVisible(false)
end) self.spineObj:setVisible(false)
self.btnUp:addClickListener(function() self.txUpdesc:setText("升1级")
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity) self.txUpdesc5:setText("升5级")
end)
self.btnSkillDesc:addClickListener(function() self.btnUp:addClickListener(function()
local cfg = ConfigManager:getConfig("skill")[self.heroEntity:getBaseSkill()] ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity)
if cfg.buff_id and #cfg.buff_id > 0 then end)
ModuleManager.TipsManager:showSkillTips(self.btnSkillDesc, cfg.buff_id) self.btnSkillDesc:addClickListener(function()
end local cfg = ConfigManager:getConfig("skill")[self.heroEntity:getBaseSkill()]
end) if cfg.buff_id and #cfg.buff_id > 0 then
self.btnAttr:addClickListener(function() ModuleManager.TipsManager:showSkillTips(self.btnSkillDesc, cfg.buff_id)
UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity}) end
end) end)
self:bind(DataManager.BagData.ItemData, "dirty", function() self.btnAttr:addClickListener(function()
self:refresh() UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity})
end) end)
self:bind(DataManager.BagData.ItemData, "dirty", function()
self:refresh()
end)
end end
function HeroInfoComp:setHeroData(heroEntity, onlyLook) function HeroInfoComp:setHeroData(heroEntity, onlyLook)
self.curLevel = heroEntity:getLv() self.curLevel = heroEntity:getLv()
self.heroEntity = heroEntity self.heroEntity = heroEntity
self.onlyLook = onlyLook self.onlyLook = onlyLook
self:bind(self.heroEntity, "isDirty", function() self:bind(self.heroEntity, "isDirty", function()
self:refresh(true) self:refresh(true)
end) end)
end end
function HeroInfoComp:refresh(checkLevel) function HeroInfoComp:refresh(checkLevel)
local isLvChange = checkLevel and self.curLevel ~= self.heroEntity:getLv() local isLvChange = checkLevel and self.curLevel ~= self.heroEntity:getLv()
self.txLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv())) self.txLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv()))
local lvTxW = self.txLv:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth local lvTxW = self.txLv:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
self.txLv:setSizeDeltaX(lvTxW) self.txLv:setSizeDeltaX(lvTxW)
self.spineObjAvatar:getSkeletonGraphic().enabled = false self.spineObjAvatar:getSkeletonGraphic().enabled = false
self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function() self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function()
self.spineObjAvatar:getSkeletonGraphic().enabled = true self.spineObjAvatar:getSkeletonGraphic().enabled = true
self.spineObjAvatar:playAnim("idle", true, true, true) self.spineObjAvatar:playAnim("idle", true, true, true)
end, true) end, true)
self.txElement:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType())) self.txElement:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType()))
local elementTxRectWidth = self.txElement:getRectWidth() local elementTxRectWidth = self.txElement:getRectWidth()
local elementTxWidth = self.txElement:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth local elementTxWidth = self.txElement:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
if elementTxWidth > elementTxRectWidth then if elementTxWidth > elementTxRectWidth then
self.bgElement:setSizeDeltaX(52 + elementTxWidth) self.bgElement:setSizeDeltaX(52 + elementTxWidth)
else else
self.bgElement:setSizeDeltaX(52 + elementTxRectWidth) self.bgElement:setSizeDeltaX(52 + elementTxRectWidth)
end end
self.txSkill:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill())) self.txSkill:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill()))
self.txHpName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2)) self.txHpName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
self.txAtkName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3)) self.txAtkName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3))
self.imgSkill:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BIG, ModuleManager.HeroManager:getSkillIcon(self.heroEntity:getBaseSkill())) self.imgSkill:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BIG, ModuleManager.HeroManager:getSkillIcon(self.heroEntity:getBaseSkill()))
self.imgElement:setSprite(GConst.ATLAS_PATH.HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType())) self.imgElement:setSprite(GConst.ATLAS_PATH.HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType()))
local materials = self.heroEntity:getLvUpMaterials() or {} local materials = self.heroEntity:getLvUpMaterials() or {}
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId()) local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId())
local needFragmentCount = materials[1] or 1 local needFragmentCount = materials[1] or 1
self.txFragmentNum:setText(fragmentCount .. "/" .. needFragmentCount) self.txFragmentNum:setText(fragmentCount .. "/" .. needFragmentCount)
if fragmentCount >= needFragmentCount then if fragmentCount >= needFragmentCount then
self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_1", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)) self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_1", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
else else
self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_2", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)) self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_2", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
end end
self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
local skillList = self.heroEntity:getRogueSkillList() local skillList = self.heroEntity:getRogueSkillList()
local lv = self.heroEntity:getLv() local lv = self.heroEntity:getLv()
for i = 1, 4 do for i = 1, 4 do
local skillInfo = skillList[i] local skillInfo = skillList[i]
if skillInfo then if skillInfo then
local skillUnlcokLv = skillInfo[1] local skillUnlcokLv = skillInfo[1]
local skillId = skillInfo[2] local skillId = skillInfo[2]
local skillBg = self.skill[i] local skillBg = self.skill[i]
local skillIcon = self.skillIcon[i] local skillIcon = self.skillIcon[i]
local skillLv = self.skillDesc[i] local skillLv = self.skillDesc[i]
local nextLvUp = self.heroEntity:getNextRougeLvUp(i) local nextLvUp = self.heroEntity:getNextRougeLvUp(i)
skillBg:addClickListener(function() skillBg:addClickListener(function()
local cfg = ConfigManager:getConfig("skill_rogue")[skillId] local cfg = ConfigManager:getConfig("skill_rogue")[skillId]
ModuleManager.TipsManager:showSkillTips(skillIcon, cfg.buff_id, skillId) ModuleManager.TipsManager:showSkillTips(skillIcon, cfg.buff_id, skillId)
end) end)
skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId)) skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId))
skillBg:setTouchEnable(true) skillBg:setTouchEnable(true)
if skillUnlcokLv > lv then if skillUnlcokLv > lv then
-- skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0)) -- skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0))
skillLv:setText(skillUnlcokLv .. "级解锁") skillLv:setText(skillUnlcokLv .. "级解锁")
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, "frame_0") skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, "frame_0")
else else
if nextLvUp then if nextLvUp then
skillLv:setText(nextLvUp .. "提升") skillLv:setText(nextLvUp .. "提升")
else else
skillLv:setText(GConst.EMPTY_STRING) skillLv:setText(GConst.EMPTY_STRING)
end end
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId, true)) skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId, true))
-- if i == activeCount and isLvChange and self.heroEntity:getLv() == skillLvs[i] then -- if i == activeCount and isLvChange and self.heroEntity:getLv() == skillLvs[i] then
-- local x, y = skillBg:fastGetAnchoredPosition() -- local x, y = skillBg:fastGetAnchoredPosition()
-- self.spineObjSkill:setAnchoredPosition(x, y) -- self.spineObjSkill:setAnchoredPosition(x, y)
-- self.spineObjSkill:setVisible(true) -- self.spineObjSkill:setVisible(true)
-- self.spineObjSkill:playAnim("idle", false, true) -- self.spineObjSkill:playAnim("idle", false, true)
-- end -- end
end end
end end
end end
self.bgFragment:setVisible(not self.heroEntity:isMaxLv()) self.bgFragment:setVisible(not self.heroEntity:isMaxLv())
local canLvUp = self.heroEntity:canLvUp() local canLvUp = self.heroEntity:canLvUp()
self.imgFragment:setVisible(not canLvUp) self.imgFragment:setVisible(not canLvUp)
local lv = self.heroEntity:getLv() local lv = self.heroEntity:getLv()
local str local str
local hpStr local hpStr
local atkStr local atkStr
if self.heroEntity:isActived() then if self.heroEntity:isActived() then
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4) str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)
local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR
local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR
local addHp = (self.heroEntity:getCfgHp(lv + 1) - self.heroEntity:getCfgHp()) // DEFAULT_FACTOR local addHp = (self.heroEntity:getCfgHp(lv + 1) - self.heroEntity:getCfgHp()) // DEFAULT_FACTOR
local addAtk = (self.heroEntity:getCfgAtk(lv + 1) - self.heroEntity:getCfgAtk()) // DEFAULT_FACTOR local addAtk = (self.heroEntity:getCfgAtk(lv + 1) - self.heroEntity:getCfgAtk()) // DEFAULT_FACTOR
if addHp <= 0 then if addHp <= 0 then
hpStr = curHp hpStr = curHp
else else
hpStr = curHp .. "<color=#A2FF29>+" .. addHp .. "</color>" hpStr = curHp .. "<color=#A2FF29>+" .. addHp .. "</color>"
end end
if addAtk <= 0 then if addAtk <= 0 then
atkStr = curAtk atkStr = curAtk
else else
atkStr = curAtk .. "<color=#A2FF29>+" .. addAtk .. "</color>" atkStr = curAtk .. "<color=#A2FF29>+" .. addAtk .. "</color>"
end end
else else
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5) str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5)
hpStr = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR hpStr = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
atkStr = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR atkStr = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
end end
local costId = self.heroEntity:getLvUpCostId() local costs = {}
self.imgUpIcon:setSprite(GFunc.getIconRes(costId)) costs[1] = {id = 1, num = materials[1], type = 1}
self.txUpdesc:setText(str) costs[2] = {id = self.heroEntity:getLvUpCostId(), num = materials[2], type = 1}
self.txUpNum:setText(materials[2]) for i,v in ipairs(self.costCells) do
self.txHp:setText(hpStr) v:refreshByConfig(costs[i])
self.txAtk:setText(atkStr) end
if canLvUp then self.costCells[1]:setIconSprite(GConst.ATLAS_PATH.HERO, self.heroEntity:getIcon())
self.btnUp:addRedPoint(120, 50, 0.6) -- local costId = self.heroEntity:getLvUpCostId()
else -- self.imgUpIcon:setSprite(GFunc.getIconRes(costId))
self.btnUp:removeRedPoint() -- self.txUpdesc:setText(str)
end -- self.txUpNum:setText(materials[2])
self.txHp:setText(hpStr)
self.txAtk:setText(atkStr)
if canLvUp then
self.btnUp:addRedPoint(70, 40, 0.6)
else
self.btnUp:removeRedPoint()
end
self.spineObjLv:setVisible(canLvUp) self.spineObjLv:setVisible(canLvUp)
if canLvUp then if canLvUp then
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1]) self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
self.spineObjLv:playAnim("animation", true, false) self.spineObjLv:playAnim("animation", true, false)
else else
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2]) self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end end
self.btnUp:setTouchEnable(true) self.btnUp:setTouchEnable(true)
self.btnUp:setActive(not self.heroEntity:isMaxLv()) self.btnUp:setActive(not self.heroEntity:isMaxLv())
if isLvChange then if isLvChange then
self.spineObj:setVisible(true) self.spineObj:setVisible(true)
self.spineObj:playAnim("idle", false, true) self.spineObj:playAnim("idle", false, true)
end end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮 if self.onlyLook then -- 仅查看的不显示升级和激活按钮
self.upgrade:setVisible(false) self.upgrade:setVisible(false)
self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_LOOK) self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
self.fragmentNode:setVisible(false) self.fragmentNode:setVisible(false)
self.spineObjLv:setVisible(false) self.spineObjLv:setVisible(false)
self.txLv:setAnchoredPositionX(lvTxW / 2) self.txLv:setAnchoredPositionX(lvTxW / 2)
else else
self.upgrade:setVisible(true) self.upgrade:setVisible(true)
self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_HERO) self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_HERO)
self.txLv:setAnchoredPositionX(-44) self.txLv:setAnchoredPositionX(-44)
self.fragmentNode:setVisible(true) self.fragmentNode:setVisible(true)
end end
end end
return HeroInfoComp return HeroInfoComp