local BattleHelper = require "app/module/battle/helper/battle_helper" local BattleBaseController = require "app/module/battle/controller/battle_base_controller" local BattleControllerPVP = class("BattleControllerPVP", BattleBaseController) local BattleConst = GConst.BattleConst -- *************各个子模块的战斗需要重写的方法 START************* function BattleControllerPVP:getBoardConfig() return {} end function BattleControllerPVP:getChapterConfig() return {} end function BattleControllerPVP:getChapterId() return 0 end function BattleControllerPVP:getBuffs() return {} end -- 战斗对应的ui function BattleControllerPVP:getBattleUIPath() return "app/ui/battle/battle_ui_pvp" end -- 战斗结束 function BattleControllerPVP:controllBattleEnd() end -- 一共有多少波 function BattleControllerPVP:getMaxWave() return 1 end function BattleControllerPVP:findNextDefUnit() self:enterRoundEnd(true) end function BattleControllerPVP:onLinkChange() self.battleUI:hideAllSfxLine() self.linkChangeNeedFalsePosMap = table.clearOrCreate(self.linkChangeNeedFalsePosMap) for posId, entity in pairs(self.battleData:getGridEnties()) do if entity:getCell() then self.linkChangeNeedFalsePosMap[posId] = entity:getCell() end end local sequence = self.battleData:getGridSequence() local mainElementType for index, info in ipairs(sequence) do local entity = self.battleData:getGridEntity(info.posId) if not mainElementType then local skillId = entity:getSkillId() if not skillId then mainElementType = entity:getElementType() break end end end local count = #sequence for index, info in ipairs(sequence) do local entity = self.battleData:getGridEntity(info.posId) if entity:getCell() then entity:getCell():showHighLight(true, mainElementType, self.battleUI) end if self.linkChangeNeedFalsePosMap[info.posId] then self.linkChangeNeedFalsePosMap[info.posId] = nil end if index < count then local nextPosId = sequence[index + 1].posId self.battleUI:getSfxLine(index, function(obj) local curPos = ModuleManager.BattleManager:getPosInfo(info.posId) local nextPos = ModuleManager.BattleManager:getPosInfo(nextPosId) local pos, z = ModuleManager.BattleManager:getPosCenterAndDir(curPos, nextPos) obj:setLocalScale(25, 25, 25) obj:setLocalPosition(pos.x, pos.y, 0) obj:setEulerAngles(0, 0, z) end) end if index == count then if entity:getCell() then entity:getCell():showAni() end end end for posId, cell in pairs(self.linkChangeNeedFalsePosMap) do cell:showHighLight(false) end for posId, info in pairs(self.battleData:getSkillInfluenceGrids()) do local entity = self.battleData:getGridEntity(posId) if info.direction ~= BattleConst.BOARD_RANGE_TYPE.RANDOM then if entity:getCell() then entity:getCell():showCircle(true) end end end if not self.atkTeam:getMainUnit().unitEntity:getActiveSkillLimit() then local aniSequence, influenceElementType, lineCount, elementTypeMap, linkElementType = self:calculateCurElimination(true) self.battleUI:refreshSkill(elementTypeMap, count > 0) end if mainElementType then self.atkTeam:changeMainUnit(mainElementType) end end function BattleControllerPVP:postWaveOver(atkDead, isQuit) end function BattleControllerPVP:postFightStart() end function BattleControllerPVP:onEliminationBegin() end function BattleControllerPVP:refreshWave() if not self.battleUI then return end self.battleUI:refreshWave(self.waveIndex) end -- *************各个子模块的战斗需要重写的方法 END************* function BattleControllerPVP:ctor() self.battleData = DataManager.BattlePVPData end function BattleControllerPVP:initDefUnits(callback) local defTeamEntity = self.battleData:getDefTeam() local count = 0 local totalCount = defTeamEntity:getMembersCount() local function onloadFinished() count = count + 1 if count == totalCount then self.battleUI:refreshAtkHp(defTeamEntity:getHp(), defTeamEntity:getHpPercent()) callback() end end local members = defTeamEntity:getAllMembers() for k, v in pairs(members) do local modelId = v:getModelId() BattleHelper:loadBattleHeroModel(modelId, self.battleUI:getBattleNode(), function(spineObject) local heroComp = spineObject:addLuaComponent(BattleConst.TYPEOF_LUA_COMP.BATTLE_HERO_COMPONENT) heroComp:initWithEntity(modelId, v, self) if v:getIsMainUnit() then self.defTeam:addUnit(heroComp, true) else self.defTeam:addUnit(heroComp) heroComp:hideOutsideScreen() end onloadFinished() end) end if totalCount == 0 then callback() end end return BattleControllerPVP