diff --git a/lua/app/common/config_manager.lua b/lua/app/common/config_manager.lua index 9ea71610..e9f7f80b 100644 --- a/lua/app/common/config_manager.lua +++ b/lua/app/common/config_manager.lua @@ -91,6 +91,7 @@ function ConfigManager:preLoadConfig() self:clearConfigCache(name) end handleMonsterGrow("monster_chapter") + handleMonsterGrow("monster_daily_challenge") self.configs["monster"] = { data = monsterFullData, diff --git a/lua/app/config/hero.lua b/lua/app/config/hero.lua index 41d8d6a9..f63a7834 100644 --- a/lua/app/config/hero.lua +++ b/lua/app/config/hero.lua @@ -19,12 +19,12 @@ local hero = { ["rouge_skill_7"]=1200107, ["begin_lv"]=1, ["hp"]={ - 2000000, - 2400000, + 2000000000, + 2400000000, 2800000, 3220000, - 3660000, - 4120000, + 3660000000, + 4120000000, 4620000, 5160000, 5760000, @@ -40,7 +40,7 @@ local hero = { 1200000, 1400000, 1610000, - 1830000, + 18300000, 2060000, 2310000, 2580000, diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 563b76b8..490e57d6 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -76,6 +76,7 @@ BattleConst.TIME_SCALE = { -- 为方便存储,这里使用字符串 BattleConst.BATTLE_TYPE = { STAGE = "1", + DAILY_CHALLENGE = "2", } BattleConst.TYPEOF_LUA_COMP = { diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index 01420281..875f17e7 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -7,7 +7,8 @@ BattleManager.SKILL_CFG = ConfigManager:getConfig("skill") local BATTLE_CONTROLLER_BASE = "app/module/battle/controller/battle_controller" local BATTLE_CONTROLLER = { - [BattleConst.BATTLE_TYPE.STAGE] = "app/module/battle/controller/battle_controller_stage" + [BattleConst.BATTLE_TYPE.STAGE] = "app/module/battle/controller/battle_controller_stage", + [BattleConst.BATTLE_TYPE.DAILY_CHALLENGE] = "app/module/battle/controller/battle_controller_daily_challenge", } function BattleManager:showPauseUI() diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 9db26a45..afed8d59 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -30,10 +30,39 @@ function BattleController:getNotInvolvedSkills() return {} end +function BattleController:getFixedRogueSkill() + return {} +end + function BattleController:getSealElementType() return {} end +function BattleController:getBuffs() + return {} +end + +function BattleController:handleBuffs(side) + for _, buffEntity in ipairs(self:getBuffs()) do + local buffTargetSide = buffEntity:getTargetSide() + local target + if buffTargetSide == BattleConst.SIDE_ATK then + target = self.atkTeam:getMainUnit() + else + target = self.defTeam:getMainUnit() + end + if side then + if buffTargetSide == side then + buffEntity:setOwner(target) + target:takeEffect(buffEntity, target) + end + else + buffEntity:setOwner(target) + target:takeEffect(buffEntity, target) + end + end +end + -- 战斗对应的ui function BattleController:getBattleUIPath() return "app/ui/battle/battle_ui" @@ -47,6 +76,16 @@ end function BattleController:initOther() end +-- 怪物攻击力加成 +function BattleController:getMonsterAtkAddition() + return BattleConst.DEFAULT_FACTOR +end + +-- 怪物血量加成 +function BattleController:getMonsterHpAddition() + return BattleConst.DEFAULT_FACTOR +end + -- 需要额外加载的资源 function BattleController:loadOtherRes(callback) return callback() @@ -364,6 +403,7 @@ function BattleController:getOtherSideMainUnit(side) end function BattleController:onLoadComplete() + self:handleBuffs() self:battleStart() end diff --git a/lua/app/module/battle/controller/battle_controller_daily_challenge.lua b/lua/app/module/battle/controller/battle_controller_daily_challenge.lua new file mode 100644 index 00000000..7ca8182d --- /dev/null +++ b/lua/app/module/battle/controller/battle_controller_daily_challenge.lua @@ -0,0 +1,248 @@ +local BattleHelper = require "app/module/battle/helper/battle_helper" +local BattleController = require "app/module/battle/controller/battle_controller" +local BattleControllerDailyChallenge = class("BattleControllerDailyChallenge", BattleController) +local CHAPTER_CFG = ConfigManager:getConfig("chapter_daily_challenge") +local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity" + +function BattleControllerDailyChallenge:getChapterId() + return 1 -- 临时 +end + +function BattleControllerDailyChallenge:getMaxWave() + if CHAPTER_CFG[self.chapterId] then + return #CHAPTER_CFG[self.chapterId].monster + end + return 0 +end + +function BattleControllerDailyChallenge:getChessBoardBgName() + local chapterInfo = CHAPTER_CFG[self.chapterId] + if not chapterInfo then + return "chessboard_1" + end + return chapterInfo.chess_board +end + +function BattleControllerDailyChallenge:getBuffs() + if not self.initBuffs then + self.initBuffs = {} + end + + return self.initBuffs +end + +function BattleControllerDailyChallenge:initOther() + local cfg = ConfigManager:getConfig("chapter")[2] -- 临时 + self.monsterAtkAddition = 0 + self.monsterHpAddition = 0 + if cfg and cfg.daily_challenge_difficulty then + self.monsterAtkAddition = cfg.daily_challenge_difficulty[2] + self.monsterHpAddition = cfg.daily_challenge_difficulty[1] + end +end + +-- 怪物攻击力加成 +function BattleControllerDailyChallenge:getMonsterAtkAddition() + return self.monsterAtkAddition +end + +-- 怪物血量加成 +function BattleControllerDailyChallenge:getMonsterHpAddition() + return self.monsterHpAddition +end + +function BattleControllerDailyChallenge:initDefUnits(callback) + local config = CHAPTER_CFG[self.chapterId] + self.battleUI:loadBg(config.scene) + local unitEntity = DataManager.BattleData:addMonster(config.monster[1], nil, self) + local modelId = unitEntity:getModelId() + BattleHelper:loadBattleHeroModel(modelId, self.battleUI:getBattleNode(), function(spineObject) + local monsterComp = spineObject:addLuaComponent(GConst.BattleConst.TYPEOF_LUA_COMP.BATTLE_MONSTER_COMPONENT) + monsterComp:initWithEntity(modelId, unitEntity, self) + self.defTeam:addUnit(monsterComp, true) + self.battleUI:refreshDefHp(unitEntity:getHp(), unitEntity:getHpPercent()) + callback() + end) +end + +function BattleControllerDailyChallenge:_stageGenerateNextMonster() + local config = CHAPTER_CFG[self.chapterId] + local monsterId = config.monster[self.waveIndex + 1] + if monsterId == nil then + return self:enterNextWave() + end + local isBoss = self.defTeam:getIsBoss() + local unitEntity = DataManager.BattleData:addMonster(monsterId, true, self) + local modelId = unitEntity:getModelId() + BattleHelper:loadBattleHeroModel(modelId, self.battleUI:getBattleNode(), function(spineObject) + self.defTeam:removeAllUnits() + local monsterComp = spineObject:addLuaComponent(GConst.BattleConst.TYPEOF_LUA_COMP.BATTLE_MONSTER_COMPONENT) + monsterComp:initWithEntity(modelId, unitEntity, self) + self.defTeam:addUnit(monsterComp, true) + self:handleBuffs(GConst.BattleConst.SIDE_DEF) + self.battleUI:refreshDefHp(unitEntity:getHp(), unitEntity:getHpPercent()) + local bornTime = monsterComp:getAnimationDuration(GConst.BattleConst.SPINE_ANIMATION_NAME.BORN) + if isBoss then -- 如果是boss就跑过去 + local count = 0 + local function onFinish() + count = count + 1 + if count == 2 then + self.atkTeam:stopRunAction() + self:onRoundEnd(true) + end + end + self.atkTeam:playRunAction() + self.atkTeam:recoverHpOnWaveOver(onFinish) + + isBoss = self.defTeam:getIsBoss() + if isBoss then + local monsterInfo = ConfigManager:getConfig("monster")[monsterId] + self.battleUI:showBossEnterAni(bornTime, ModuleManager.HeroManager:getMonsterName(monsterInfo.monster_base), monsterComp, function() + monsterComp:playEnterBattlefield(true, onFinish) + end) + else + monsterComp:playEnterBattlefield(true, onFinish) + end + else + local count = 0 + local function onFinish() + count = count + 1 + if count == 2 then + self:onRoundEnd(true) + end + end + self.atkTeam:recoverHpOnWaveOver(onFinish) + + isBoss = self.defTeam:getIsBoss() + if isBoss then + local monsterInfo = ConfigManager:getConfig("monster")[monsterId] + self.battleUI:showBossEnterAni(bornTime, ModuleManager.HeroManager:getMonsterName(monsterInfo.monster_base), monsterComp, function() + monsterComp:playEnterBattlefield(false, onFinish) + end) + else + monsterComp:playEnterBattlefield(false, onFinish) + end + end + end) +end + +function BattleControllerDailyChallenge:getInitBoard() + if not self.boradList then + self.boradList = {} + self.fixedRandomGrid = {} + self.mysteryBoxIndexMap = {} + + local config = CHAPTER_CFG[self.chapterId] + local boardCfg = ConfigManager:getConfig("chapter_board_daily_challenge") + for _, boardId in ipairs(config.chapter_board_daily_challenge) do + local cfg = boardCfg[boardId] + if cfg then + table.insert(self.boradList, {board = GFunc.getTable(cfg.board_daily_challenge)}) + end + end + end + + return self.boradList, self.fixedRandomGrid, self.mysteryBoxIndexMap +end + +function BattleControllerDailyChallenge:getSealElementType() + if not self.sealElementType then + self.sealElementType = {} + local config = CHAPTER_CFG[self.chapterId] + if config.seal_element then + for _, elementType in ipairs(config.seal_element) do + self.sealElementType[elementType] = true + end + end + end + + return self.sealElementType +end + +function BattleControllerDailyChallenge:getNotInvolvedSkills() + if not self.notInvolvedSkills then + self.notInvolvedSkills = {} + local config = CHAPTER_CFG[self.chapterId] + if config.not_involved_skill then + for _, skillId in ipairs(config.not_involved_skill) do + self.notInvolvedSkills[skillId] = true + end + end + end + + return self.notInvolvedSkills +end + +function BattleControllerDailyChallenge:getFixedRogueSkill() + if not self.fixedRogueSkill then + local config = CHAPTER_CFG[self.chapterId] + if config.involved_skill then + self.fixedRogueSkill = GFunc.getTable(config.involved_skill) + else + self.fixedRogueSkill = {} + end + end + + return self.fixedRogueSkill +end + +function BattleControllerDailyChallenge:findNextDefUnit() + self:_stageGenerateNextMonster() +end + +function BattleControllerDailyChallenge:controllBattleEnd() + self.combatReport = { + battleType = GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, + wave = self.waveIndex, + victory = self.victory, + } + local atkReport = {} + local teamEntity = DataManager.BattleData:getAtkTeam() + local members = teamEntity:getAllMembers() + for k, v in pairs(members) do + local report = { + heroId = v:getId(), + dmg = v:getDamageCount(), + } + table.insert(atkReport, report) + end + self.combatReport.atkReport = atkReport + if not self.victory then + self.combatReport.wave = self.combatReport.wave - 1 + end + Logger.logHighlight("BattleControllerDailyChallenge fight over") + -- ModuleManager.ChapterManager:endFight(self.chapterId, self.combatReport, self.gotMysteryBoxIndexs, self.taskProgress) +end + +function BattleControllerDailyChallenge:postWaveOver(atkDead, isQuit) + local deathType = BIReport.FIGHT_DEATH_TYPE.SURVIVE + local waveEndType = BIReport.FIGHT_WAVE_END_TYPE.WIN + if atkDead then + if self.isBossWave then + deathType = BIReport.FIGHT_DEATH_TYPE.BOSS_FAIL + else + deathType = BIReport.FIGHT_DEATH_TYPE.NORMAL_FAIL + end + waveEndType = BIReport.FIGHT_WAVE_END_TYPE.FAIL + end + + if isQuit then + waveEndType = BIReport.FIGHT_WAVE_END_TYPE.QUIT + end + + local duration = Time:getServerTime() - self.waveStartTime + local totalTime = Time:getServerTime() - self.battleStartTime + local startTimes = 1 -- TODO + local isFirstWin = false -- TODO + + local isFianlStep = self.waveIndex >= self.maxWaveIndex + + BIReport:postFightEnd(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, self.chapterId, self.waveIndex, duration, totalTime, self.eliminateCount, self.eliminateTotalCount, waveEndType, deathType, startTimes, isFirstWin, isFianlStep) +end + +function BattleControllerDailyChallenge:postFightStart() + local unlockMaxChapter = DataManager.ChapterData:getNewChapterId() + BIReport:postFightBegin(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, self.waveIndex, self.chapterId, unlockMaxChapter, 1) +end + +return BattleControllerDailyChallenge \ No newline at end of file diff --git a/lua/app/module/battle/controller/battle_controller_daily_challenge.lua.meta b/lua/app/module/battle/controller/battle_controller_daily_challenge.lua.meta new file mode 100644 index 00000000..1e913b50 --- /dev/null +++ b/lua/app/module/battle/controller/battle_controller_daily_challenge.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: b8ac1cad3e089ab49a3f7b7c2d6923ac +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/module/battle/controller/battle_controller_stage.lua b/lua/app/module/battle/controller/battle_controller_stage.lua index 793bf1ef..25aa6f72 100644 --- a/lua/app/module/battle/controller/battle_controller_stage.lua +++ b/lua/app/module/battle/controller/battle_controller_stage.lua @@ -28,7 +28,7 @@ function BattleControllerStage:getChessBoardBgName() end -function BattleController:initOther() +function BattleControllerStage:initOther() end @@ -202,7 +202,7 @@ function BattleControllerStage:controllBattleEnd() ModuleManager.ChapterManager:endFight(self.chapterId, self.combatReport, self.gotMysteryBoxIndexs, self.taskProgress) end -function BattleController:postWaveOver(atkDead, isQuit) +function BattleControllerStage:postWaveOver(atkDead, isQuit) local deathType = BIReport.FIGHT_DEATH_TYPE.SURVIVE local waveEndType = BIReport.FIGHT_WAVE_END_TYPE.WIN if atkDead then diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 41ed3e56..389e24b5 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -293,7 +293,7 @@ function BattleTeam:removeAllBuff() local count = #self.buffList for i = count, 1, -1 do buffEffect = self.buffList[i] - if buffEffect then + if buffEffect and not buffEffect.buff:isCantRemove() then self:updateBuffState(buffEffect.buff, -1) table.remove(self.buffList, i) BattleBuffHandle.removeBuff(self.mainUnit, buffEffect) @@ -332,7 +332,7 @@ function BattleTeam:putCacheBuffByDecr(buffDecr) local count = #self.buffList for i = count, 1, -1 do buffEffect = self.buffList[i] - if buffEffect and buffEffect.buff:getDecr() == buffDecr then + if buffEffect and buffEffect.buff:getDecr() == buffDecr and not buffEffect.buff:isCantRemove() then self:updateBuffState(buffEffect.buff, -1) table.remove(self.buffList, i) BattleBuffHandle.removeBuff(self.mainUnit, buffEffect, true) diff --git a/lua/app/userdata/battle/battle_data.lua b/lua/app/userdata/battle/battle_data.lua index 400ebf0a..33020be3 100644 --- a/lua/app/userdata/battle/battle_data.lua +++ b/lua/app/userdata/battle/battle_data.lua @@ -614,10 +614,14 @@ function BattleData:initHeroData() return data end -function BattleData:addMonster(monsterId, newTeam) +function BattleData:addMonster(monsterId, newTeam, battleController) local monsterInfo = ConfigManager:getConfig("monster")[monsterId] local hp = monsterInfo.hp // DEFAULT_FACTOR local atk = monsterInfo.atk // DEFAULT_FACTOR + if battleController then + hp = hp * (DEFAULT_FACTOR + battleController:getMonsterHpAddition()) // DEFAULT_FACTOR + atk = atk * (DEFAULT_FACTOR + battleController:getMonsterAtkAddition()) // DEFAULT_FACTOR + end local unitData = { id = monsterId, modelId = monsterInfo.model_id, diff --git a/lua/app/userdata/battle/skill/battle_buff_entity.lua b/lua/app/userdata/battle/skill/battle_buff_entity.lua index c3677090..5deb3477 100644 --- a/lua/app/userdata/battle/skill/battle_buff_entity.lua +++ b/lua/app/userdata/battle/skill/battle_buff_entity.lua @@ -16,6 +16,7 @@ function BattleBuffEntity:init(effectParams, owner, hostSkill) self.targetSide = nil self.buffInfo = ConfigManager:getConfigWithOtherKey("buff", "name")[self.name] self.buffType = self.buffInfo.buff_type + self.cantRemove = false end function BattleBuffEntity:setOwner(owner) @@ -114,4 +115,12 @@ function BattleBuffEntity:getFxDisappear() return self.buffInfo.fx_disappear end +function BattleBuffEntity:isCantRemove() + return self.cantRemove +end + +function BattleBuffEntity:setIsCantRemove(cantRemove) + self.cantRemove = cantRemove +end + return BattleBuffEntity \ No newline at end of file