Merge branch 'dev_20230725' into dungeon

# Conflicts:
#	lua/app/common/bi_report.lua
#	lua/app/common/module_manager.lua
#	lua/app/config/localization/localization_global_const.lua
#	lua/app/config/strings/cn/global.lua
This commit is contained in:
xiekaidong 2023-07-20 19:45:54 +08:00
commit 100e125c19
36 changed files with 1951 additions and 279 deletions

View File

@ -129,6 +129,7 @@ BIReport.ITEM_GET_TYPE = {
DUNGEON_ARMOR_END = "DungeonArmorEnd",
DUNGEON_ARMOR_SWEEP = "DungeonArmorSweep",
DUNGEON_ARMOR_STAR_REWARD = "DungeonArmorStarReward",
EQUIP_UPGRADE = "EquipUpgrade",
}
BIReport.ADS_CLICK_TYPE = {

View File

@ -14,6 +14,7 @@ function DataManager:init()
self:initManager("CollectionData", "app/userdata/collection/collection_data")
self:initManager("HeroData", "app/userdata/hero/hero_data")
self:initManager("BagData", "app/userdata/bag/bag_data")
self:initManager("EquipData", "app/userdata/equip/equip_data")
self:initManager("BattleData", "app/userdata/battle/battle_data")
self:initManager("BattlePVPData", "app/userdata/battle/battle_pvp_data")
self:initManager("FormationData", "app/userdata/formation/formation_data")
@ -98,6 +99,7 @@ function DataManager:clear()
self.CollectionData:clear()
self.HeroData:clear()
self.BagData:clear()
self.EquipData:clear()
self.FormationData:clear()
self.ActivityData:clear()
self.MailData:clear()
@ -135,6 +137,8 @@ function DataManager:initWithServerData(data)
self.DailyChallengeData:init(data.chapter_daily_challenge)
self.DungeonData:initDungeonGold(data.chapter_gold_challenge)
self.DungeonData:initDungeonShards(data.chapter_shards_challenge)
self.EquipData:init(data.heroes_equips)
-- HeroData要在EquipData之后初始化依赖装备的属性数据
self.HeroData:init(data.bag.heroes)
self.BagData:init(data.bag)
self.FormationData:init(data.fight_info)

View File

@ -48,6 +48,7 @@ EventManager.CUSTOM_EVENT = {
ARENA_RANK_SUCCESS = "ARENA_RANK_SUCCESS",-- 排行榜获取成功
ARENA_AD_BOX_SUCCESS = "ARENA_AD_BOX_SUCCESS",-- ad宝箱获取成功
COLLECTION_CLICK_GET_POINT = "COLLECTION_CLICK_GET_POINT",
EQUIP_UPGRADE_SUCCESS = "EQUIP_UPGRADE_SUCCESS",
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
DUNGEON_ARMOR_TO_TARGET_ID = "DUNGEON_ARMOR_TO_TARGET_ID",

View File

@ -65,6 +65,8 @@ local MODULE_PATHS = {
DungeonWeaponManager = "app/module/dungeon_weapon/dungeon_weapon_manager",
-- 防具副本
DungeonArmorManager = "app/module/dungeon_armor/dungeon_armor_manager",
-- 装备
EquipManager = "app/module/equip/equip_manager",
}
-- 这里的key对应func_open里的id
@ -92,6 +94,8 @@ ModuleManager.MODULE_KEY = {
COLLECT = "collection_open", -- 收集
DUNGEON_ARMOR = "dungeon_armor_open", -- 支线副本
DUNGEON_WEAPON = "dungeon_weapon_open", -- 装备副本
EQUIP_WEAPON = "equip_weapon_open", -- 武器
EQUIP_ARMOR = "equip_armor_open", -- 防具
}
local _moduleMgrs = {}

View File

@ -12,6 +12,7 @@ local CONST_PATHS = {
BattleConst = "app/module/battle/battle_const",
HeroConst = "app/module/hero/hero_const",
FormationConst = "app/module/formation/formation_const",
EquipConst = "app/module/equip/equip_const",
ShopConst = "app/module/shop/shop_const",
SummonConst = "app/module/summon/summon_const",
MailConst = "app/module/mail/mail_const",
@ -204,6 +205,7 @@ GConst.ATLAS_PATH = {
ICON_HERO_2 = "assets/arts/atlas/icon/hero_2.asset",
ICON_SKILL_ROGUE = "assets/arts/atlas/icon/skill_rogue.asset",
ICON_BUFF = "assets/arts/atlas/icon/buff.asset",
ICON_EQUIP = "assets/arts/atlas/icon/equip.asset",
BOUNTY = "assets/arts/atlas/ui/bounty.asset",
UI_SETTING = "assets/arts/atlas/ui/setting.asset",
ICON_TASK = "assets/arts/atlas/icon/task.asset",
@ -482,6 +484,14 @@ GConst.ENTITY_TYPE = {
JEWELRY_ENTITY = 3,
}
GConst.MATCH_HP_NAME = {
[1] = "hp",
[2] = "hp",
[3] = "hp",
[4] = "hp",
[5] = "hp",
}
GConst.MATCH_ATTACK_NAME = {
[0] = "atk",
[1] = "atk_red",

View File

@ -428,6 +428,11 @@ function GFunc.getBuffDesc(buffName, effectNum)
return I18N:getTextWithOtherKey("buff", "name", buffName, "desc", effectNum)
end
function GFunc.getAttrDesc(attrName, attrNum)
attrNum = attrNum // 100
return I18N:getTextWithOtherKey("attr", "name", attrName, "desc", attrNum)
end
function GFunc.getAttrName(key)
return I18N:getText("attr", key, "name")
end

View File

@ -1728,7 +1728,7 @@ function BattleUnitComp:takeDamageOrCure(atker, num, effectType, effectStatus, d
local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_BY_BURN)
end
if self.unitEntity:getAttrValue(BattleConst.ATTR_NAME.BLEED) > 0 then
if self.unitEntity:getTotalAttrValue(BattleConst.ATTR_NAME.BLEED) > 0 then
local team = self.battleController:getOtherSideTeam(self.side)
team:checkPassiveEvent(BattleConst.PASSIVE_EVENT.ON_DEAD_WITH_BLEED)
end

View File

@ -19,7 +19,7 @@ local function _judgeTargetAttr(buffCondition, conditionRel, target, battleContr
if buffCondition.attr == "hpp" then
attrNum = target.unitEntity:getHpPercent() * DEFAULT_FACTOR
else
attrNum = target.unitEntity:getAttrValue(buffCondition.attr)
attrNum = target.unitEntity:getTotalAttrValue(buffCondition.attr)
end
return BattleSkillConditionHandle._strOperatorOverloading(buffCondition.op, attrNum, buffCondition.v)
end

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 222c5bc28608bbc4fa9f9d8130fbf737
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,27 @@
local EquipConst = {}
-- 部位类型
EquipConst.PART_TYPE = {
WEAPON = 1,
HAT = 2,
CLOTHES = 3,
BELT = 4,
HANDGUARD = 5
}
-- 界面类型
EquipConst.PANEL_TYPE = {
HERO = 1,
WEAPON = 2,
ARMOR = 3,
}
-- 加成属性类型
EquipConst.ATTR_TYPE = {
HP = 1,
ATK = 2,
NORMAL_HURT = 3,
SKILL_HURT = 4,
}
return EquipConst

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a5ec83c29e9559c418698f2dc75e7dbd
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,40 @@
local EquipManager = class("EquipManager", BaseModule)
-- 升级装备
function EquipManager:reqUpgrade(id, part)
local entity = DataManager.EquipData:getEquip(id, part)
if not entity then
return
end
if not entity:isEnoughMaterial() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_8))
-- 打开副本界面
return
end
if not entity:isEnoughGold() then
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_GOLD)
ModuleManager.ShopManager:tryTriggerCoinGift()
return
end
if entity:isMaxLevel() then
if entity:getPart() == GConst.EquipConst.PART_TYPE.WEAPON then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_7, DataManager.PlayerData:getLv() + 1))
else
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_9, entity:getLevel() + 1))
end
return
end
self:sendMessage(ProtoMsgType.FromMsgEnum.EquipUpgradeReq, {hero_id = id, position = part}, {}, self.rspUpgrade, BIReport.ITEM_GET_TYPE.EQUIP_UPGRADE)
end
function EquipManager:rspUpgrade(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.EquipData:onUpgradeEquip(result.reqData.hero_id, result.reqData.position)
end
end
return EquipManager

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7f304c187ddaa934d9b50da6fc0e015b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -16,6 +16,55 @@ HeroConst.CHECK_LV_UP_STATE = {
COIN_NOT_ENOUGH = 5
}
-- 总计
HeroConst.ATTR_SHOW_TOTAL = {
GConst.MATCH_HP_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.ATTR_SHOW_BASE = {
GConst.MATCH_HP_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 = {
GConst.MATCH_HP_NAME, -- 生命
GConst.MATCH_ATTACK_NAME, -- 攻击
}
-- 需要显示属性的模块
HeroConst.SHOW_NODE =
{
HeroConst.ATTR_SHOW_TOTAL,
HeroConst.ATTR_SHOW_BASE,
HeroConst.ATTR_SHOW_WEAPON,
HeroConst.ATTR_SHOW_ARMOR,
}
HeroConst.TRIAL_HERO_ID = 34001 -- 花木兰
HeroConst.TRIAL_HERO_MIN_CHAPTER = 2
HeroConst.TRIAL_HERO_MAX_CHAPTER = 4

View File

@ -0,0 +1,194 @@
local ArmorInfoComp = class("ArmorInfoComp", LuaComponent)
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
local ARMOR_PART_INDEX = {
[1] = GConst.EquipConst.PART_TYPE.HAT,
[2] = GConst.EquipConst.PART_TYPE.CLOTHES,
[3] = GConst.EquipConst.PART_TYPE.HANDGUARD,
[4] = GConst.EquipConst.PART_TYPE.BELT,
}
function ArmorInfoComp:init()
local uiMap = self:getUIMap()
self.txAttr = uiMap["armor_info.attr.tx_attr"]
self.txDesc = uiMap["armor_info.tx_desc"]
self.btnUp = uiMap["armor_info.upgrade.btn_up"]
self.txUp = uiMap["armor_info.upgrade.btn_up.tx_desc"]
self.txNum = uiMap["armor_info.upgrade.btn_up.tx_num"]
self.btnAttr = uiMap["armor_info.attr.btn_attr"]
self.imgCurBg = uiMap["armor_info.current.cur_armor.bg"]
self.txCurName = uiMap["armor_info.current.cur_armor.name.tx_name"]
self.imgCurIcon = uiMap["armor_info.current.cur_armor.img_icon"]
self.txCurLevel = uiMap["armor_info.current.cur_armor.tx_num"]
self.imgNextBg = uiMap["armor_info.current.next_armor.bg"]
self.txNextName = uiMap["armor_info.current.next_armor.name.tx_name"]
self.imgNextIcon = uiMap["armor_info.current.next_armor.img_icon"]
self.txNextLevel = uiMap["armor_info.current.next_armor.tx_num"]
self.attr = {}
for i = 1, 2 do
self.attr[i] = uiMap["armor_info.attr_" .. i]
end
self.armor = {}
for i = 1, 4 do
self.armor[i] = uiMap["armor_info.other.armor_" .. i]
self.armor[i]:addClickListener(function()
self:onSelectIdx(i)
end)
end
self.txAttr:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_6))
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_16))
self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
self.btnUp:addClickListener(function()
ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), self.selectPart)
end)
self.btnAttr:addClickListener(function()
ModuleManager.TipsManager:showDescTips(DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), self.selectPart):getAttrDesc(), self.btnAttr)
end)
end
function ArmorInfoComp:setHeroData(heroEntity)
self.heroEntity = heroEntity
self.selectPart = self.selectPart or GConst.EquipConst.PART_TYPE.HAT
end
function ArmorInfoComp:refresh()
self:onSelectIdx(self:getIndexByPart(self.selectPart))
end
function ArmorInfoComp:onSelectIdx(index)
self.selectPart = ARMOR_PART_INDEX[index]
self:refreshSelectArmor()
for index, value in ipairs(self.armor) do
self:refreshPart(index)
end
end
function ArmorInfoComp:refreshSelectArmor()
-- current
local armorEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), self.selectPart)
self.txCurName:setText(armorEntity:getName())
self.imgCurBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorEntity:getStage())
-- self.imgCurIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorEntity:getIconId())
self.txCurLevel:setText("+".. armorEntity:getLevel())
-- next
local armorNextEntity = armorEntity:getNextLevelEntity()
self.txNextName:setText(armorNextEntity:getName())
self.imgNextBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorNextEntity:getStage())
-- self.imgNextIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorNextEntity:getIconId())
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 showAttrType = {}
for index, obj in ipairs(self.attr) do
local map = obj:genAllChildren()
local imgIcon = map["img_icon"]
local txTitle = map["tx_title"]
local txNum = map["tx_num"]
obj:setVisible(true)
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) and diffAtk > 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>")
txNum:setText(armorEntity:getAttack() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffAtk .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) and diffNormalHurt > 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>")
txNum:setText(armorEntity:getNormalHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffNormalHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) and diffSkillHurt > 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>")
txNum:setText(armorEntity:getSkillHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffSkillHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and diffHp > 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>")
txNum:setText(armorEntity:getHp() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffHp .. "</color>")
else
obj:setVisible(false)
end
end
-- 消耗材料
local cost = armorEntity:getUpgradeMaterials()
for i = 1, 3 do
local uiMap = self:getUIMap()
local costNode = uiMap["armor_info.upgrade.cost.cost_" .. i]
if cost[i] then
costNode:setActive(true)
local icon = uiMap["armor_info.upgrade.cost.cost_" .. i .. ".img_icon"]
local num = uiMap["armor_info.upgrade.cost.cost_" .. i .. ".tx_num"]
local costId = GFunc.getRewardId(cost[i])
local costNum = GFunc.getRewardNum(cost[i])
local haveNum = DataManager.BagData.ItemData:getItemNumById(costId)
if haveNum < costNum then
num:setText("<color=#FF5252>" .. haveNum .. "</color>/" .. costNum)
else
num:setText(haveNum .. "/" .. costNum)
end
-- icon:setSprite(GFunc.getIconRes(costId))
else
costNode:setActive(false)
end
end
self.txNum:setText(armorEntity:getUpgradeGoldNum())
local canLvUp = armorEntity:canLevelUp()
if canLvUp then
self.btnUp:addRedPoint(120, 50, 0.6)
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
else
self.btnUp:removeRedPoint()
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
end
function ArmorInfoComp:refreshPart(index)
local part = ARMOR_PART_INDEX[index]
local armorObj = self.armor[index]
-- Logger.logHighlight("index:"..index)
-- Logger.logHighlight("part:"..part)
if not armorObj then
Logger.logHighlight("不存在部位:"..part)
return
end
local armorEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), part)
local map = armorObj:genAllChildren()
local imgSelect = map["img_select"]
local imgBg = map["img_bg"]
local imgIcon = map["img_icon"]
local imgType = map["img_type"]
local txLevel = map["tx_num"]
local stage = armorEntity:getStage()
imgSelect:setActive(part == self.selectPart)
imgSelect:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_select_" .. math.floor(stage / 2) + stage % 2)
imgBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. stage)
-- imgIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorEntity:getIconId())
imgType:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, stage <= 1 and "frame_dec_1" or "frame_dec_2")
txLevel:setText("+".. armorEntity:getLevel())
end
function ArmorInfoComp:getIndexByPart(part)
for i, p in ipairs(ARMOR_PART_INDEX) do
if p == part then
return i
end
end
return nil
end
return ArmorInfoComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 737f4f50ad1db9b4a93cad6afae4656c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,228 @@
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 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
value = self.heroEntity:getCfgHp(self.heroEntity:getLv())
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getHp()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = value + self.hatEntity:getHp()
value = value + self.clothesEntity:getHp()
value = value + self.beltEntity:getHp()
value = value + self.handguardEntity:getHp()
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 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
value = self.heroEntity:getCfgAtk(self.heroEntity:getLv())
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_WEAPON then
value = self.weaponEntity:getAttack()
elseif self.nodeType == GConst.HeroConst.ATTR_SHOW_ARMOR then
value = value + self.hatEntity:getAttack()
value = value + self.clothesEntity:getAttack()
value = value + self.beltEntity:getAttack()
value = value + self.handguardEntity:getAttack()
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: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: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: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: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:getTotalAttrValue(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:getTotalAttrValue(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: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: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: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: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:getTotalAttrValue(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

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 466f2f1b3480deb4d8b6928f700a143d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,32 @@
local AttrNodeCell = class("AttrNodeCell", BaseCell)
local ATTR_CELL = "app/ui/hero/cell/attr_cell"
local ATTR_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_cell.prefab"
function AttrNodeCell:init()
local uiMap = self:getUIMap()
self.txTitle = uiMap["total_node.tx_title"]
self.itemsRoot = uiMap["total_node.items"]
end
function AttrNodeCell:refresh(heroId, node)
if node == GConst.HeroConst.ATTR_SHOW_TOTAL then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_13))
elseif node == GConst.HeroConst.ATTR_SHOW_BASE then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_14))
elseif node == GConst.HeroConst.ATTR_SHOW_WEAPON then
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_15))
elseif node == GConst.HeroConst.ATTR_SHOW_ARMOR then
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))
end
for index, attr in ipairs(node) do
CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell)
cell:refresh(heroId, node, attr)
end)
end
end
return AttrNodeCell

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b4e090e8b69f7fb48af4cd0cff1d22e2
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,57 @@
local HeroAttrUI = class("HeroAttrUI", BaseUI)
local ATTR_NODE_CELL = "app/ui/hero/cell/attr_node_cell"
local ATTR_NODE_CELL_PATH = "assets/prefabs/ui/hero/cell/attr_node_cell.prefab"
local ATTR_CELLS_PADDING = 60
local ATTR_CELL_HEIGHT = 80
local ATTR_CELL_SPACING_Y = 8
function HeroAttrUI:isFullScreen()
return false
end
function HeroAttrUI:getPrefabPath()
return "assets/prefabs/ui/hero/hero_attr_ui.prefab"
end
function HeroAttrUI:onPressBackspace()
self:closeUI()
end
function HeroAttrUI:onClose()
self.rootNodes:removeAllChildren()
end
function HeroAttrUI:ctor(parmas)
self.heroId = parmas
end
function HeroAttrUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
self.txTitle = uiMap["hero_attr_ui.content.tx_title"]
self.btnClose = uiMap["hero_attr_ui.content.btn_close"]
self.rootNodes = uiMap["hero_attr_ui.content.ScrollView.Viewport.Content"]
self.txTitle:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_18))
self.btnClose:addClickListener(function()
self:closeUI()
end)
end
function HeroAttrUI:onRefresh()
local totalHeight = 0
for index, node in ipairs(GConst.HeroConst.SHOW_NODE) do
CellManager:loadCellAsync(ATTR_NODE_CELL_PATH, ATTR_NODE_CELL, self.rootNodes, function(cell)
local nodeHeight = math.ceil(#node / 2) * ATTR_CELL_HEIGHT + (math.ceil(#node / 2) - 1) * ATTR_CELL_SPACING_Y + ATTR_CELLS_PADDING
cell.baseObject:setLocalPositionY(-totalHeight)
cell.baseObject:setSizeDeltaY(nodeHeight)
cell:refresh(self.heroId, node)
totalHeight = totalHeight + nodeHeight
self.rootNodes:setSizeDeltaY(totalHeight)
end)
end
end
return HeroAttrUI

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 73590143cf9ae2845905eb2f7c56695a
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -14,11 +14,7 @@ function HeroComp:init()
self:onClickHero(cell, heroId)
end)
end)
self.heroList = {}
local heroCfg = ConfigManager:getConfig("hero")
for id, v in pairs(heroCfg) do
table.insert(self.heroList, {cfgId = id, sort = id, elementType = v.position})
end
self.heroList = DataManager.HeroData:getAllHeroesSort()
self.heroNodeList = {
self.uiMap["hero_ui.formation.hero_1"],
self.uiMap["hero_ui.formation.hero_2"],
@ -198,7 +194,6 @@ function HeroComp:refreshScrollRect()
end
end
self:sortHeroList()
self.allHeroCount = #self.heroList
self.unlockCount = DataManager.HeroData:getUnlockHeroCount()
local lockCount = self.allHeroCount - self.unlockCount
@ -218,35 +213,6 @@ function HeroComp:refreshScrollRect()
end
end
-- 等级>品质>id
function HeroComp:sortHeroList()
local HeroData = DataManager.HeroData
for _, info in ipairs(self.heroList) do
local heroEntity = HeroData:getHeroById(info.cfgId)
local sort = info.cfgId -- id 预留6位
sort = sort + (10 - info.elementType) * 1000000 -- 位置预留1位
sort = sort + 10000000 * heroEntity:getQlt() -- 品质1位
sort = sort + 100000000 * heroEntity:getLv() -- 预留3位
if heroEntity:isUnlock() then
sort = sort + 300000000000
if heroEntity:isActived() then
sort = sort + 400000000000
else
sort = sort + 300000000000
end
elseif DataManager.BagData.ItemData:getItemNumById(heroEntity:getFragmentId()) > 0 then
sort = sort + 200000000000
else
sort = sort + 100000000000
end
info.sort = sort
end
table.sort(self.heroList, function(a, b)
return a.sort > b.sort
end)
end
function HeroComp:onClickHero(cell, heroId)
if not cell or not heroId then
self.largeHeroCell:getBaseObject():setAnchoredPositionX(OUT_SCREEN_X)

View File

@ -1,9 +1,7 @@
local HeroDetailUI = class("HeroDetailUI", BaseUI)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local COMP_HERO = "app/ui/hero/hero_info_comp"
local COMP_WEAPON = "app/ui/hero/weapon_info_comp"
local COMP_ARMOR = "app/ui/hero/armor_info_comp"
local SIZE_DELTA_Y_HERO = 942
local SIZE_DELTA_Y_LOOK = 802
@ -20,6 +18,7 @@ function HeroDetailUI:onPressBackspace()
end
function HeroDetailUI:ctor(parmas)
self.panelType = parmas.panelType or GConst.EquipConst.PANEL_TYPE.HERO
self.onlyLook = parmas.onlyLook
if parmas.heroEntity then
self.heroEntity = parmas.heroEntity
@ -30,175 +29,197 @@ function HeroDetailUI:ctor(parmas)
end
function HeroDetailUI:onLoadRootComplete()
self:_initSpineObjs()
self:_display()
self:_addListeners()
self:_bind()
end
function HeroDetailUI:_display(lvChange)
local uiMap = self.root:genAllChildren()
uiMap["hero_detail_ui.bg.title_desc"]:setText(self.heroEntity:getName())
uiMap["hero_detail_ui.bg.lv_desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv()))
local elementBg = uiMap["hero_detail_ui.bg.element_bg"]
local elementTx = uiMap["hero_detail_ui.bg.element_desc"]
elementTx:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType()))
local elementTxRectWidth = elementTx:getRectWidth()
local elementTxWidth = elementTx:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
if elementTxWidth > elementTxRectWidth then
elementBg:setSizeDeltaX(52 + elementTxWidth)
self.commonInfo = uiMap["hero_detail_ui.common"]
self.heroInfo = uiMap["hero_detail_ui.hero_info"]
self.weaponInfo = uiMap["hero_detail_ui.weapon_info"]
self.armorInfo = uiMap["hero_detail_ui.armor_info"]
self.txTitle = uiMap["hero_detail_ui.common.img_title.tx_title"]
self.btnClose = uiMap["hero_detail_ui.common.btn_close"]
self.btnHero = uiMap["hero_detail_ui.common.btns.btn_hero"]
self.txHero1 = uiMap["hero_detail_ui.common.btns.btn_hero.tx_btn"]
self.selectHero = uiMap["hero_detail_ui.common.btns.btn_hero.select"]
self.txHero2 = uiMap["hero_detail_ui.common.btns.btn_hero.select.tx_select"]
self.btnWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon"]
self.lockWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon.img_lock"]
self.txWeapon1 = uiMap["hero_detail_ui.common.btns.btn_weapon.tx_btn"]
self.selectWeapon = uiMap["hero_detail_ui.common.btns.btn_weapon.select"]
self.txWeapon2 = uiMap["hero_detail_ui.common.btns.btn_weapon.select.tx_select"]
self.btnArmor = uiMap["hero_detail_ui.common.btns.btn_armor"]
self.lockArmor = uiMap["hero_detail_ui.common.btns.btn_armor.img_lock"]
self.txArmor1 = uiMap["hero_detail_ui.common.btns.btn_armor.tx_btn"]
self.selectArmor = uiMap["hero_detail_ui.common.btns.btn_armor.select"]
self.txArmor2 = uiMap["hero_detail_ui.common.btns.btn_armor.select.tx_select"]
self.btnLeft = uiMap["hero_detail_ui.common.btn_left"]
self.btnRight = uiMap["hero_detail_ui.common.btn_right"]
self.txHero1:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
self.txHero2:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4))
self.txWeapon1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
self.txWeapon2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_1))
self.txArmor1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
self.txArmor2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_2))
if not DataManager.EquipData:isWeaponOpen() then
self.lockWeapon:setVisible(true)
GFunc.centerImgAndTx(self.lockWeapon, self.txWeapon1, 5)
else
elementBg:setSizeDeltaX(52 + elementTxRectWidth)
self.lockWeapon:setVisible(false)
end
uiMap["hero_detail_ui.bg.skill_desc"]:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill()))
uiMap["hero_detail_ui.bg.hp_name"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
uiMap["hero_detail_ui.bg.atk_name"]:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_3))
uiMap["hero_detail_ui.bg.skill_node.skill_icon"]:setSprite(GConst.ATLAS_PATH.ICON_SKILL_BIG, ModuleManager.HeroManager:getSkillIcon(self.heroEntity:getBaseSkill()))
uiMap["hero_detail_ui.bg.hero_element"]:setSprite(GConst.ATLAS_PATH.HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType()))
local materials = self.heroEntity:getLvUpMaterials() or {}
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId())
local needFragmentCount = materials[1] or 1
uiMap["hero_detail_ui.bg.fragment_bg.fragment_num"]:setText(fragmentCount .. "/" .. needFragmentCount)
local slider = uiMap["hero_detail_ui.bg.fragment_bg.slider"]
if fragmentCount >= needFragmentCount then
slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_1", nil, slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
if not DataManager.EquipData:isArmorOpen() then
self.lockArmor:setVisible(true)
GFunc.centerImgAndTx(self.lockArmor, self.txArmor1, 5)
else
slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_2", nil, slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
self.lockArmor:setVisible(false)
end
slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
local activeCount = self.heroEntity:getActiveRogueCount()
local skillList = self.heroEntity:getRogueSkillList()
local skillLvs = ModuleManager.HeroManager:getActiveRogueLvs()
for i = 1, 7 do
local skillId = skillList[i]
if skillId then
local skillIcon = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".icon"]
local skillBg = uiMap["hero_detail_ui.bg.skill_up_" .. i]
local skillLv = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"]
skillBg:addClickListener(function()
ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), skillIcon)
self.heroList = DataManager.HeroData:getAllHeroesSort()
self:updateSide()
self:refreshShow()
self.btnHero:addClickListener(function()
self.panelType = GConst.EquipConst.PANEL_TYPE.HERO
self:refreshShow()
end)
skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId))
skillBg:setTouchEnable(true)
if i > activeCount then
skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0))
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, "frame_0")
else
skillLv:setText(GConst.EMPTY_STRING)
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId, true))
if i == activeCount and lvChange and self.heroEntity:getLv() == skillLvs[i] then
local x, y = skillBg:fastGetAnchoredPosition()
self.spineObjSkill:setAnchoredPosition(x, y)
self.spineObjSkill:setVisible(true)
self.spineObjSkill:playAnim("idle", false, true)
self.btnWeapon:addClickListener(function()
if not DataManager.EquipData:isWeaponOpen(true) then
return
end
self.panelType = GConst.EquipConst.PANEL_TYPE.WEAPON
self:refreshShow()
end)
self.btnArmor:addClickListener(function()
if not DataManager.EquipData:isArmorOpen(true) then
return
end
end
end
uiMap["hero_detail_ui.bg.fragment_bg"]:setVisible(not self.heroEntity:isMaxLv())
local canLvUp = self.heroEntity:canLvUp()
uiMap["hero_detail_ui.bg.fragment_bg.fragment_icon"]:setVisible(not canLvUp)
local lv = self.heroEntity:getLv()
local str
local hpStr
local atkStr
if self.heroEntity:isActived() then
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)
local curHp = self.heroEntity:getCfgHp() // DEFAULT_FACTOR
local curAtk = self.heroEntity:getCfgAtk() // DEFAULT_FACTOR
local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp
local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk
if addHp <= 0 then
hpStr = curHp
else
hpStr = curHp .. "<color=#82FF82>+" .. addHp .. "</color>"
end
if addAtk <= 0 then
atkStr = curAtk
else
atkStr = curAtk .. "<color=#82FF82>+" .. addAtk .. "</color>"
end
else
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5)
hpStr = self.heroEntity:getCfgHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
atkStr = self.heroEntity:getCfgAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
end
uiMap["hero_detail_ui.bg.up_btn.desc"]:setText(str)
uiMap["hero_detail_ui.bg.up_btn.num"]:setText(materials[2])
uiMap["hero_detail_ui.bg.up_btn.rp"]:setVisible(self.heroEntity:canLvUp())
uiMap["hero_detail_ui.bg.hp"]:setText(hpStr)
uiMap["hero_detail_ui.bg.atk"]:setText(atkStr)
local btn = uiMap["hero_detail_ui.bg.up_btn"]
self.spineObjLv:setVisible(canLvUp)
if canLvUp then
btn:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
self.spineObjLv:playAnim("animation", true, false)
else
btn:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
btn:setTouchEnable(true)
btn:setActive(not self.heroEntity:isMaxLv())
if lvChange then
self.spineObj:setVisible(true)
self.spineObj:playAnim("idle", false, true)
end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
uiMap["hero_detail_ui.bg.down"]:setVisible(false)
uiMap["hero_detail_ui.bg.up_btn"]:setVisible(false)
uiMap["hero_detail_ui.bg"]:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
else
uiMap["hero_detail_ui.bg.down"]:setVisible(true)
uiMap["hero_detail_ui.bg.up_btn"]:setVisible(true)
uiMap["hero_detail_ui.bg"]:setSizeDeltaY(SIZE_DELTA_Y_HERO)
end
end
function HeroDetailUI:_addListeners()
local uiMap = self.root:genAllChildren()
uiMap["hero_detail_ui.bg.back_btn"]:addClickListener(function()
self.panelType = GConst.EquipConst.PANEL_TYPE.ARMOR
self:refreshShow()
end)
self.btnClose:addClickListener(function()
self:closeUI()
end)
uiMap["hero_detail_ui.bg.up_btn"]:addClickListener(function()
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity)
self.btnLeft:addClickListener(function()
if not self:isExistLeftHero() then
return
end
self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxLast].cfgId)
self:updateSide()
self:refreshShow()
end)
end
function HeroDetailUI:_bind()
self:bind(self.heroEntity, "lv", function()
self:_display(true)
self.btnRight:addClickListener(function()
if not self:isExistRightHero() then
return
end
self.heroEntity = DataManager.HeroData:getHeroById(self.heroList[self.idxNext].cfgId)
self:updateSide()
self:refreshShow()
end)
self:addEventListener(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS, function()
self:refreshShow()
end)
self:bind(DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GOLD), "isDirty", function()
self:_display()
self:refreshShow()
end)
end
function HeroDetailUI:_initSpineObjs()
local uiMap = self.root:genAllChildren()
self.spineObjSkill = uiMap["hero_detail_ui.bg.ui_spine_obj_skill"]
self.spineObjLv = uiMap["hero_detail_ui.bg.ui_spine_obj_lv"]
self.spineObj = uiMap["hero_detail_ui.bg.ui_spine_obj"]
self.spineObjAvatar = uiMap["hero_detail_ui.bg.ui_spine_obj_avatar"]
function HeroDetailUI:updateSide()
for index, data in ipairs(self.heroList) do
if data.cfgId == self.heroEntity.id then
self.idxLast = index - 1
self.idxNext = index + 1
end
end
end
self.spineObjAvatar:getSkeletonGraphic().enabled = false
self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function()
self.spineObjAvatar:getSkeletonGraphic().enabled = true
self.spineObjAvatar:playAnim("idle", true, true, true)
end, true)
function HeroDetailUI:refreshShow()
self.txTitle:setText(self.heroEntity:getName())
self.spineObjSkill:setVisible(false)
self.spineObjLv:setVisible(false)
self.spineObj:setVisible(false)
if self.panelType == GConst.EquipConst.PANEL_TYPE.HERO then
self:showHeroInfo()
elseif self.panelType == GConst.EquipConst.PANEL_TYPE.WEAPON then
self:showWeaponInfo()
elseif self.panelType == GConst.EquipConst.PANEL_TYPE.ARMOR then
self:showArmorInfo()
end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
self.btnHero:setVisible(false)
self.btnWeapon:setVisible(false)
self.btnArmor:setVisible(false)
self.btnLeft:setVisible(false)
self.btnRight:setVisible(false)
self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
else
self.btnHero:setVisible(true)
self.btnWeapon:setVisible(true)
self.btnArmor:setVisible(true)
self.btnLeft:setVisible(self:isExistLeftHero())
self.btnRight:setVisible(self:isExistRightHero())
self.commonInfo:setSizeDeltaY(SIZE_DELTA_Y_HERO)
end
end
function HeroDetailUI:showHeroInfo()
self.heroInfo:setActive(true)
self.selectHero:setActive(true)
self.weaponInfo:setActive(false)
self.selectWeapon:setActive(false)
self.armorInfo:setActive(false)
self.selectArmor:setActive(false)
if not self.compHero then
self.heroInfo:initPrefabHelper()
self.heroInfo:genAllChildren()
self.compHero = self.heroInfo:addLuaComponent(COMP_HERO)
end
self.compHero:setHeroData(self.heroEntity, self.onlyLook)
self.compHero:refresh()
end
function HeroDetailUI:showWeaponInfo()
self.heroInfo:setActive(false)
self.selectHero:setActive(false)
self.weaponInfo:setActive(true)
self.selectWeapon:setActive(true)
self.armorInfo:setActive(false)
self.selectArmor:setActive(false)
if not self.compWeapon then
self.weaponInfo:initPrefabHelper()
self.weaponInfo:genAllChildren()
self.compWeapon = self.weaponInfo:addLuaComponent(COMP_WEAPON)
end
self.compWeapon:setHeroData(self.heroEntity)
self.compWeapon:refresh()
end
function HeroDetailUI:showArmorInfo()
self.heroInfo:setActive(false)
self.selectHero:setActive(false)
self.weaponInfo:setActive(false)
self.selectWeapon:setActive(false)
self.armorInfo:setActive(true)
self.selectArmor:setActive(true)
if not self.compArmor then
self.armorInfo:initPrefabHelper()
self.armorInfo:genAllChildren()
self.compArmor = self.armorInfo:addLuaComponent(COMP_ARMOR)
end
self.compArmor:setHeroData(self.heroEntity)
self.compArmor:refresh()
end
-- 是否存在左侧英雄
function HeroDetailUI:isExistLeftHero()
return self.idxLast and self.idxLast > 0
end
-- 是否存在右侧英雄
function HeroDetailUI:isExistRightHero()
return self.idxNext and self.idxNext <= #self.heroList
end
return HeroDetailUI

