英雄属性bug修复,查看其他玩家信息时带入装备信息

This commit is contained in:
xiekaidong 2023-07-22 18:15:46 +08:00
parent e429f716c7
commit b1df62d3a4
17 changed files with 166 additions and 109 deletions

View File

@ -1768,4 +1768,41 @@ function GFunc.formatPlayerName(name)
return name return name
end end
-- info = {array_heroes, heroes_equips} -- 服务器返回的数据
function GFunc.formatPlayerFormationInfo(info)
local formation = {}
if not info.array_heroes then
return formation
end
for index, info in ipairs(info.array_heroes) do
if DataManager.HeroData:isExistHeroById(info.id) then
local heroEntity = DataManager.HeroData:getEntity(info)
formation[heroEntity:getMatchType()] = heroEntity
end
end
-- 处理装备
if not info.heroes_equips then
info.heroes_equips = {}
end
for matchType, heroEntity in pairs(formation) do
local heroId = heroEntity:getCfgId()
local equipInfo = info.heroes_equips[heroId]
local equips = {}
if not equipInfo then
equipInfo = {equips = {}}
end
for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
local level = equipInfo.equips[partType] or 0
local equipEntity = DataManager.EquipData:createEntity(heroId, partType, level)
equips[partType] = equipEntity
equipEntity:setHeroEntity(heroEntity)
end
heroEntity:setEquips(equips)
end
return formation
end
return GFunc return GFunc

View File

@ -74,35 +74,26 @@ end
function ArenaManager:rspChallenge(result) function ArenaManager:rspChallenge(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
local atkFormation = result.array_heroes local atkFormation = {}
local defFormation local defFormation
if result.reqData and result.reqData.defInfo then if result.reqData and result.reqData.defInfo then
defFormation = result.reqData.defInfo.array_heroes defFormation = GFunc.formatPlayerFormationInfo(result.reqData.defInfo)
else else
return return
end end
for idx, id in pairs(DataManager.FormationData:getArenaAttackFormation()) do
local hero = DataManager.HeroData:getHeroById(id)
if hero then
atkFormation[idx] = hero
end
end
local params = { local params = {
defInfo = result.reqData.defInfo, defInfo = result.reqData.defInfo,
atkFormation = {}, atkFormation = atkFormation,
defFormation = {} defFormation = defFormation
} }
for _, heroInfo in ipairs(atkFormation) do
if heroInfo.id > 0 then
local heroEntity = DataManager.HeroData:getEntity(heroInfo)
if heroEntity then
params.atkFormation[heroEntity:getMatchType()] = heroEntity
end
end
end
for _, heroInfo in ipairs(defFormation) do
if heroInfo.id > 0 then
local heroEntity = DataManager.HeroData:getEntity(heroInfo)
if heroEntity then
params.defFormation[heroEntity:getMatchType()] = heroEntity
end
end
end
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.ARENA, params) ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.ARENA, params)
--bi上报 --bi上报
@ -177,7 +168,7 @@ end
function ArenaManager:rspRankHeroes(result) function ArenaManager:rspRankHeroes(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.ArenaData:onRankFormationReceived(result.reqData.rid, result.array_heroes) DataManager.ArenaData:onRankFormationReceived(result.reqData.rid, result)
end end
end end

View File

@ -108,7 +108,7 @@ function TipsManager:showHeroFragmentTips(itemId)
UIManager:showUI("app/ui/tips/hero_fragment_tips", params) UIManager:showUI("app/ui/tips/hero_fragment_tips", params)
end end
-- formation = {{id = 000, level = 000}, {id = 000, level = 000}, ...} -- formation = {heroEntity, ...}
function TipsManager:showHeroFormation(targetObj, formation) function TipsManager:showHeroFormation(targetObj, formation)
local tarCornerScreenPos, location = self:getCornerScreenPosition(targetObj, TipsManager.ALIGN_TYPE.BOTTOM_CENTER) local tarCornerScreenPos, location = self:getCornerScreenPosition(targetObj, TipsManager.ALIGN_TYPE.BOTTOM_CENTER)
location = TipsManager.ALIGN_TYPE.CUSTOM location = TipsManager.ALIGN_TYPE.CUSTOM

View File

@ -165,6 +165,7 @@ function NetManager:connect(domain, port, callback, socketName)
CS.BF.BFMain.Instance.NetMgr:AddLuaOnReconnectSuccess(function(name) CS.BF.BFMain.Instance.NetMgr:AddLuaOnReconnectSuccess(function(name)
Logger.log("[NetManager]reconnect succes:%s", name) Logger.log("[NetManager]reconnect succes:%s", name)
self.isSending = false
self:trySend() self:trySend()
if name == NetManager.MAIN_SOCKET_NAME then if name == NetManager.MAIN_SOCKET_NAME then
if self.reconnectMainId then if self.reconnectMainId then

View File

@ -177,7 +177,7 @@ function ArenaMatchUI:showMatchResult()
self.matchTxName:setText(name) self.matchTxName:setText(name)
self.matchTxLevel:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, matchInfo.level)) self.matchTxLevel:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, matchInfo.level))
self.matchGrading:refresh(DataManager.ArenaData:getGradingIdFromScore(matchInfo.score)) self.matchGrading:refresh(DataManager.ArenaData:getGradingIdFromScore(matchInfo.score))
self.matchHeroFormationComp:refreshBriefInfo(matchInfo.array_heroes) self.matchHeroFormationComp:refreshByEntitys(GFunc.formatPlayerFormationInfo(matchInfo))
self.selfAvatar:refresh() self.selfAvatar:refresh()
self.selfTxName:setText(DataManager.PlayerData:getNickname()) self.selfTxName:setText(DataManager.PlayerData:getNickname())
@ -191,12 +191,12 @@ function ArenaMatchUI:showMatchResult()
local hero = DataManager.HeroData:getHeroById(id) local hero = DataManager.HeroData:getHeroById(id)
if hero then if hero then
formation[idx] = {id = id, level = hero:getLv()} formation[idx] = hero
else else
formation[idx] = nil formation[idx] = nil
end end
end end
self.selfHeroFormationComp:refreshBriefInfo(formation) self.selfHeroFormationComp:refreshByEntitys(formation)
-- 对手存在倒计时 -- 对手存在倒计时
self.matchExistCd = DataManager.ArenaData:getMatchExistRemainTime() self.matchExistCd = DataManager.ArenaData:getMatchExistRemainTime()

