diff --git a/lua/app/module/battle/component/battle_unit_comp.lua b/lua/app/module/battle/component/battle_unit_comp.lua index c91e8feb..8b65c7d8 100644 --- a/lua/app/module/battle/component/battle_unit_comp.lua +++ b/lua/app/module/battle/component/battle_unit_comp.lua @@ -28,15 +28,6 @@ function BattleUnitComp:playBorn() self:changeState(UNIT_STATE.IDLE) end -function BattleUnitComp:playSwitchIn() - self:changeState(UNIT_STATE.SWITCH_IN) -end - -function BattleUnitComp:playSwitchOut() - self:changeState(UNIT_STATE.SWITCH_OUT) -end - - function BattleUnitComp:getModelId() return self.modelId end @@ -56,7 +47,6 @@ function BattleUnitComp:_initBase() self.attackTime = 0 self.currAttackDuration = 0 self.currAttackKeyTime = 0 - self.switchTime = 0 self.isPlayHurt = 0 self.attackDurationMap = {} self.shieldBuffList = {} @@ -214,10 +204,6 @@ function BattleUnitComp:changeState(state) self:exitDeadState() elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then self:exitEnterBattlefieldState() - elseif self.currState == UNIT_STATE.SWITCH_IN then - self:exitSwitchInState() - elseif self.currState == UNIT_STATE.SWITCH_OUT then - self:exitSwitchOutState() end -- 进入目标状态 self.currState = state @@ -235,10 +221,6 @@ function BattleUnitComp:changeState(state) self:enterBornState() elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then self:enterEnterBattlefieldState() - elseif self.currState == UNIT_STATE.SWITCH_IN then - self:enterSwitchInState() - elseif self.currState == UNIT_STATE.SWITCH_OUT then - self:enterSwitchOutState() end return true end @@ -252,40 +234,6 @@ function BattleUnitComp:repeatCurrState() return false end -function BattleUnitComp:updateSwitchInState(dt) - self.switchTime = self.switchTime - dt - if self.switchTime < 0 then - self:changeState(UNIT_STATE.IDLE) - end -end - -function BattleUnitComp:enterSwitchInState() - local aniName = SPINE_ANIMATION_NAME.BORN - self.switchTime = self:getAnimationDuration(aniName) + 0.1 - self:initPosition() - self:playAnimation(aniName, false, true) -end - -function BattleUnitComp:exitSwitchInState() -end - -function BattleUnitComp:updateSwitchOutState(dt) - self.switchTime = self.switchTime - dt - if self.switchTime < 0 then - self:changeState(UNIT_STATE.IDLE) - end -end - -function BattleUnitComp:enterSwitchOutState() - local aniName = SPINE_ANIMATION_NAME.OUT - self.switchTime = self:getAnimationDuration(aniName) + 0.1 - self:playAnimation(aniName, false, true) -end - -function BattleUnitComp:exitSwitchOutState() - self:hideOutsideScreen() -end - function BattleUnitComp:updateDead(dt) self.deadTime = self.deadTime - dt if self.deadTime <= 0 then @@ -781,10 +729,6 @@ function BattleUnitComp:tick(dt) self:updateAssistingAttackState(dt) elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then self:updateEnterBattlefieldState(dt) - elseif self.currState == UNIT_STATE.SWITCH_IN then - self:updateSwitchInState(dt) - elseif self.currState == UNIT_STATE.SWITCH_OUT then - self:updateSwitchOutState(dt) end end diff --git a/lua/app/module/battle/controller/battle_controller.lua b/lua/app/module/battle/controller/battle_controller.lua index 87b08ef8..8b45982e 100644 --- a/lua/app/module/battle/controller/battle_controller.lua +++ b/lua/app/module/battle/controller/battle_controller.lua @@ -6,9 +6,11 @@ local BattleController = class("BattleController") local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle" local BATTLE_ROGUE_SKILL_HANDLE = require "app/module/battle/skill/battle_rogue_skill_handle" +local BattleBuffHandle = require "app/module/battle/helper/battle_buff_handle" local ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT local BattleConst = GConst.BattleConst +local BUFF_NAME_TO_ATTR = BattleConst.BUFF_NAME_TO_ATTR -- *************各个子模块的战斗需要重写的方法 START************* function BattleController:getChapterId() @@ -654,18 +656,18 @@ end function BattleController:generateInstructions(skillEntity, elementType, influenceElementType, elementTypeMap) ---- 加buff if skillEntity then - if skillEntity:getLinkAtkp() > 0 and elementType then - local attrType = BattleConst.ELEMENT_TYPE_ATKP_NAME[elementType] - if attrType then - table.insert(self.instructions, { - name = BattleConst.INSTRUCTION_NAME.ADD_CUR_ROUND_ATTR, - attr = { - type = attrType, - num = skillEntity:getLinkAtkp() - } - }) - end - end + -- if skillEntity:getLinkEffects() > 0 and elementType then + -- local attrType = BattleConst.ELEMENT_TYPE_ATKP_NAME[elementType] + -- if attrType then + -- table.insert(self.instructions, { + -- name = BattleConst.INSTRUCTION_NAME.ADD_CUR_ROUND_ATTR, + -- attr = { + -- type = attrType, + -- num = skillEntity:getLinkEffects() + -- } + -- }) + -- end + -- end if skillEntity:getInInfluenceAtkp() > 0 and influenceElementType then for elementType, _ in pairs(influenceElementType) do @@ -1137,34 +1139,26 @@ end function BattleController:addHeroAttr(attrName, value) Logger.logHighlight("------addHeroAttr------ " .. attrName .. " " .. value) - -- if attrName == then - -- -- body - -- elseif attrName == then - -- -- body - -- elseif attrName == then' - -- -- body - -- elseif attrName == then - -- -- body - -- elseif attrName == then - -- -- body - -- else - -- end -end + if not self.battleData or not self.battleData.atkTeam then + return + end -function BattleController:changeSkillId(elementType, skillId) - Logger.logHighlight("------changeSkillId------ " .. elementType .. " " .. skillId) -end - -function BattleController:addSkillReleaseCount(elementType, count) - Logger.logHighlight("------addSkillReleaseCount------ " .. elementType .. " " .. count) -end - -function BattleController:addSkillEffectParams(elementType, effect) - Logger.logHighlight("------addSkillEffectParams------ " .. elementType .. " " .. json.encode(effect)) -end - -function BattleController:addSkillRound(elementType, effect) - Logger.logHighlight("------addSkillRound------ " .. elementType .. " " .. json.encode(effect)) + local attr = BUFF_NAME_TO_ATTR[attrName] + if attr then + self.battleData.atkTeam:addAttr(attr[1], value, attr[2]) + else + local func = BattleBuffHandle.addAttribute[attrName] + if func then + local unitComp + for matchType, comp in pairs(self.atkTeam:getUnitComp()) do + unitComp = comp + break + end + if unitComp then + func(unitComp, value) + end + end + end end function BattleController:addSkillEffect(elementType, effects) diff --git a/lua/app/module/battle/skill/battle_rogue_skill_handle.lua b/lua/app/module/battle/skill/battle_rogue_skill_handle.lua index 9de53445..0e5d72c4 100644 --- a/lua/app/module/battle/skill/battle_rogue_skill_handle.lua +++ b/lua/app/module/battle/skill/battle_rogue_skill_handle.lua @@ -13,8 +13,17 @@ local _changeBaseSkill = function(skillInfo, battleData, battleController) return end - battleData:changeSkillId(elementType, newSkillId) - battleController:changeSkillId(elementType, newSkillId) + local skillEntity = battleData:getSkillEntityByElement(elementType) + if skillEntity then + local skillId = skillEntity:getSkillId() + battleData:changeSkillId(elementType, newSkillId) + if not battleData.atkTeam then + return + end + if battleData.atkTeam:getAllMembers()[elementType] then + battleData.atkTeam:getAllMembers()[elementType]:changeActiveSkillId(skillId, newSkillId) + end + end end local _addEliminationRange = function(skillInfo, battleData, battleController) @@ -43,18 +52,24 @@ end local _addLinkAtkp = function(skillInfo, battleData, battleController) local elementType = skillInfo.skill_position - if not elementType or not skillInfo.parameter then + if not elementType or not skillInfo.effect then return end - local atkp = skillInfo.parameter[1] - if not atkp then + if not battleController.battleData or not battleController.battleData.atkTeam then return end - local entity = battleData:getSkillEntityByElement(elementType) - if entity then - entity:addLinkAtkp(atkp) + local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType] + if not unitEntity then + return + end + + for _, effect in ipairs(skillInfo.effect) do + local entity = battleData:getSkillEntityByElement(elementType) + if entity then + entity:addLinkEffect(effect, unitEntity) + end end end @@ -92,7 +107,7 @@ local _addSkillReleaseCount = function(skillInfo, battleData, battleController) return end - battleController:addSkillReleaseCount(elementType, count) + -- battleController:addSkillReleaseCount(elementType, count) end local _addSkillEffectParams = function(skillInfo, battleData, battleController) @@ -120,7 +135,16 @@ local _addSkillEffectParams = function(skillInfo, battleData, battleController) return end - battleController:addSkillEffectParams(elementType, effect) + local skillEntity = battleData:getSkillEntityByElement(elementType) + if skillEntity then + local skillId = skillEntity:getSkillId() + if not battleData.atkTeam then + return + end + if battleData.atkTeam:getAllMembers()[elementType] then + battleData.atkTeam:getAllMembers()[elementType]:addSkillEffectParams(skillId, effect) + end + end end local _addSkillRound = function(skillInfo, battleData, battleController) @@ -141,7 +165,7 @@ local _addSkillRound = function(skillInfo, battleData, battleController) local effectCfg = entity:getEffect()[index] if effectCfg then effect = GFunc.getTable(effectCfg) - effect.num = value + effect.round = value end end @@ -149,7 +173,17 @@ local _addSkillRound = function(skillInfo, battleData, battleController) return end - battleController:addSkillRound(elementType, effect) + local skillEntity = battleData:getSkillEntityByElement(elementType) + if skillEntity then + local skillId = skillEntity:getSkillId() + if not battleData.atkTeam then + return + end + if battleData.atkTeam:getAllMembers()[elementType] then + battleData.atkTeam:getAllMembers()[elementType]:addActiveSkillRound(skillId, effect) + end + end + Logger.logHighlight("------addSkillRound------ " .. elementType .. " " .. json.encode(effect)) end local _addSkillEffect = function(skillInfo, battleData, battleController) @@ -168,18 +202,22 @@ end local _addSkillInInfluenceAtkp = function(skillInfo, battleData, battleController) local elementType = skillInfo.skill_position - if not elementType or not skillInfo.parameter then + if not elementType or not skillInfo.effect then return end - local atkp = skillInfo.parameter[1] - if not atkp then + if not battleController.battleData or not battleController.battleData.atkTeam then + return + end + + local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType] + if not unitEntity then return end local entity = battleData:getSkillEntityByElement(elementType) - if entity then - entity:addInInfluenceAtkp(atkp) + for _, effect in ipairs(skillInfo.effect) do + entity:addInInfluenceEffect(effect, unitEntity) end end @@ -189,10 +227,19 @@ local _addSkillGeneralAttackEffect = function(skillInfo, battleData, battleContr return end + if not battleController.battleData or not battleController.battleData.atkTeam then + return + end + + local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType] + if not unitEntity then + return + end + local entity = battleData:getSkillEntityByElement(elementType) if entity then for _, effect in ipairs(skillInfo.effect) do - entity:addGeneralAttackEffect(effect) + entity:addGeneralAttackEffect(effect, unitEntity) end end end @@ -203,10 +250,19 @@ local _addSkillElementCountEffect = function(skillInfo, battleData, battleContro return end + if not battleController.battleData or not battleController.battleData.atkTeam then + return + end + + local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType] + if not unitEntity then + return + end + local entity = battleData:getSkillEntityByElement(elementType) if entity then for _, effect in ipairs(skillInfo.effect) do - entity:addElementCountEffect(effect) + entity:addElementCountEffect(effect, unitEntity) end end end diff --git a/lua/app/module/battle/team/battle_team.lua b/lua/app/module/battle/team/battle_team.lua index 8aed626b..c48ebf28 100644 --- a/lua/app/module/battle/team/battle_team.lua +++ b/lua/app/module/battle/team/battle_team.lua @@ -178,6 +178,10 @@ function BattleTeam:updateBuffState(buff, num) self.sameBuffCount[buffName] = buffNum end +function BattleTeam:getUnitComp() + return self.unitMap +end + function BattleTeam:tick(dt) for k, v in ipairs(self.unitList) do v:tick(dt) diff --git a/lua/app/userdata/battle/skill/battle_board_skill_entity.lua b/lua/app/userdata/battle/skill/battle_board_skill_entity.lua index 471a5e23..549629eb 100644 --- a/lua/app/userdata/battle/skill/battle_board_skill_entity.lua +++ b/lua/app/userdata/battle/skill/battle_board_skill_entity.lua @@ -1,13 +1,15 @@ local BattleBoardSkillEnity = class("BattleBoardSkillEnity", BaseData) +local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity" function BattleBoardSkillEnity:ctor(skillId) self:refreshSkillId(skillId) self.curEnergy = 0 self.addRange = {} - self.linkAtkp = 0 - self.inInfluenceAtkp = 0 - self.generalAttackEffect = {} - self.elementCountEffect = {} + self.linkEffectEntities = 0 + self.inInfluenceEntities = 0 + self.generalAttackEffectEntities = {} + self.elementCountEffectEntities = {} + self.cacheBuffEntities = {} end function BattleBoardSkillEnity:refreshSkillId(skillId) @@ -153,44 +155,89 @@ function BattleBoardSkillEnity:setIgnoreElementType(ignore) self.ignoreElementType = ignore end -function BattleBoardSkillEnity:getLinkAtkp() - return self.linkAtkp +function BattleBoardSkillEnity:getLinkEffects() + return self.linkEffectEntities end -function BattleBoardSkillEnity:addLinkAtkp(atkp) - self.linkAtkp = self.linkAtkp + atkp +function BattleBoardSkillEnity:addLinkEffect(effect, unitEntity) + local buffEntity = self.linkEffectEntities[effect.type] + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(effect, unitEntity) + self.linkEffectEntities[effect.type] = buffEntity + else + local buffNum = buffEntity:getEffectNum() + buffEntity:init(effect, unitEntity) + buffEntity:setEffectNum(buffEntity:getEffectNum() + buffNum) + end end function BattleBoardSkillEnity:getInInfluenceAtkp() - return self.inInfluenceAtkp + return self.inInfluenceEntities end -function BattleBoardSkillEnity:addInInfluenceAtkp(atkp) - self.inInfluenceAtkp = self.inInfluenceAtkp + atkp -end - -function BattleBoardSkillEnity:addGeneralAttackEffect(effect) - if not self.generalAttackEffect[effect.type] then - self.generalAttackEffect[effect.type] = GFunc.getTable(effect) +function BattleBoardSkillEnity:addInInfluenceEffect(effect, unitEntity) + local buffEntity = self.inInfluenceEntities[effect.type] + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(effect, unitEntity) + self.inInfluenceEntities[effect.type] = buffEntity else - self.generalAttackEffect[effect.type].num = self.generalAttackEffect[effect.type].numn + effect.num + local buffNum = buffEntity:getEffectNum() + buffEntity:init(effect, unitEntity) + buffEntity:setEffectNum(buffEntity:getEffectNum() + buffNum) + end +end + +function BattleBoardSkillEnity:addGeneralAttackEffect(effect, unitEntity) + local buffEntity = self.generalAttackEffectEntities[effect.type] + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(effect, unitEntity) + self.generalAttackEffectEntities[effect.type] = buffEntity + else + local buffNum = buffEntity:getEffectNum() + buffEntity:init(effect, unitEntity) + buffEntity:setEffectNum(buffEntity:getEffectNum() + buffNum) end end function BattleBoardSkillEnity:getGeneralAttackEffect() - return self.generalAttackEffect + return self.generalAttackEffectEntities end -function BattleBoardSkillEnity:addElementCountEffect(effect) - if not self.elementCountEffect[effect.type] then - self.elementCountEffect[effect.type] = GFunc.getTable(effect) +function BattleBoardSkillEnity:addElementCountEffect(effect, unitEntity) + local buffEntity = self.elementCountEffectEntities[effect.type] + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(effect, unitEntity) + self.elementCountEffectEntities[effect.type] = buffEntity else - self.elementCountEffect[effect.type].num = self.elementCountEffect[effect.type].numn + effect.num + local buffNum = buffEntity:getEffectNum() + buffEntity:init(effect, unitEntity) + buffEntity:setEffectNum(buffEntity:getEffectNum() + buffNum) end end function BattleBoardSkillEnity:getElementCountEffect() - return self.elementCountEffect + return self.elementCountEffectEntities +end + +function BattleBoardSkillEnity:addBuffEffect(buff, unitEntity) + local buffEntity = self.cacheBuffEntities[buff.type] + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(buff, unitEntity) + self.cacheBuffEntities[buff.type] = buffEntity + else + local buffNum = buffEntity:getEffectNum() + buffEntity:init(buff, unitEntity) + buffEntity:setEffectNum(buffEntity:getEffectNum() + buffNum) + end +end + +function BattleBoardSkillEnity:getBuffEffects() + return self.cacheBuffEntities end return BattleBoardSkillEnity \ No newline at end of file diff --git a/lua/app/userdata/battle/skill/battle_buff_entity.lua b/lua/app/userdata/battle/skill/battle_buff_entity.lua index 2568d74c..af467e3a 100644 --- a/lua/app/userdata/battle/skill/battle_buff_entity.lua +++ b/lua/app/userdata/battle/skill/battle_buff_entity.lua @@ -13,6 +13,10 @@ function BattleBuffEntity:init(effectParams, owner) self.buffType = self.buffInfo.buff_type end +function BattleBuffEntity:setOwner(owner) + self.owner = owner +end + function BattleBuffEntity:getName() return self.name end @@ -25,6 +29,10 @@ function BattleBuffEntity:getEffectNum() return self.effectNum end +function BattleBuffEntity:setEffectNum(num) + self.effectNum = num +end + function BattleBuffEntity:getFormula() return self.buffInfo.formula end @@ -33,10 +41,18 @@ function BattleBuffEntity:getRatio() return self.ratio end +function BattleBuffEntity:setRatio(ratio) + self.ratio = ratio +end + function BattleBuffEntity:getRound() return self.round end +function BattleBuffEntity:setRound(num) + self.round = num +end + function BattleBuffEntity:getBuffHitFxId() return nil end diff --git a/lua/app/userdata/battle/skill/battle_skill_entity.lua b/lua/app/userdata/battle/skill/battle_skill_entity.lua index a530dc48..f657e0a1 100644 --- a/lua/app/userdata/battle/skill/battle_skill_entity.lua +++ b/lua/app/userdata/battle/skill/battle_skill_entity.lua @@ -50,6 +50,49 @@ function BattleSkillEntity:endSkill() self.cd = self.coolingRounds end +function BattleSkillEntity:addSkillEffectParams(effect) + local buffEntity + for _, entity in ipairs(self.effectList) do + if entity:getName() == effect.type then + buffEntity = entity + break + end + end + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(effect, self.owner) + table.insert(self.effectList, buffEntity) + else + buffEntity:setEffectNum(buffEntity:getEffectNum() + effect.num) + end +end + +function BattleSkillEntity:addSkillEffectRound(effect) + local buffEntity + for _, entity in ipairs(self.effectList) do + if entity:getName() == effect.type then + buffEntity = entity + break + end + end + if not buffEntity then + buffEntity = BattleBuffEntity:create() + buffEntity:init(effect, self.owner) + table.insert(self.effectList, buffEntity) + else + buffEntity:setRound(buffEntity:getRound() + effect.round) + end +end + +function BattleSkillEntity:getSkillid() + return self.skillId +end + +function BattleSkillEntity:changeSkillId(skillId) + self.skillId = skillId + self:init() +end + function BattleSkillEntity:getMoveType() return self.skillInfo.position end diff --git a/lua/app/userdata/battle/team/battle_unit_entity.lua b/lua/app/userdata/battle/team/battle_unit_entity.lua index 1b24f56a..7358575c 100644 --- a/lua/app/userdata/battle/team/battle_unit_entity.lua +++ b/lua/app/userdata/battle/team/battle_unit_entity.lua @@ -91,6 +91,33 @@ function BattleUnitEntity:getNormalSkillNameList() return self.normalSkillNameList, count end +function BattleUnitEntity:changeActiveSkillId(originSkillId, tartgetSkillId) + for _, skillEntity in ipairs(self.activeSkills) do + if skillEntity:getSkillid() == originSkillId then + skillEntity:changeSkillId(tartgetSkillId) + break + end + end +end + +function BattleUnitEntity:addActiveSkillParams(skillId, effect) + for _, skillEntity in ipairs(self.activeSkills) do + if skillEntity:getSkillid() == skillId then + skillEntity:addSkillEffectParams(effect) + break + end + end +end + +function BattleUnitEntity:addActiveSkillRound(skillId, effect) + for _, skillEntity in ipairs(self.activeSkills) do + if skillEntity:getSkillid() == skillId then + skillEntity:addSkillEffectRound(effect) + break + end + end +end + function BattleUnitEntity:takeDamageOrCure(num) return self.team:takeDamageOrCure(num) end