View File

@ -0,0 +1,194 @@
local HeroInfoComp = class("HeroInfoComp", LuaComponent)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local SIZE_DELTA_Y_HERO = 942
local SIZE_DELTA_Y_LOOK = 802
function HeroInfoComp:init()
local uiMap = self:getUIMap()
self.slider = uiMap["hero_detail_ui.bg.fragment_bg.slider"]
self.imgElement = uiMap["hero_detail_ui.bg.hero_element"]
self.imgSkill = uiMap["hero_detail_ui.bg.skill_node.skill_icon"]
self.imgFragment = uiMap["hero_detail_ui.bg.fragment_bg.fragment_icon"]
self.btnUp = uiMap["hero_detail_ui.bg.up_btn"]
self.imgUpIcon = uiMap["hero_detail_ui.bg.up_btn.icon"]
self.txUpdesc = uiMap["hero_detail_ui.bg.up_btn.desc"]
self.txUpNum = uiMap["hero_detail_ui.bg.up_btn.num"]
self.txLv = uiMap["hero_detail_ui.bg.lv_desc"]
self.txElement = uiMap["hero_detail_ui.bg.element_desc"]
self.txSkill = uiMap["hero_detail_ui.bg.skill_desc"]
self.txFragmentNum = uiMap["hero_detail_ui.bg.fragment_bg.fragment_num"]
self.txHpName = uiMap["hero_detail_ui.bg.hp_name"]
self.txAtkName = uiMap["hero_detail_ui.bg.atk_name"]
self.txHp = uiMap["hero_detail_ui.bg.hp"]
self.txAtk = uiMap["hero_detail_ui.bg.atk"]
self.bgFragment = uiMap["hero_detail_ui.bg.fragment_bg"]
self.spineObjSkill = uiMap["hero_detail_ui.bg.ui_spine_obj_skill"]
self.spineObjLv = uiMap["hero_detail_ui.bg.ui_spine_obj_lv"]
self.spineObj = uiMap["hero_detail_ui.bg.ui_spine_obj"]
self.spineObjAvatar = uiMap["hero_detail_ui.bg.ui_spine_obj_avatar"]
self.upgrade = uiMap["hero_info.up"]
self.bgElement = uiMap["hero_detail_ui.bg.element_bg"]
self.btnAttr = uiMap["hero_info.bg_6.btn_attr"]
self.skill = {}
self.skillIcon = {}
self.skillDesc = {}
for i = 1, 7 do
self.skill[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i]
self.skillIcon[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".icon"]
self.skillDesc[i] = uiMap["hero_detail_ui.bg.skill_up_" .. i .. ".desc"]
end
self.spineObjSkill:setVisible(false)
self.spineObjLv:setVisible(false)
self.spineObj:setVisible(false)
self.btnUp:addClickListener(function()
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity)
end)
self.btnAttr:addClickListener(function()
UIManager:showUI("app/ui/hero/hero_attr_ui", self.heroEntity:getCfgId())
end)
end
function HeroInfoComp:setHeroData(heroEntity, onlyLook)
self.heroEntity = heroEntity
self.onlyLook = onlyLook
self:bind(self.heroEntity, "lv", function()
self:refresh(true)
end)
end
function HeroInfoComp:refresh(lvChange)
self.txLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, self.heroEntity:getLv()))
self.spineObjAvatar:getSkeletonGraphic().enabled = false
self.spineObjAvatar:loadAssetAsync(self.heroEntity:getModelId(), function()
self.spineObjAvatar:getSkeletonGraphic().enabled = true
self.spineObjAvatar:playAnim("idle", true, true, true)
end, true)
self.txElement:setText(ModuleManager.HeroManager:getMatchTypeName(self.heroEntity:getMatchType()))
local elementTxRectWidth = self.txElement:getRectWidth()
local elementTxWidth = self.txElement:getComponent(GConst.TYPEOF_UNITY_CLASS.UI_TEXT_MESH_PRO).preferredWidth
if elementTxWidth > elementTxRectWidth then
self.bgElement:setSizeDeltaX(52 + elementTxWidth)
else
self.bgElement:setSizeDeltaX(52 + elementTxRectWidth)
end
self.txSkill:setText(ModuleManager.HeroManager:getSkillDesc(self.heroEntity:getBaseSkill()))
self.txHpName:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_2))
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.imgElement:setSprite(GConst.ATLAS_PATH.HERO, ModuleManager.HeroManager:getMatchTypeIcon(self.heroEntity:getMatchType()))
local materials = self.heroEntity:getLvUpMaterials() or {}
local fragmentCount = DataManager.BagData.ItemData:getItemNumById(self.heroEntity:getFragmentId())
local needFragmentCount = materials[1] or 1
self.txFragmentNum:setText(fragmentCount .. "/" .. needFragmentCount)
if fragmentCount >= needFragmentCount then
self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_1", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
else
self.slider:setSprite(GConst.ATLAS_PATH.COMMON, "common_progress_2", nil, self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER))
end
self.slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = fragmentCount / needFragmentCount
local activeCount = self.heroEntity:getActiveRogueCount()
local skillList = self.heroEntity:getRogueSkillList()
local skillLvs = ModuleManager.HeroManager:getActiveRogueLvs()
for i = 1, 7 do
local skillId = skillList[i]
if skillId then
local skillBg = self.skill[i]
local skillIcon = self.skillIcon[i]
local skillLv = self.skillDesc[i]
skillBg:addClickListener(function()
ModuleManager.TipsManager:showDescTips(ModuleManager.HeroManager:getSkillRogueDesc(skillId), skillIcon)
end)
skillIcon:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueIcon(skillId))
skillBg:setTouchEnable(true)
if i > activeCount then
skillLv:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, skillLvs[i] or 0))
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, "frame_0")
else
skillLv:setText(GConst.EMPTY_STRING)
skillBg:setSprite(GConst.ATLAS_PATH.ICON_SKILL_ROGUE, ModuleManager.HeroManager:getSkillRogueBg(skillId, true))
if i == activeCount and lvChange and self.heroEntity:getLv() == skillLvs[i] then
local x, y = skillBg:fastGetAnchoredPosition()
self.spineObjSkill:setAnchoredPosition(x, y)
self.spineObjSkill:setVisible(true)
self.spineObjSkill:playAnim("idle", false, true)
end
end
end
end
self.bgFragment:setVisible(not self.heroEntity:isMaxLv())
local canLvUp = self.heroEntity:canLvUp()
self.imgFragment:setVisible(not canLvUp)
local lv = self.heroEntity:getLv()
local str
local hpStr
local atkStr
if self.heroEntity:isActived() then
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_4)
local curHp = self.heroEntity:getHp() // DEFAULT_FACTOR
local curAtk = self.heroEntity:getAtk() // DEFAULT_FACTOR
local addHp = self.heroEntity:getCfgHp(lv + 1) // DEFAULT_FACTOR - curHp
local addAtk = self.heroEntity:getCfgAtk(lv + 1) // DEFAULT_FACTOR - curAtk
if addHp <= 0 then
hpStr = curHp
else
hpStr = curHp .. "<color=#A2FF29>+" .. addHp .. "</color>"
end
if addAtk <= 0 then
atkStr = curAtk
else
atkStr = curAtk .. "<color=#A2FF29>+" .. addAtk .. "</color>"
end
else
str = I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_5)
hpStr = self.heroEntity:getHp(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
atkStr = self.heroEntity:getAtk(self.heroEntity:getBeginLv()) // DEFAULT_FACTOR
end
self.txUpdesc:setText(str)
self.txUpNum:setText(materials[2])
self.txHp:setText(hpStr)
self.txAtk:setText(atkStr)
if canLvUp then
self.btnUp:addRedPoint(120, 50, 0.6)
else
self.btnUp:removeRedPoint()
end
self.spineObjLv:setVisible(canLvUp)
if canLvUp then
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
self.spineObjLv:playAnim("animation", true, false)
else
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
self.btnUp:setTouchEnable(true)
self.btnUp:setActive(not self.heroEntity:isMaxLv())
if lvChange then
self.spineObj:setVisible(true)
self.spineObj:playAnim("idle", false, true)
end
if self.onlyLook then -- 仅查看的不显示升级和激活按钮
self.upgrade:setVisible(false)
self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_LOOK)
else
self.upgrade:setVisible(true)
self.baseObject:setSizeDeltaY(SIZE_DELTA_Y_HERO)
end
end
return HeroInfoComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 31b3534902c35f2488ec7c843e221ba4
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,121 @@
local WeaponInfoComp = class("WeaponInfoComp", LuaComponent)
local BTN_ICON = {"common_btn_green_2", "common_btn_grey_2"}
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function WeaponInfoComp:init()
local uiMap = self:getUIMap()
self.txName = uiMap["weapon_info.name.tx_name"]
self.imgWeapon = uiMap["weapon_info.img_weapon"]
self.txLevel = uiMap["weapon_info.level.tx_level"]
self.txDesc1 = uiMap["weapon_info.tx_desc_1"]
self.txDesc2 = uiMap["weapon_info.tx_desc_2"]
self.txAttr = uiMap["weapon_info.ScrollView.Viewport.Content.tx_attr"]
self.btnUp = uiMap["weapon_info.upgrade.btn_up"]
self.txUp = uiMap["weapon_info.upgrade.btn_up.tx_desc"]
self.txNum = uiMap["weapon_info.upgrade.btn_up.tx_num"]
self.attr = {}
for i = 1, 2 do
self.attr[i] = uiMap["weapon_info.attr_" .. i]
end
self.txDesc1:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_4))
self.txDesc2:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_5))
self.txUp:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3))
self.btnUp:addClickListener(function()
ModuleManager.EquipManager:reqUpgrade(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)
end)
end
function WeaponInfoComp:setHeroData(heroEntity)
self.heroEntity = heroEntity
self.weaponEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON)
end
function WeaponInfoComp:refresh()
local nextWeaponEntity = self.weaponEntity:getNextLevelEntity()
self.txName:setText(self.weaponEntity:getName())
-- self.imgWeapon:setSprite(GConst.ATLAS_PATH.COMMON, self.weaponEntity:getIcon())
self.txLevel:setText(I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3) .. self.weaponEntity:getLevel().."/"..self.weaponEntity:getMaxLevel())
self.txAttr:setText(self.weaponEntity:getAttrDesc())
-- 基础属性
local diffAtk = (nextWeaponEntity:getAttack() - self.weaponEntity:getAttack()) // DEFAULT_FACTOR
local diffNormalHurt = (nextWeaponEntity:getNormalHurt() - self.weaponEntity:getNormalHurt()) // DEFAULT_FACTOR
local diffSkillHurt = (nextWeaponEntity:getSkillHurt() - self.weaponEntity:getSkillHurt()) // DEFAULT_FACTOR
local diffHp = (nextWeaponEntity:getHp() - self.weaponEntity:getHp()) // DEFAULT_FACTOR
local showAttrType = {}
for index, obj in ipairs(self.attr) do
local map = obj:genAllChildren()
local imgIcon = map["img_icon"]
local txTitle = map["tx_title"]
local txNum = map["tx_num"]
obj:setVisible(true)
if not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.ATK) and diffAtk > 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>")
txNum:setText(self.weaponEntity:getAttack() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffAtk .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.NORMAL_HURT) and diffNormalHurt > 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>")
txNum:setText(self.weaponEntity:getNormalHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffNormalHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.SKILL_HURT) and diffSkillHurt > 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>")
txNum:setText(self.weaponEntity:getSkillHurt() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffSkillHurt .. "</color>")
elseif not table.containValue(showAttrType, GConst.EquipConst.ATTR_TYPE.HP) and diffHp > 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>")
txNum:setText(self.weaponEntity:getHp() // DEFAULT_FACTOR .. "<color=#A2FF29>+" .. diffHp .. "</color>")
else
obj:setVisible(false)
end
end
-- 消耗材料
local cost = self.weaponEntity:getUpgradeMaterials()
for i = 1, 3 do
local uiMap = self:getUIMap()
local costNode = uiMap["weapon_info.upgrade.cost.cost_" .. i]
if cost[i] then
costNode:setActive(true)
local icon = uiMap["weapon_info.upgrade.cost.cost_" .. i .. ".img_icon"]
local num = uiMap["weapon_info.upgrade.cost.cost_" .. i .. ".tx_num"]
local costId = GFunc.getRewardId(cost[i])
local costNum = GFunc.getRewardNum(cost[i])
local haveNum = DataManager.BagData.ItemData:getItemNumById(costId)
if haveNum < costNum then
num:setText("<color=#FF5252>" .. haveNum .. "</color>/" .. costNum)
else
num:setText(haveNum .. "/" .. costNum)
end
-- icon:setSprite(GFunc.getIconRes(costId))
else
costNode:setActive(false)
end
end
if self.weaponEntity:isEnoughGold() then
self.txNum:setText(self.weaponEntity:getUpgradeGoldNum())
else
self.txNum:setText("<color=#FF5252>" .. self.weaponEntity:getUpgradeGoldNum() .. "</color>")
end
local canLvUp = self.weaponEntity:canLevelUp()
if canLvUp then
self.btnUp:addRedPoint(120, 50, 0.6)
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[1])
else
self.btnUp:removeRedPoint()
self.btnUp:setSprite(GConst.ATLAS_PATH.COMMON, BTN_ICON[2])
end
end
return WeaponInfoComp

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 91ff8826d011d0e4ab0ab27ad66d27fa
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -687,10 +687,10 @@ function BattleBaseData:initHeroData(formation)
---- 攻击力
for matchType, attrName in pairs(GConst.MATCH_ATTACK_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
local atkAddName = GConst.MATCH_ATTACK_ADD_NAME[matchType]
if atkAddName then
unitData.attr[attrName] = unitData.attr[attrName] + heroEntity:getAttrValue(atkAddName)
unitData.attr[attrName] = unitData.attr[attrName] + heroEntity:getTotalAttrValue(atkAddName)
end
unitData.attr[attrName] = unitData.attr[attrName] // DEFAULT_FACTOR
@ -698,37 +698,37 @@ function BattleBaseData:initHeroData(formation)
---- 暴击率
for matchType, attrName in pairs(GConst.MATCH_CRIT_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
---- 暴击伤害
for matchType, attrName in pairs(GConst.MATCH_CRIT_TIME_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
---- 治疗效果
for matchType, attrName in pairs(GConst.MATCH_CURED_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
---- 普攻增伤固定值
for matchType, attrName in pairs(GConst.MATCH_NORMAL_HURT_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
---- 普攻增伤百分比
for matchType, attrName in pairs(GConst.MATCH_NORMAL_HURTP_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
---- 技能增伤固定值
for matchType, attrName in pairs(GConst.MATCH_SKILL_HURT_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
---- 技能增伤百分比
for matchType, attrName in pairs(GConst.MATCH_SKILL_HURTP_NAME) do
unitData.attr[attrName] = heroEntity:getAttrValue(attrName)
unitData.attr[attrName] = heroEntity:getTotalAttrValue(attrName)
end
local skillInfo = skillCfg[skillId]

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a746fa6473a70b4479bb34950024c322
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,86 @@
local EquipData = class("EquipData", BaseData)
local EquipEntity = require "app/userdata/equip/equip_entity"
function EquipData:ctor()
self.data.isDirty = false
end
function EquipData:clear()
end
function EquipData:init(data)
data = data or GConst.EMPTY_TABLE
Logger.logHighlight("装备数据")
Logger.printTable(data)
self.equips = {}
if not data.HeroesEquips then
return
end
for heroId, equip in pairs(data.HeroesEquips) do
for part, level in pairs(equip.Equips) do
self:addEquip(heroId, part, level)
end
end
end
function EquipData:setDirty()
self.data.isDirty = not self.data.isDirty
end
-- 武器功能是否开启
function EquipData:isWeaponOpen(showToast)
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.EQUIP_WEAPON, not showToast) then
return false
end
return true
end
-- 防具功能是否开启
function EquipData:isArmorOpen(showToast)
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.EQUIP_ARMOR, not showToast) then
return false
end
return true
end
function EquipData:addEquip(heroId, part, level)
if not self.equips[heroId] then
self.equips[heroId] = {}
end
if self.equips[heroId][part] then
return
end
self.equips[heroId][part] = self:createEntity(heroId, part, level)
end
function EquipData:createEntity(heroId, part, level)
return EquipEntity:create(heroId, part, level)
end
function EquipData:getAllEquips()
return self.equips
end
function EquipData:getEquip(id, part)
if not self.equips[id] then
self.equips[id] = {}
end
if not self.equips[id][part] then
self.equips[id][part] = self:createEntity(id, part)
end
return self.equips[id][part]
end
-- 装备升级
function EquipData:onUpgradeEquip(heroId, part)
local entity = self:getEquip(heroId, part)
if not entity then
return
end
entity:onLevelUp()
DataManager.HeroData:getHeroById(heroId):setEquipAttrDirty()
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.EQUIP_UPGRADE_SUCCESS)
end
return EquipData

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 32de1824973422f489910fc6dbd7797e
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -0,0 +1,351 @@
local EquipEntity = class("EquipEntity", BaseData)
local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function EquipEntity:ctor(heroId, part, level)
self.level = level or 0
self.cfg, self.cfgId = table.find(ConfigManager:getConfig("equip"), function(value)
return value.hero == heroId and value.part == part
end)
end
function EquipEntity:setDirty()
self.data.isDirty = not self.data.isDirty
end
-- 获取部位id
function EquipEntity:getId()
return self.cfgId
end
-- 获取部位所属英雄
function EquipEntity:getHeroId()
return self.cfg.hero
end
-- 获取部位类型
function EquipEntity:getPart()
return self.cfg.part
end
-- 获取部位基础生命值
function EquipEntity:getBaseHp()
if self.cfg.armor_hp and self.cfg.armor_hp[self.level] then
return self.cfg.armor_hp[self.level]
end
return 0
end
-- 获取部位加成后生命值
function EquipEntity:getHp()
local result = self:getBaseHp()
result = result + DataManager.HeroData:getHeroById(self:getHeroId()):getTotalBaseHp() * self:getHpPercent() // DEFAULT_FACTOR
return result
end
-- 获取部位基础攻击力
function EquipEntity:getBaseAttack()
if self.cfg.armor_atk and self.cfg.armor_atk[self.level] then
return self.cfg.armor_atk[self.level]
end
return 0
end
-- 获取部位加成后攻击力
function EquipEntity:getAttack()
local result = self:getBaseAttack()
result = result + DataManager.HeroData:getHeroById(self:getHeroId()):getTotalBaseAtk() * self:getAtkPercent() // DEFAULT_FACTOR
return result
end
-- 获取部位普攻伤害
function EquipEntity:getNormalHurt()
if self.cfg.normal_hurt_add and self.cfg.normal_hurt_add[self.level] then
return self.cfg.normal_hurt_add[self.level]
end
return 0
end
-- 获取部位技能伤害
function EquipEntity:getSkillHurt()
if self.cfg.skill_hurt_add and self.cfg.skill_hurt_add[self.level] then
return self.cfg.skill_hurt_add[self.level]
end
return 0
end
-- 获取攻击加成百分比
function EquipEntity:getAtkPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_ATTACK_ADD_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取生命值加成百分比
function EquipEntity:getHpPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_HP_ADD_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取暴击率百分比
function EquipEntity:getCritPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CRIT_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
--获取暴击伤害百分比
function EquipEntity:getCritHurtPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CRIT_TIME_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取治疗百分比
function EquipEntity:getHealPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_CURED_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取普攻增伤百分比
function EquipEntity:getNormalHurtPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_NORMAL_HURTP_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取技能增伤百分比
function EquipEntity:getSkillHurtPercent()
local attrs = self:getStageAttr()
if not attrs then
return 0
end
for index, attr in ipairs(attrs) do
if table.containValue(GConst.MATCH_SKILL_HURTP_NAME, attr.type) then
return attr.num // DEFAULT_FACTOR
end
end
return 0
end
-- 获取部位阶段等级
function EquipEntity:getStage()
for idx, level in pairs(self.cfg.features_level) do
if self.level < level then
return idx
end
end
return nil-- 超过最大阶段等级
end
-- 获取属性描述
function EquipEntity:getAttrDesc()
local strAttr = ""
local stage = self:getStage()
for i = 1, stage + 1 do
local level = self.cfg.features_level[i]
local attr = self.cfg.features_attr[i]
local str = I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_3) .. level .. ":".. GFunc.getAttrDesc(attr.type, attr.num)
if i < stage + 1 then
strAttr = "<color=#EEDFFF>" .. strAttr.. str .. "\n</color>"
else
strAttr = "<color=#9C94BE>" .. strAttr.. str .. "(" .. I18N:getGlobalText(I18N.GlobalConst.EQUIP_DESC_12) .. ")</color>"
end
end
return strAttr
end
-- 获取部位已获得属性
function EquipEntity:getStageAttr()
local stage = self:getStage()
if stage then
return self.cfg.features_attr[stage]
end
return nil
end
-- 获取部位图标id
function EquipEntity:getIconId()
local stage = self:getStage()
if stage then
return self.cfg.weapon_icon[stage]
end
return nil
end
-- 获取部位名称
function EquipEntity:getName()
local names = I18N:getText("equip", self:getId(), "name")
names = string.split(names, ",")
return names[self:getStage()] or ""
end
-- 获取部位当前等级
function EquipEntity:getLevel()
return self.level
end
-- 获取部位等级上限
function EquipEntity:getMaxLevel()
if self:getPart() == GConst.EquipConst.PART_TYPE.WEAPON then
-- 武器等级上限是玩家等级*2
return DataManager.PlayerData:getLv() * 2
else
-- 防具等级上限是当前英雄武器等级
return DataManager.EquipData:getEquip(self:getHeroId(), GConst.EquipConst.PART_TYPE.WEAPON):getLevel()
end
end
-- 部位是否可升级
function EquipEntity:canLevelUp()
--判断材料
if not self:isEnoughMaterial() then
return false
end
-- 判断金币
if not self:isEnoughGold() then
return false
end
-- 判断等级
if self:isMaxLevel() then
return false
end
return true
end
-- 升级材料是否满足
function EquipEntity:isEnoughMaterial()
for index, cost in ipairs(self:getUpgradeMaterials()) do
if cost.num > DataManager.BagData.ItemData:getItemNumById(cost.id) then
return false
end
end
return true
end
-- 升级金币是否满足
function EquipEntity:isEnoughGold()
return DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_GOLD) >= self:getUpgradeGoldNum()
end
-- 部位是否是最大等级
function EquipEntity:isMaxLevel()
return self:getLevel() >= self:getMaxLevel()
end
-- 获取部位上一等级实例
function EquipEntity:getLastLevelEntity()
if self:getLevel() == 0 then
return nil
end
return DataManager.EquipData:createEntity(self:getHeroId(), self:getPart(), self:getLevel() - 1)
end
-- 获取部位下一等级实例
function EquipEntity:getNextLevelEntity()
return DataManager.EquipData:createEntity(self:getHeroId(), self:getPart(), self:getLevel() + 1)
end
-- 获取部位升级所需材料和金币
function EquipEntity:getUpgradeCost()
local nextCost = ConfigManager:getConfig("equip_level")[self:getLevel() + 1]
if not nextCost then
return
end
local part = self:getPart()
if part == GConst.EquipConst.PART_TYPE.WEAPON then
return nextCost.weapon_cost
elseif part == GConst.EquipConst.PART_TYPE.HAT then
return nextCost.hat_cost
elseif part == GConst.EquipConst.PART_TYPE.CLOTHES then
return nextCost.clothes_cost
elseif part == GConst.EquipConst.PART_TYPE.BELT then
return nextCost.belt_cost
elseif part == GConst.EquipConst.PART_TYPE.HANDGUARD then
return nextCost.handguard_cost
end
end
-- 获取部位升级所需金币数
function EquipEntity:getUpgradeGoldNum()
local cost = self:getUpgradeCost()
if cost then
for key, value in pairs(cost) do
if GFunc.getRewardId(value) == GConst.ItemConst.ITEM_ID_GOLD then
return GFunc.getRewardNum(value)
end
end
end
return 0
end
-- 获取部位升级所需材料
function EquipEntity:getUpgradeMaterials()
local cost = self:getUpgradeCost()
local materials = {}
if cost then
for key, value in pairs(cost) do
if GFunc.getRewardId(value) ~= GConst.ItemConst.ITEM_ID_GOLD then
table.insert(materials, value)
end
end
end
return materials
end
-- 升级
function EquipEntity:onLevelUp()
self.level = self.level + 1
self:setDirty()
end
return EquipEntity

View File

@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 594ba474037adea439047897262342dc
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}

View File

@ -235,4 +235,40 @@ function HeroData:getAllHeroesBIStr()
return str
end
-- 获取所有英雄列表(等级>品质>id
function HeroData:getAllHeroesSort()
local result = {}
local heroCfg = ConfigManager:getConfig("hero")
for id, v in pairs(heroCfg) do
table.insert(result, {cfgId = id, sort = id, elementType = v.position})
end
for _, info in ipairs(result) do
local heroEntity = self:getHeroById(info.cfgId)
local sort = info.cfgId -- id 预留6位
sort = sort + (10 - info.elementType) * 1000000 -- 位置预留1位
sort = sort + 10000000 * heroEntity:getQlt() -- 品质1位
sort = sort + 100000000 * heroEntity:getLv() -- 预留3位
if heroEntity:isUnlock() then
sort = sort + 300000000000
if heroEntity:isActived() then
sort = sort + 400000000000
else
sort = sort + 300000000000
end
elseif DataManager.BagData.ItemData:getItemNumById(heroEntity:getFragmentId()) > 0 then
sort = sort + 200000000000
else
sort = sort + 100000000000
end
info.sort = sort
end
table.sort(result, function(a, b)
return a.sort > b.sort
end)
return result
end
return HeroData

View File

@ -2,28 +2,176 @@ local HeroEntity = class("HeroEntity", BaseData)
local ATTR_NAME = GConst.BattleConst.ATTR_NAME
function HeroEntity:ctor(cfgId, lv, collectionLevel)
self.id = cfgId
self.cfgId = cfgId
self.data.lv = lv
self.data.collectionLevel = collectionLevel
self.attrDirty = false
self.baseAttrDirty = false
self.equipAttrDirty = false
self.config = ConfigManager:getConfig("hero")[self.cfgId]
self.beginLv = self.config.begin_lv -- 初始等级
self.baseAttrOriginal = {}
self.allAttr = {}
self:initAttr()
self:updateAttr()
end
function HeroEntity:initAttr()
self:setAttrValue(ATTR_NAME.HP, 0)
self:setAttrValue(ATTR_NAME.ATK, 0)
self:setAttrValue(ATTR_NAME.ATK_RED, 0)
self:setAttrValue(ATTR_NAME.ATK_YELLOW, 0)
self:setAttrValue(ATTR_NAME.ATK_GREEN, 0)
self:setAttrValue(ATTR_NAME.ATK_BLUE, 0)
self:setAttrValue(ATTR_NAME.ATK_PURPLE, 0)
self.baseAttrOriginal = {}
self.equipAttr = {}
self.allAttr = {}
self:setTotalAttrValue(ATTR_NAME.HP, 0)
self:setTotalAttrValue(ATTR_NAME.ATK, 0)
self:setTotalAttrValue(ATTR_NAME.ATK_RED, 0)
self:setTotalAttrValue(ATTR_NAME.ATK_YELLOW, 0)
self:setTotalAttrValue(ATTR_NAME.ATK_GREEN, 0)
self:setTotalAttrValue(ATTR_NAME.ATK_BLUE, 0)
self:setTotalAttrValue(ATTR_NAME.ATK_PURPLE, 0)
self:setEquipAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], 0)
self:setEquipAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()], 0)
self:updateAllAttr()
end
function HeroEntity:setBaseAttrDirty()
self.baseAttrDirty = true
end
function HeroEntity:setEquipAttrDirty()
self.equipAttrDirty = true
end
function HeroEntity:getAllAttr()
if self.allAttr == nil then
self:initAttr()
end
local needUpdate = false
if self.baseAttrDirty == true then
needUpdate = true
self.baseAttrDirty = false
self:updateBaseAttr()
end
if self.equipAttrDirty == true then
needUpdate = true
self.equipAttrDirty = false
self:updateEquipAttr()
end
if needUpdate then
self:updateTotalAttr()
end
return self.allAttr
end
-- 更新所有属性
function HeroEntity:updateAllAttr()
self:updateBaseAttr()
self:updateEquipAttr()
self:updateTotalAttr()
end
-- 更新英雄基础属性
function HeroEntity:updateBaseAttr()
self.baseAttrOriginal[ATTR_NAME.HP] = self:getCfgHp()
self.baseAttrOriginal[ATTR_NAME.ATK_RED] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_YELLOW] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_GREEN] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_BLUE] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_PURPLE] = 0
self.baseAttrOriginal[GConst.MATCH_ATTACK_NAME[self.config.position]] = self:getCfgAtk()
end
-- 更新装备属性
function HeroEntity:updateEquipAttr()
local equips = DataManager.EquipData:getAllEquips()[self:getCfgId()]
if not equips then
return
end
local hp,atk,normalHurt,skillHurt,critPer,critHurtPer,normalHurtPer,skillHurtPer,healPer = 0
for part, equipEntity in pairs(equips) do
if equipEntity:getLevel() <= 0 then
return
end
hp = equipEntity:getHp()
atk = equipEntity:getAttack()
normalHurt = equipEntity:getNormalHurt()
skillHurt = equipEntity:getSkillHurt()
critPer = equipEntity:getCritPercent()
critHurtPer = equipEntity:getCritHurtPercent()
normalHurtPer = equipEntity:getNormalHurtPercent()
skillHurtPer = equipEntity:getSkillHurtPercent()
healPer = equipEntity:getHealPercent()
self:addEquipAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()], hp)
self:addEquipAttrValue(GConst.MATCH_ATTACK_NAME[self:getMatchType()], atk)
self:addEquipAttrValue(GConst.MATCH_NORMAL_HURT_NAME[self:getMatchType()], normalHurt)
self:addEquipAttrValue(GConst.MATCH_SKILL_HURT_NAME[self:getMatchType()], skillHurt)
self:addEquipAttrValue(GConst.MATCH_CRIT_NAME[self:getMatchType()], critPer)
self:addEquipAttrValue(GConst.MATCH_CRIT_TIME_NAME[self:getMatchType()], critHurtPer)
self:addEquipAttrValue(GConst.MATCH_NORMAL_HURTP_NAME[self:getMatchType()], normalHurtPer)
self:addEquipAttrValue(GConst.MATCH_SKILL_HURTP_NAME[self:getMatchType()], skillHurtPer)
self:addEquipAttrValue(GConst.MATCH_CURED_NAME[self:getMatchType()], healPer)
if EDITOR_MODE then
local printStr = ""
printStr = printStr .. "更新装备数值:"..self:getCfgId().."-"..part .. "\n"
printStr = printStr .. "生命:".. hp .. "\n"
printStr = printStr .. "攻击力:".. atk .. "\n"
printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
printStr = printStr .. "技能增伤:".. skillHurt .. "\n"
printStr = printStr .. "暴击率:".. critPer .. "\n"
printStr = printStr .. "暴击伤害百分比:".. critHurtPer .. "\n"
printStr = printStr .. "普攻增伤百分比:".. normalHurtPer .. "\n"
printStr = printStr .. "技能增伤百分比:".. skillHurtPer .. "\n"
printStr = printStr .. "治疗加成百分比:".. healPer .. "\n"
Logger.logHighlight(printStr)
end
end
end
function HeroEntity:setEquipAttrValue(name, value)
self.equipAttr[name] = value
end
function HeroEntity:addEquipAttrValue(name, value)
self.equipAttr[name] = self.equipAttr[name] + value
end
-- 更新总属性
function HeroEntity:updateTotalAttr()
for k, v in pairs(self.baseAttrOriginal) do
self:setTotalAttrValue(k, v)
end
for k, v in pairs(self.equipAttr) do
self:addTotalAttrValue(k, v)
end
end
function HeroEntity:setTotalAttrValue(name, value)
self.allAttr[name] = GFunc.encryptNumber(value or 0)
end
function HeroEntity:addTotalAttrValue(name, add)
-- Logger.logHighlight("add "..name..":"..add)
local before = self:getTotalAttrValue(name)
self.allAttr[name] = GFunc.encryptNumber(before + add or 0)
end
function HeroEntity:getTotalAttrValue(name)
if self.allAttr == nil then
self:initAttr()
end
if not self.allAttr[name] then
return 0
end
-- Logger.logHighlight("get "..name..":"..GFunc.decryptNumber(self.allAttr[name]))
return GFunc.decryptNumber(self.allAttr[name])
end
function HeroEntity:setLv(lv)
@ -35,7 +183,7 @@ function HeroEntity:setLv(lv)
end
self.data.lv = lv
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_HERO_LV_UP, lv)
self:setDirty()
self:setAttrDirty()
end
function HeroEntity:getCfgId()
@ -46,16 +194,6 @@ function HeroEntity:getLv()
return self.data.lv
end
-- 获取英雄已领取图鉴点数的等级
function HeroEntity:getCollectionLevel()
return self.data.collectionLevel
end
-- 更新英雄图鉴已领取等级
function HeroEntity:updateCollectionLevel()
self.data.collectionLevel = self:getLv()
end
function HeroEntity:getQlt()
return self.config.qlt
end
@ -68,38 +206,21 @@ function HeroEntity:getMatchType()
return self.config.position
end
-- 获取英雄已领取图鉴点数的等级
function HeroEntity:getCollectionLevel()
return self.data.collectionLevel
end
-- 更新英雄图鉴已领取等级
function HeroEntity:updateCollectionLevel()
self.data.collectionLevel = self:getLv()
end
-- 英雄每级可领取图鉴点数
function HeroEntity:getCollectionPoint()
return self.config.collection_point
end
function HeroEntity:setAttrDirty()
self.attrDirty = true
end
function HeroEntity:getAllAttr()
if self.attrDirty == true then
self.attrDirty = false
self:updateAttr()
end
return self.allAttr
end
function HeroEntity:updateAttr()
self:updateBaseAttr()
self:updateAllAttr()
end
function HeroEntity:updateBaseAttr()
self.baseAttrOriginal[ATTR_NAME.HP] = self:getCfgHp()
self.baseAttrOriginal[ATTR_NAME.ATK_RED] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_YELLOW] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_GREEN] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_BLUE] = 0
self.baseAttrOriginal[ATTR_NAME.ATK_PURPLE] = 0
self.baseAttrOriginal[GConst.MATCH_ATTACK_NAME[self.config.position]] = self:getCfgAtk()
end
function HeroEntity:getCfgHp(lv)
lv = lv or self.data.lv
if lv > self:getMaxLv() then
@ -132,36 +253,16 @@ function HeroEntity:getIsShowUnlcokChapter()
return self.config.is_show == 1
end
function HeroEntity:updateAllAttr()
for k, v in pairs(self.baseAttrOriginal) do
self:setAttrValue(k, v)
end
end
function HeroEntity:setAttrValue(name, value)
self.allAttr[name] = GFunc.encryptNumber(value or 0)
end
function HeroEntity:getAttrValue(name)
if not self.allAttr[name] then
return 0
end
return GFunc.decryptNumber(self.allAttr[name])
end
function HeroEntity:getAtk()
local atkAddName = GConst.MATCH_ATTACK_ADD_NAME[self:getMatchType()]
local atkName = GConst.MATCH_ATTACK_NAME[self:getMatchType()]
return self:getAttrValue(atkName) + self:getAttrValue(atkAddName)
local atkAddName = GConst.MATCH_ATTACK_ADD_NAME[self:getMatchType()]
return self:getTotalAttrValue(atkName) + self:getTotalAttrValue(atkAddName)
end
function HeroEntity:getHp()
local atkAddName = GConst.MATCH_HP_ADD_NAME[self:getMatchType()]
return self:getAttrValue(GConst.BattleConst.ATTR_NAME.HP) + self:getAttrValue(atkAddName)
end
function HeroEntity:setDirty()
self.attrDirty = true
local hpName = GConst.MATCH_HP_NAME[self:getMatchType()]
local hpAddName = GConst.MATCH_HP_ADD_NAME[self:getMatchType()]
return self:getTotalAttrValue(hpName) + self:getTotalAttrValue(hpAddName)
end
function HeroEntity:isMaxLv()
@ -310,4 +411,32 @@ function HeroEntity:getActiveRogueSkills()
return list
end
-- 获取总基础生命值(英雄+装备)
function HeroEntity:getTotalBaseHp()
local result = 0
result = result + self:getTotalAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()])
-- 武器
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON):getBaseHp()
-- 防具
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HAT):getBaseHp()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.CLOTHES):getBaseHp()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.BELT):getBaseHp()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HANDGUARD):getBaseHp()
return result
end
-- 获取总基础攻击值(英雄+装备)
function HeroEntity:getTotalBaseAtk()
local result = 0
result = result + self:getTotalAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()])
-- 武器
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON):getBaseAttack()
-- 防具
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HAT):getBaseAttack()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.CLOTHES):getBaseAttack()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.BELT):getBaseAttack()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HANDGUARD):getBaseAttack()
return result
end
return HeroEntity