View File

@ -83,7 +83,7 @@ function ArenaRecentBattleUI:refreshRecord(obj, info)
local playerHeadCell = CellManager:addCellComp(uiMap["player_head_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_HEAD_CELL) local playerHeadCell = CellManager:addCellComp(uiMap["player_head_cell"], GConst.TYPEOF_LUA_CLASS.PLAYER_HEAD_CELL)
playerHeadCell:refresh(info.match_info.avatar, info.match_info.avatar_frame) playerHeadCell:refresh(info.match_info.avatar, info.match_info.avatar_frame)
uiMap["player_head_cell"]:addClickListener(function() uiMap["player_head_cell"]:addClickListener(function()
ModuleManager.TipsManager:showHeroFormation(uiMap["player_head_cell"], info.match_info.array_heroes) ModuleManager.TipsManager:showHeroFormation(uiMap["player_head_cell"], GFunc.formatPlayerFormationInfo(info.match_info))
end) end)
local name = info.match_info.name local name = info.match_info.name
if name == nil or #name == 0 then if name == nil or #name == 0 then

View File

@ -62,7 +62,8 @@ end
function ArenaRankCell:showHeroFormationTips() function ArenaRankCell:showHeroFormationTips()
self.clickFormation = false self.clickFormation = false
ModuleManager.TipsManager:showHeroFormation(self.btnFormation, DataManager.ArenaData:getRankFormation(self.rankInfo.ID)) local result = DataManager.ArenaData:getRankFormation(self.rankInfo.ID)
ModuleManager.TipsManager:showHeroFormation(self.btnFormation, GFunc.formatPlayerFormationInfo(result))
end end
return ArenaRankCell return ArenaRankCell

View File

@ -11,7 +11,7 @@ function PlayerRecordCell:refresh(info)
uiMap["player_record_cell.tx_name"]:setText(GFunc.formatPlayerName(info.name)) uiMap["player_record_cell.tx_name"]:setText(GFunc.formatPlayerName(info.name))
uiMap["player_record_cell.btn_formation.tx_formation"]:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_WEAPON_DESC_14)) uiMap["player_record_cell.btn_formation.tx_formation"]:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_WEAPON_DESC_14))
uiMap["player_record_cell.btn_formation"]:addClickListener(function() uiMap["player_record_cell.btn_formation"]:addClickListener(function()
ModuleManager.TipsManager:showHeroFormation(uiMap["player_record_cell.btn_formation"], info.array_heroes) ModuleManager.TipsManager:showHeroFormation(uiMap["player_record_cell.btn_formation"], GFunc.formatPlayerFormationInfo(info))
end) end)
end end

