装备界面显示fix

This commit is contained in:
Fang 2023-07-25 19:59:18 +08:00
parent 6f18d573a9
commit 4fe57bcfe8
2 changed files with 48 additions and 40 deletions

View File

@ -89,10 +89,14 @@ function ArmorInfoComp:refreshSelectArmor()
self.txNextLevel:setText("+".. armorNextEntity:getLevel())
-- 基础属性
local diffAtk = (armorNextEntity:getAttack() - armorEntity:getAttack()) // DEFAULT_FACTOR
local diffNormalHurt = (armorNextEntity:getNormalHurt() - armorEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffSkillHurt = (armorNextEntity:getSkillHurt() - armorEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffHp = (armorNextEntity:getHp() - armorEntity:getHp()) // DEFAULT_FACTOR
local curAtk = armorEntity:getAttack()
local curNormalHurt = armorEntity:getNormalHurt()
local curSkillHurt = armorEntity:getSkillHurt()
local curHp = armorEntity:getHp()
local diffBaseAtk = (armorNextEntity:getBaseAttack() - armorEntity:getBaseAttack()) // DEFAULT_FACTOR
local diffBaseNormalHurt = (armorNextEntity:getNormalHurt() - armorEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffBaseSkillHurt = (armorNextEntity:getSkillHurt() - armorEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffBaseHp = (armorNextEntity:getBaseHp() - armorEntity:getBaseHp()) // DEFAULT_FACTOR
local showAttrType = {}
for index, obj in ipairs(self.attr) do
local map = obj:genAllChildren()
@ -101,40 +105,40 @@ function ArmorInfoComp:refreshSelectArmor()
local txNum = map["tx_num"]
obj:setVisible(true)
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) then
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) and (curAtk > 0 or diffBaseAtk > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_5")
txTitle:setText("<color=#FCB501>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3).."</color>")
local numStr = armorEntity:getAttack() // DEFAULT_FACTOR
if diffAtk > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffAtk .. "</color>"
local numStr = curAtk // DEFAULT_FACTOR
if diffBaseAtk > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseAtk .. "</color>"
end
txNum:setText(numStr)
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) then
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) and (curNormalHurt > 0 or diffBaseNormalHurt > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_20")
txTitle:setText("<color=#4CCFFA>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT).."</color>")
local numStr = armorEntity:getNormalHurt() // DEFAULT_FACTOR
if diffNormalHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffNormalHurt .. "</color>"
local numStr = curNormalHurt // DEFAULT_FACTOR
if diffBaseNormalHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseNormalHurt .. "</color>"
end
txNum:setText(numStr)
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) then
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) and (curSkillHurt > 0 or diffBaseSkillHurt > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_21")
txTitle:setText("<color=#EC80FF>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT).."</color>")
local numStr = armorEntity:getSkillHurt() // DEFAULT_FACTOR
if diffSkillHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffSkillHurt .. "</color>"
local numStr = curSkillHurt // DEFAULT_FACTOR
if diffBaseSkillHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseSkillHurt .. "</color>"
end
txNum:setText(numStr)
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and diffHp > 0 then
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and (curHp > 0 or diffBaseHp > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.HP)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_4")
txTitle:setText("<color=#FB6895>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2).."</color>")
local numStr = armorEntity:getHp() // DEFAULT_FACTOR
if diffHp > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffHp .. "</color>"
local numStr = curHp // DEFAULT_FACTOR
if diffBaseHp > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseHp .. "</color>"
end
txNum:setText(numStr)
else

View File

@ -48,10 +48,14 @@ function WeaponInfoComp:refresh()
self.attrContent:setAnchoredPosition(0, 0)
-- 基础属性
local diffAtk = (nextWeaponEntity:getBaseAttack() - self.weaponEntity:getBaseAttack()) // DEFAULT_FACTOR
local diffNormalHurt = (nextWeaponEntity:getNormalHurt() - self.weaponEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffSkillHurt = (nextWeaponEntity:getSkillHurt() - self.weaponEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffHp = (nextWeaponEntity:getBaseHp() - self.weaponEntity:getBaseHp()) // DEFAULT_FACTOR
local curAtk = self.weaponEntity:getAttack()
local curNormalHurt = self.weaponEntity:getNormalHurt()
local curSkillHurt = self.weaponEntity:getSkillHurt()
local curHp = self.weaponEntity:getHp()
local diffBaseAtk = (nextWeaponEntity:getBaseAttack() - self.weaponEntity:getBaseAttack()) // DEFAULT_FACTOR
local diffBaseNormalHurt = (nextWeaponEntity:getNormalHurt() - self.weaponEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffBaseSkillHurt = (nextWeaponEntity:getSkillHurt() - self.weaponEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffBaseHp = (nextWeaponEntity:getBaseHp() - self.weaponEntity:getBaseHp()) // DEFAULT_FACTOR
local showAttrType = {}
for index, obj in ipairs(self.attr) do
local map = obj:genAllChildren()
@ -60,40 +64,40 @@ function WeaponInfoComp:refresh()
local txNum = map["tx_num"]
obj:setVisible(true)
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) then
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) and (curAtk > 0 or diffBaseAtk > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_5")
txTitle:setText("<color=#FCB501>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3).."</color>")
local numStr = self.weaponEntity:getAttack() // DEFAULT_FACTOR
if diffAtk > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffAtk .. "</color>"
local numStr = curAtk // DEFAULT_FACTOR
if diffBaseAtk > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseAtk .. "</color>"
end
txNum:setText(numStr)
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) then
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) and (curNormalHurt > 0 or diffBaseNormalHurt > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_20")
txTitle:setText("<color=#4CCFFA>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_NORMAL_HURT).."</color>")
local numStr = self.weaponEntity:getNormalHurt() // DEFAULT_FACTOR
if diffNormalHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffNormalHurt .. "</color>"
local numStr = curNormalHurt // DEFAULT_FACTOR
if diffBaseNormalHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseNormalHurt .. "</color>"
end
txNum:setText(numStr)
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) then
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) and (curSkillHurt > 0 or diffBaseSkillHurt > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_21")
txTitle:setText("<color=#EC80FF>"..I18N:getGlobalText(I18N.GlobalConst.ATTR_SKILL_HURT).."</color>")
local numStr = self.weaponEntity:getSkillHurt() // DEFAULT_FACTOR
if diffSkillHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffSkillHurt .. "</color>"
local numStr = curSkillHurt // DEFAULT_FACTOR
if diffBaseSkillHurt > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseSkillHurt .. "</color>"
end
txNum:setText(numStr)
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) then
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and (curHp > 0 or diffBaseHp > 0) then
table.insert(showAttrType, GConst.EquipConst.ATTR_TYPE.HP)
imgIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_dec_4")
txTitle:setText("<color=#FB6895>"..I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2).."</color>")
local numStr = self.weaponEntity:getHp() // DEFAULT_FACTOR
if diffHp > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffHp .. "</color>"
local numStr = curHp // DEFAULT_FACTOR
if diffBaseHp > 0 then
numStr = numStr .. "<color=#A2FF29>+" .. diffBaseHp .. "</color>"
end
txNum:setText(numStr)
else