diff --git a/lua/app/global/global_func.lua b/lua/app/global/global_func.lua index 60722256..fef8def8 100644 --- a/lua/app/global/global_func.lua +++ b/lua/app/global/global_func.lua @@ -1768,4 +1768,41 @@ function GFunc.formatPlayerName(name) return name 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 \ No newline at end of file diff --git a/lua/app/module/arena/arena_manager.lua b/lua/app/module/arena/arena_manager.lua index 7021b839..82cec391 100644 --- a/lua/app/module/arena/arena_manager.lua +++ b/lua/app/module/arena/arena_manager.lua @@ -74,35 +74,26 @@ end function ArenaManager:rspChallenge(result) if result.err_code == GConst.ERROR_STR.SUCCESS then - local atkFormation = result.array_heroes + local atkFormation = {} local defFormation if result.reqData and result.reqData.defInfo then - defFormation = result.reqData.defInfo.array_heroes + defFormation = GFunc.formatPlayerFormationInfo(result.reqData.defInfo) else return 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 = { defInfo = result.reqData.defInfo, - atkFormation = {}, - defFormation = {} + atkFormation = atkFormation, + 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) --bi上报 @@ -177,7 +168,7 @@ end function ArenaManager:rspRankHeroes(result) 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 diff --git a/lua/app/module/tips/tips_manager.lua b/lua/app/module/tips/tips_manager.lua index 8c9d714a..53e5b591 100644 --- a/lua/app/module/tips/tips_manager.lua +++ b/lua/app/module/tips/tips_manager.lua @@ -108,7 +108,7 @@ function TipsManager:showHeroFragmentTips(itemId) UIManager:showUI("app/ui/tips/hero_fragment_tips", params) end --- formation = {{id = 000, level = 000}, {id = 000, level = 000}, ...} +-- formation = {heroEntity, ...} function TipsManager:showHeroFormation(targetObj, formation) local tarCornerScreenPos, location = self:getCornerScreenPosition(targetObj, TipsManager.ALIGN_TYPE.BOTTOM_CENTER) location = TipsManager.ALIGN_TYPE.CUSTOM diff --git a/lua/app/net/net_manager.lua b/lua/app/net/net_manager.lua index 24e53f1e..e4b9bc97 100644 --- a/lua/app/net/net_manager.lua +++ b/lua/app/net/net_manager.lua @@ -165,6 +165,7 @@ function NetManager:connect(domain, port, callback, socketName) CS.BF.BFMain.Instance.NetMgr:AddLuaOnReconnectSuccess(function(name) Logger.log("[NetManager]reconnect succes:%s", name) + self.isSending = false self:trySend() if name == NetManager.MAIN_SOCKET_NAME then if self.reconnectMainId then diff --git a/lua/app/ui/arena/arena_match_ui.lua b/lua/app/ui/arena/arena_match_ui.lua index 5954d262..9006e39f 100644 --- a/lua/app/ui/arena/arena_match_ui.lua +++ b/lua/app/ui/arena/arena_match_ui.lua @@ -177,7 +177,7 @@ function ArenaMatchUI:showMatchResult() self.matchTxName:setText(name) self.matchTxLevel:setText(I18N:getGlobalText(I18N.GlobalConst.HERO_DESC_1, matchInfo.level)) self.matchGrading:refresh(DataManager.ArenaData:getGradingIdFromScore(matchInfo.score)) - self.matchHeroFormationComp:refreshBriefInfo(matchInfo.array_heroes) + self.matchHeroFormationComp:refreshByEntitys(GFunc.formatPlayerFormationInfo(matchInfo)) self.selfAvatar:refresh() self.selfTxName:setText(DataManager.PlayerData:getNickname()) @@ -191,12 +191,12 @@ function ArenaMatchUI:showMatchResult() local hero = DataManager.HeroData:getHeroById(id) if hero then - formation[idx] = {id = id, level = hero:getLv()} + formation[idx] = hero else formation[idx] = nil end end - self.selfHeroFormationComp:refreshBriefInfo(formation) + self.selfHeroFormationComp:refreshByEntitys(formation) -- 对手存在倒计时 self.matchExistCd = DataManager.ArenaData:getMatchExistRemainTime() diff --git a/lua/app/ui/arena/arena_recent_battle_ui.lua b/lua/app/ui/arena/arena_recent_battle_ui.lua index cf7db44a..83ca059d 100644 --- a/lua/app/ui/arena/arena_recent_battle_ui.lua +++ b/lua/app/ui/arena/arena_recent_battle_ui.lua @@ -83,7 +83,7 @@ function ArenaRecentBattleUI:refreshRecord(obj, info) 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) 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) local name = info.match_info.name if name == nil or #name == 0 then diff --git a/lua/app/ui/arena/cell/arena_rank_cell.lua b/lua/app/ui/arena/cell/arena_rank_cell.lua index c2120040..948bdc8c 100644 --- a/lua/app/ui/arena/cell/arena_rank_cell.lua +++ b/lua/app/ui/arena/cell/arena_rank_cell.lua @@ -62,7 +62,8 @@ end function ArenaRankCell:showHeroFormationTips() 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 return ArenaRankCell \ No newline at end of file diff --git a/lua/app/ui/common/cell/player_record_cell.lua b/lua/app/ui/common/cell/player_record_cell.lua index 8c63522e..b846ab2b 100644 --- a/lua/app/ui/common/cell/player_record_cell.lua +++ b/lua/app/ui/common/cell/player_record_cell.lua @@ -11,7 +11,7 @@ function PlayerRecordCell:refresh(info) 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"]: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 diff --git a/lua/app/ui/common/component/hero_formation_comp.lua b/lua/app/ui/common/component/hero_formation_comp.lua index fda66a08..db92912b 100644 --- a/lua/app/ui/common/component/hero_formation_comp.lua +++ b/lua/app/ui/common/component/hero_formation_comp.lua @@ -54,16 +54,14 @@ function HeroFormationComp:refreshByFormation(formation) end end --- 显示英雄等级/名称/品级信息 --- formation = {{id = 000, level=000},{id = 000, level=000}, ...} -function HeroFormationComp:refreshBriefInfo(formation) +function HeroFormationComp:refreshByEntitys(formation) 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:refreshBriefInfo(formation[i].id, formation[i].level) + heroCell:refreshBriefInfo(heroEntity:getCfgId(), heroEntity:getLv()) heroCell:addClickListener(function() - local heroEntity = DataManager.HeroData:getEntity(formation[i]) - ModuleManager.HeroManager:showHeroDetailUI(formation[i].id, true, heroEntity) + ModuleManager.HeroManager:showHeroDetailUI(heroEntity:getCfgId(), true, heroEntity) end) else heroCell:setVisible(false) diff --git a/lua/app/ui/hero/armor_info_comp.lua b/lua/app/ui/hero/armor_info_comp.lua index 05998084..8367501f 100644 --- a/lua/app/ui/hero/armor_info_comp.lua +++ b/lua/app/ui/hero/armor_info_comp.lua @@ -77,14 +77,14 @@ function ArmorInfoComp:refreshSelectArmor() 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.imgCurIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(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.imgNextIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(armorNextEntity:getIconId())) self.txNextLevel:setText("+".. armorNextEntity:getLevel()) -- 基础属性 @@ -143,7 +143,7 @@ function ArmorInfoComp:refreshSelectArmor() else num:setText(haveNum .. "/" .. costNum) end - -- icon:setSprite(GFunc.getIconRes(costId)) + icon:setSprite(GFunc.getIconRes(costId)) else costNode:setActive(false) end @@ -182,7 +182,7 @@ function ArmorInfoComp:refreshPart(index) 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()) + -- 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") txLevel:setText("+".. armorEntity:getLevel()) end diff --git a/lua/app/ui/hero/cell/attr_cell.lua b/lua/app/ui/hero/cell/attr_cell.lua index 849b06f2..caa4d482 100644 --- a/lua/app/ui/hero/cell/attr_cell.lua +++ b/lua/app/ui/hero/cell/attr_cell.lua @@ -9,13 +9,13 @@ function AttrCell:init() 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) +function AttrCell:refresh(heroEntity, nodeType, attrType) + self.heroEntity = heroEntity + self.weaponEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.WEAPON) + self.hatEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HAT) + self.clothesEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.CLOTHES) + self.beltEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.BELT) + self.handguardEntity = self.heroEntity:getEquips(GConst.EquipConst.PART_TYPE.HANDGUARD) self.nodeType = nodeType self.attrName = attrType[self.heroEntity:getMatchType()] diff --git a/lua/app/ui/hero/cell/attr_node_cell.lua b/lua/app/ui/hero/cell/attr_node_cell.lua index 36ecb2ae..929fb0f1 100644 --- a/lua/app/ui/hero/cell/attr_node_cell.lua +++ b/lua/app/ui/hero/cell/attr_node_cell.lua @@ -9,7 +9,7 @@ function AttrNodeCell:init() self.itemsRoot = uiMap["total_node.items"] end -function AttrNodeCell:refresh(heroId, node) +function AttrNodeCell:refresh(heroEntity, 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 @@ -24,7 +24,7 @@ function AttrNodeCell:refresh(heroId, node) for index, attr in ipairs(node) do CellManager:loadCellAsync(ATTR_CELL_PATH, ATTR_CELL, self.itemsRoot, function(cell) - cell:refresh(heroId, node, attr) + cell:refresh(heroEntity, node, attr) end) end end diff --git a/lua/app/ui/hero/hero_attr_ui.lua b/lua/app/ui/hero/hero_attr_ui.lua index 488bd973..37b9e168 100644 --- a/lua/app/ui/hero/hero_attr_ui.lua +++ b/lua/app/ui/hero/hero_attr_ui.lua @@ -23,7 +23,7 @@ function HeroAttrUI:onClose() end function HeroAttrUI:ctor(parmas) - self.heroId = parmas + self.heroEntity = parmas.heroEntity end 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 cell.baseObject:setLocalPositionY(-totalHeight) cell.baseObject:setSizeDeltaY(nodeHeight) - cell:refresh(self.heroId, node) + cell:refresh(self.heroEntity, node) totalHeight = totalHeight + nodeHeight self.rootNodes:setSizeDeltaY(totalHeight) end) diff --git a/lua/app/ui/hero/hero_info_comp.lua b/lua/app/ui/hero/hero_info_comp.lua index d8632552..400731be 100644 --- a/lua/app/ui/hero/hero_info_comp.lua +++ b/lua/app/ui/hero/hero_info_comp.lua @@ -50,7 +50,7 @@ function HeroInfoComp:init() ModuleManager.HeroManager:upgradeHero(self.heroEntity:getCfgId(), self.heroEntity) end) 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 diff --git a/lua/app/ui/tips/formation_tips.lua b/lua/app/ui/tips/formation_tips.lua index 29b0afbb..9fd76e03 100644 --- a/lua/app/ui/tips/formation_tips.lua +++ b/lua/app/ui/tips/formation_tips.lua @@ -30,7 +30,7 @@ function FormationTips:onLoadRootComplete() self.originAnchoredPosition = tipsBgTransform.anchoredPosition self.originLocalPosition = tipsBgTransform.localPosition - self.heroFormation:refreshBriefInfo(self.formation) + self.heroFormation:refreshByEntitys(self.formation) end function FormationTips:onRefresh() diff --git a/lua/app/userdata/equip/equip_entity.lua b/lua/app/userdata/equip/equip_entity.lua index 7cd55d4a..035c4c33 100644 --- a/lua/app/userdata/equip/equip_entity.lua +++ b/lua/app/userdata/equip/equip_entity.lua @@ -4,6 +4,7 @@ local DEFAULT_FACTOR = GConst.BattleConst.DEFAULT_FACTOR function EquipEntity:ctor(heroId, part, level) self.level = level or 0 + self.heroEntity = nil self.cfg, self.cfgId = table.find(ConfigManager:getConfig("equip"), function(value) return value.hero == heroId and value.part == part end) @@ -39,7 +40,7 @@ end -- 获取部位加成后生命值 function EquipEntity:getHp() 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 end @@ -54,7 +55,7 @@ end -- 获取部位加成后攻击力 function EquipEntity:getAttack() 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 end @@ -348,4 +349,16 @@ function EquipEntity:onLevelUp() self:setDirty() 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 \ No newline at end of file diff --git a/lua/app/userdata/hero/hero_entity.lua b/lua/app/userdata/hero/hero_entity.lua index 48daa0f5..eadcdaa3 100644 --- a/lua/app/userdata/hero/hero_entity.lua +++ b/lua/app/userdata/hero/hero_entity.lua @@ -75,50 +75,51 @@ 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 + if self.equipAttr then --更新前删除以前的,因为方法应该为覆盖数值 + for attrName, value in pairs(self.equipAttr) do + self.equipAttr[attrName] = 0 end + 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() + local hp,atk,normalHurt,skillHurt,critPer,critHurtPer,normalHurtPer,skillHurtPer,healPer = 0 - 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) + for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do + local equipEntity = self:getEquips(partType) + if equipEntity then + 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().."-".. partName .. "\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 end @@ -404,13 +405,13 @@ 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() + -- 武器 + 防具 + for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do + local equipEntity = self:getEquips(partType) + if equipEntity then + result = result + equipEntity:getBaseHp() + end + end return result end @@ -418,14 +419,29 @@ 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() + -- 武器 + 防具 + for partName, partType in pairs(GConst.EquipConst.PART_TYPE) do + local equipEntity = self:getEquips(partType) + if equipEntity then + result = result + equipEntity:getBaseAttack() + end + end return result 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 \ No newline at end of file