View File

@ -54,16 +54,14 @@ function HeroFormationComp:refreshByFormation(formation)
end end
end end
-- 显示英雄等级/名称/品级信息 function HeroFormationComp:refreshByEntitys(formation)
-- formation = {{id = 000, level=000},{id = 000, level=000}, ...}
function HeroFormationComp:refreshBriefInfo(formation)
for i, heroCell in ipairs(self.heroCells) do for i, heroCell in ipairs(self.heroCells) do
if formation[i] and DataManager.HeroData:isExistHeroById(formation[i].id) then local heroEntity = formation[i]
if heroEntity then
heroCell:setVisible(true, 1) heroCell:setVisible(true, 1)
heroCell:refreshBriefInfo(formation[i].id, formation[i].level) heroCell:refreshBriefInfo(heroEntity:getCfgId(), heroEntity:getLv())
heroCell:addClickListener(function() heroCell:addClickListener(function()
local heroEntity = DataManager.HeroData:getEntity(formation[i]) ModuleManager.HeroManager:showHeroDetailUI(heroEntity:getCfgId(), true, heroEntity)
ModuleManager.HeroManager:showHeroDetailUI(formation[i].id, true, heroEntity)
end) end)
else else
heroCell:setVisible(false) heroCell:setVisible(false)

View File

@ -77,14 +77,14 @@ function ArmorInfoComp:refreshSelectArmor()
local armorEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), self.selectPart) local armorEntity = DataManager.EquipData:getEquip(self.heroEntity:getCfgId(), self.selectPart)
self.txCurName:setText(armorEntity:getName()) self.txCurName:setText(armorEntity:getName())
self.imgCurBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorEntity:getStage()) self.imgCurBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorEntity:getStage())
-- self.imgCurIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorEntity:getIconId()) -- self.imgCurIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(armorEntity:getIconId()))
self.txCurLevel:setText("+".. armorEntity:getLevel()) self.txCurLevel:setText("+".. armorEntity:getLevel())
-- next -- next
local armorNextEntity = armorEntity:getNextLevelEntity() local armorNextEntity = armorEntity:getNextLevelEntity()
self.txNextName:setText(armorNextEntity:getName()) self.txNextName:setText(armorNextEntity:getName())
self.imgNextBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorNextEntity:getStage()) self.imgNextBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. armorNextEntity:getStage())
-- self.imgNextIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorNextEntity:getIconId()) -- self.imgNextIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(armorNextEntity:getIconId()))
self.txNextLevel:setText("+".. armorNextEntity:getLevel()) self.txNextLevel:setText("+".. armorNextEntity:getLevel())
-- 基础属性 -- 基础属性
@ -143,7 +143,7 @@ function ArmorInfoComp:refreshSelectArmor()
else else
num:setText(haveNum .. "/" .. costNum) num:setText(haveNum .. "/" .. costNum)
end end
-- icon:setSprite(GFunc.getIconRes(costId)) icon:setSprite(GFunc.getIconRes(costId))
else else
costNode:setActive(false) costNode:setActive(false)
end end
@ -182,7 +182,7 @@ function ArmorInfoComp:refreshPart(index)
imgSelect:setActive(part == self.selectPart) imgSelect:setActive(part == self.selectPart)
imgSelect:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_select_" .. math.floor(stage / 2) + stage % 2) imgSelect:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_select_" .. math.floor(stage / 2) + stage % 2)
imgBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. stage) imgBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. stage)
-- imgIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, armorEntity:getIconId()) -- imgIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(armorEntity:getIconId()))
imgType:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, stage <= 1 and "frame_dec_1" or "frame_dec_2") imgType:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, stage <= 1 and "frame_dec_1" or "frame_dec_2")
txLevel:setText("+".. armorEntity:getLevel()) txLevel:setText("+".. armorEntity:getLevel())
end end

View File

@ -9,13 +9,13 @@ function AttrCell:init()
self.txValue = uiMap["attr_cell.tx_value"] self.txValue = uiMap["attr_cell.tx_value"]
end end
function AttrCell:refresh(heroId, nodeType, attrType) function AttrCell:refresh(heroEntity, nodeType, attrType)
self.heroEntity = DataManager.HeroData:getHeroById(heroId) self.heroEntity = heroEntity
self.weaponEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.WEAPON) self.weaponEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON)
self.hatEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.HAT) self.hatEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT)
self.clothesEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.CLOTHES) self.clothesEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES)
self.beltEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.BELT) self.beltEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT)
self.handguardEntity = DataManager.EquipData:getEquip(heroId, GConst.EquipConst.PART_TYPE.HANDGUARD) self.handguardEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD)
self.nodeType = nodeType self.nodeType = nodeType
self.attrName = attrType[self.heroEntity:getMatchType()] self.attrName = attrType[self.heroEntity:getMatchType()]

View File

@ -9,7 +9,7 @@ function AttrNodeCell:init()
self.itemsRoot = uiMap["total_node.items"] self.itemsRoot = uiMap["total_node.items"]
end end
function AttrNodeCell:refresh(heroId, 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
@ -24,7 +24,7 @@ function AttrNodeCell:refresh(heroId, node)
for index, attr in ipairs(node) do for index, attr in ipairs(node) do
CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell) CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell)
cell:refresh(heroId, node, attr) cell:refresh(heroEntity, node, attr)
end) end)
end end
end end

View File

@ -23,7 +23,7 @@ function HeroAttrUI:onClose()
end end
function HeroAttrUI:ctor(parmas) function HeroAttrUI:ctor(parmas)
self.heroId = parmas self.heroEntity = parmas.heroEntity
end end
function HeroAttrUI:onLoadRootComplete() function HeroAttrUI:onLoadRootComplete()
@ -47,7 +47,7 @@ function HeroAttrUI:onRefresh()
local nodeHeight = math.ceil(#node / 2) * ATTR_CELL_HEIGHT + (math.ceil(#node / 2) - 1) * ATTR_CELL_SPACING_Y + ATTR_CELLS_PADDING 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:setLocalPositionY(-totalHeight)
cell.baseObject:setSizeDeltaY(nodeHeight) cell.baseObject:setSizeDeltaY(nodeHeight)
cell:refresh(self.heroId, node) cell:refresh(self.heroEntity, node)
totalHeight = totalHeight + nodeHeight totalHeight = totalHeight + nodeHeight
self.rootNodes:setSizeDeltaY(totalHeight) self.rootNodes:setSizeDeltaY(totalHeight)
end) end)

View File

@ -50,7 +50,7 @@ function HeroInfoComp:init()
ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity) ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity)
end) end)
self.btnAttr:addClickListener(function() self.btnAttr:addClickListener(function()
UIManager:showUI("app/ui/hero/hero_attr_ui", self.heroEntity:getCfgId()) UIManager:showUI("app/ui/hero/hero_attr_ui", {heroEntity = self.heroEntity})
end) end)
end end

View File

@ -30,7 +30,7 @@ function FormationTips:onLoadRootComplete()
self.originAnchoredPosition = tipsBgTransform.anchoredPosition self.originAnchoredPosition = tipsBgTransform.anchoredPosition
self.originLocalPosition = tipsBgTransform.localPosition self.originLocalPosition = tipsBgTransform.localPosition
self.heroFormation:refreshBriefInfo(self.formation) self.heroFormation:refreshByEntitys(self.formation)
end end
function FormationTips:onRefresh() function FormationTips:onRefresh()

View File

@ -4,6 +4,7 @@ local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR
function EquipEntity:ctor(heroId, part, level) function EquipEntity:ctor(heroId, part, level)
self.level = level or 0 self.level = level or 0
self.heroEntity = nil
self.cfg, self.cfgId = table.find(ConfigManager:getConfig("equip"), function(value) self.cfg, self.cfgId = table.find(ConfigManager:getConfig("equip"), function(value)
return value.hero == heroId and value.part == part return value.hero == heroId and value.part == part
end) end)
@ -39,7 +40,7 @@ end
-- 获取部位加成后生命值 -- 获取部位加成后生命值
function EquipEntity:getHp() function EquipEntity:getHp()
local result = self:getBaseHp() local result = self:getBaseHp()
result = result + DataManager.HeroData:getHeroById(self:getHeroId()):getTotalBaseHp() * self:getHpPercent() // DEFAULT_FACTOR result = result + self:getHeroEntity():getTotalBaseHp() * self:getHpPercent() // DEFAULT_FACTOR
return result return result
end end
@ -54,7 +55,7 @@ end
-- 获取部位加成后攻击力 -- 获取部位加成后攻击力
function EquipEntity:getAttack() function EquipEntity:getAttack()
local result = self:getBaseAttack() local result = self:getBaseAttack()
result = result + DataManager.HeroData:getHeroById(self:getHeroId()):getTotalBaseAtk() * self:getAtkPercent() // DEFAULT_FACTOR result = result + self:getHeroEntity():getTotalBaseAtk() * self:getAtkPercent() // DEFAULT_FACTOR
return result return result
end end
@ -348,4 +349,16 @@ function EquipEntity:onLevelUp()
self:setDirty() self:setDirty()
end end
function EquipEntity:setHeroEntity(heroEntity)
self.heroEntity = heroEntity
end
function EquipEntity:getHeroEntity()
if self.heroEntity then
return self.heroEntity
end
return DataManager.HeroData:getHeroById(self:getHeroId())
end
return EquipEntity return EquipEntity

View File

@ -75,17 +75,17 @@ end
-- 更新装备属性 -- 更新装备属性
function HeroEntity:updateEquipAttr() function HeroEntity:updateEquipAttr()
local equips = DataManager.EquipData:getAllEquips()[self:getCfgId()] if self.equipAttr then --更新前删除以前的,因为方法应该为覆盖数值
if not equips then for attrName, value in pairs(self.equipAttr) do
return self.equipAttr[attrName] = 0
end
end end
local hp,atk,normalHurt,skillHurt,critPer,critHurtPer,normalHurtPer,skillHurtPer,healPer = 0 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
for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
local equipEntity = self:getEquips(partType)
if equipEntity then
hp = equipEntity:getHp() hp = equipEntity:getHp()
atk = equipEntity:getAttack() atk = equipEntity:getAttack()
normalHurt = equipEntity:getNormalHurt() normalHurt = equipEntity:getNormalHurt()
@ -108,7 +108,7 @@ function HeroEntity:updateEquipAttr()
if EDITOR_MODE then if EDITOR_MODE then
local printStr = "" local printStr = ""
printStr = printStr .. "更新装备数值:"..self:getCfgId().."-"..part .. "\n" printStr = printStr .. "更新装备数值:"..self:getCfgId().."-".. partName .. "\n"
printStr = printStr .. "生命:".. hp .. "\n" printStr = printStr .. "生命:".. hp .. "\n"
printStr = printStr .. "攻击力:".. atk .. "\n" printStr = printStr .. "攻击力:".. atk .. "\n"
printStr = printStr .. "普攻增伤:".. normalHurt .. "\n" printStr = printStr .. "普攻增伤:".. normalHurt .. "\n"
@ -122,6 +122,7 @@ function HeroEntity:updateEquipAttr()
end end
end end
end end
end
function HeroEntity:setEquipAttrValue(name, value) function HeroEntity:setEquipAttrValue(name, value)
self.equipAttr[name] = value self.equipAttr[name] = value
@ -404,13 +405,13 @@ end
function HeroEntity:getTotalBaseHp() function HeroEntity:getTotalBaseHp()
local result = 0 local result = 0
result = result + self:getTotalAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()]) result = result + self:getTotalAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()])
-- 武器 -- 武器 + 防具
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON):getBaseHp() for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
-- 防具 local equipEntity = self:getEquips(partType)
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HAT):getBaseHp() if equipEntity then
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.CLOTHES):getBaseHp() result = result + equipEntity:getBaseHp()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.BELT):getBaseHp() end
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HANDGUARD):getBaseHp() end
return result return result
end end
@ -418,14 +419,29 @@ end
function HeroEntity:getTotalBaseAtk() function HeroEntity:getTotalBaseAtk()
local result = 0 local result = 0
result = result + self:getTotalAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()]) result = result + self:getTotalAttrValue(GConst.MATCH_HP_NAME[self:getMatchType()])
-- 武器 -- 武器 + 防具
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.WEAPON):getBaseAttack() for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do
-- 防具 local equipEntity = self:getEquips(partType)
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HAT):getBaseAttack() if equipEntity then
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.CLOTHES):getBaseAttack() result = result + equipEntity:getBaseAttack()
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.BELT):getBaseAttack() end
result = result + DataManager.EquipData:getEquip(self:getCfgId(), GConst.EquipConst.PART_TYPE.HANDGUARD):getBaseAttack() end
return result return result
end end
-- {partType = EquipEntity}
function HeroEntity:setEquips(equipEntities)
self.equipEntities = equipEntities
self:getTotalAttrValue() -- 防止报错
self:onEquipAttrChange()
end
function HeroEntity:getEquips(partType)
if self.equipEntities then
return self.equipEntities[partType]
end
return DataManager.EquipData:getEquip(self:getCfgId(), partType)
end
return HeroEntity return HeroEntity