棋盘增加属性

This commit is contained in:
xiekaidong 2023-04-18 10:36:00 +08:00
parent 74cffb310d
commit 947fc23ff0
8 changed files with 268 additions and 137 deletions

View File

@ -28,15 +28,6 @@ function BattleUnitComp:playBorn()
self:changeState(UNIT_STATE.IDLE) self:changeState(UNIT_STATE.IDLE)
end end
function BattleUnitComp:playSwitchIn()
self:changeState(UNIT_STATE.SWITCH_IN)
end
function BattleUnitComp:playSwitchOut()
self:changeState(UNIT_STATE.SWITCH_OUT)
end
function BattleUnitComp:getModelId() function BattleUnitComp:getModelId()
return self.modelId return self.modelId
end end
@ -52,7 +43,6 @@ function BattleUnitComp:_initBase()
self.attackTime = 0 self.attackTime = 0
self.currAttackDuration = 0 self.currAttackDuration = 0
self.currAttackKeyTime = 0 self.currAttackKeyTime = 0
self.switchTime = 0
self.isPlayHurt = 0 self.isPlayHurt = 0
self.attackDurationMap = {} self.attackDurationMap = {}
self.buffList = {} self.buffList = {}
@ -205,10 +195,6 @@ function BattleUnitComp:changeState(state)
self:exitDeadState() self:exitDeadState()
elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then
self:exitEnterBattlefieldState() self:exitEnterBattlefieldState()
elseif self.currState == UNIT_STATE.SWITCH_IN then
self:exitSwitchInState()
elseif self.currState == UNIT_STATE.SWITCH_OUT then
self:exitSwitchOutState()
end end
-- 进入目标状态 -- 进入目标状态
self.currState = state self.currState = state
@ -226,10 +212,6 @@ function BattleUnitComp:changeState(state)
self:enterBornState() self:enterBornState()
elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then
self:enterEnterBattlefieldState() self:enterEnterBattlefieldState()
elseif self.currState == UNIT_STATE.SWITCH_IN then
self:enterSwitchInState()
elseif self.currState == UNIT_STATE.SWITCH_OUT then
self:enterSwitchOutState()
end end
return true return true
end end
@ -243,40 +225,6 @@ function BattleUnitComp:repeatCurrState()
return false return false
end 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) function BattleUnitComp:updateDead(dt)
self.deadTime = self.deadTime - dt self.deadTime = self.deadTime - dt
if self.deadTime <= 0 then if self.deadTime <= 0 then
@ -763,10 +711,6 @@ function BattleUnitComp:tick(dt)
self:updateAssistingAttackState(dt) self:updateAssistingAttackState(dt)
elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then elseif self.currState == UNIT_STATE.ENTER_BATTLEFIELD then
self:updateEnterBattlefieldState(dt) 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
end end

View File

@ -6,9 +6,11 @@ local BattleController = class("BattleController")
local BATTLE_BOARD_SKILL_HANDLE = require "app/module/battle/skill/battle_board_skill_handle" 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 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 ELIMINATION_TOUCH_EVENT = GConst.ELIMINATION_TOUCH_EVENT
local BattleConst = GConst.BattleConst local BattleConst = GConst.BattleConst
local BUFF_NAME_TO_ATTR = BattleConst.BUFF_NAME_TO_ATTR
-- *************各个子模块的战斗需要重写的方法 START************* -- *************各个子模块的战斗需要重写的方法 START*************
function BattleController:getChapterId() function BattleController:getChapterId()
@ -651,18 +653,18 @@ end
function BattleController:generateInstructions(skillEntity, elementType, influenceElementType, elementTypeMap) function BattleController:generateInstructions(skillEntity, elementType, influenceElementType, elementTypeMap)
---- 加buff ---- 加buff
if skillEntity then if skillEntity then
if skillEntity:getLinkAtkp() > 0 and elementType then -- if skillEntity:getLinkEffects() > 0 and elementType then
local attrType = BattleConst.ELEMENT_TYPE_ATKP_NAME[elementType] -- local attrType = BattleConst.ELEMENT_TYPE_ATKP_NAME[elementType]
if attrType then -- if attrType then
table.insert(self.instructions, { -- table.insert(self.instructions, {
name = BattleConst.INSTRUCTION_NAME.ADD_CUR_ROUND_ATTR, -- name = BattleConst.INSTRUCTION_NAME.ADD_CUR_ROUND_ATTR,
attr = { -- attr = {
type = attrType, -- type = attrType,
num = skillEntity:getLinkAtkp() -- num = skillEntity:getLinkEffects()
} -- }
}) -- })
end -- end
end -- end
if skillEntity:getInInfluenceAtkp() > 0 and influenceElementType then if skillEntity:getInInfluenceAtkp() > 0 and influenceElementType then
for elementType, _ in pairs(influenceElementType) do for elementType, _ in pairs(influenceElementType) do
@ -1134,34 +1136,26 @@ end
function BattleController:addHeroAttr(attrName, value) function BattleController:addHeroAttr(attrName, value)
Logger.logHighlight("------addHeroAttr------ " .. attrName .. " " .. value) Logger.logHighlight("------addHeroAttr------ " .. attrName .. " " .. value)
-- if attrName == then if not self.battleData or not self.battleData.atkTeam then
-- -- body return
-- elseif attrName == then
-- -- body
-- elseif attrName == then'
-- -- body
-- elseif attrName == then
-- -- body
-- elseif attrName == then
-- -- body
-- else
-- end
end end
function BattleController:changeSkillId(elementType, skillId) local attr = BUFF_NAME_TO_ATTR[attrName]
Logger.logHighlight("------changeSkillId------ " .. elementType .. " " .. skillId) 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
function BattleController:addSkillReleaseCount(elementType, count)
Logger.logHighlight("------addSkillReleaseCount------ " .. elementType .. " " .. count)
end end
function BattleController:addSkillEffectParams(elementType, effect)
Logger.logHighlight("------addSkillEffectParams------ " .. elementType .. " " .. json.encode(effect))
end end
function BattleController:addSkillRound(elementType, effect)
Logger.logHighlight("------addSkillRound------ " .. elementType .. " " .. json.encode(effect))
end end
function BattleController:addSkillEffect(elementType, effects) function BattleController:addSkillEffect(elementType, effects)

View File

@ -13,8 +13,17 @@ local _changeBaseSkill = function(skillInfo, battleData, battleController)
return return
end end
local skillEntity = battleData:getSkillEntityByElement(elementType)
if skillEntity then
local skillId = skillEntity:getSkillId()
battleData:changeSkillId(elementType, newSkillId) battleData:changeSkillId(elementType, newSkillId)
battleController: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 end
local _addEliminationRange = function(skillInfo, battleData, battleController) local _addEliminationRange = function(skillInfo, battleData, battleController)
@ -43,18 +52,24 @@ end
local _addLinkAtkp = function(skillInfo, battleData, battleController) local _addLinkAtkp = function(skillInfo, battleData, battleController)
local elementType = skillInfo.skill_position local elementType = skillInfo.skill_position
if not elementType or not skillInfo.parameter then if not elementType or not skillInfo.effect then
return return
end end
local atkp = skillInfo.parameter[1] if not battleController.battleData or not battleController.battleData.atkTeam then
if not atkp then
return return
end end
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) local entity = battleData:getSkillEntityByElement(elementType)
if entity then if entity then
entity:addLinkAtkp(atkp) entity:addLinkEffect(effect, unitEntity)
end
end end
end end
@ -92,7 +107,7 @@ local _addSkillReleaseCount = function(skillInfo, battleData, battleController)
return return
end end
battleController:addSkillReleaseCount(elementType, count) -- battleController:addSkillReleaseCount(elementType, count)
end end
local _addSkillEffectParams = function(skillInfo, battleData, battleController) local _addSkillEffectParams = function(skillInfo, battleData, battleController)
@ -120,7 +135,16 @@ local _addSkillEffectParams = function(skillInfo, battleData, battleController)
return return
end 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 end
local _addSkillRound = function(skillInfo, battleData, battleController) local _addSkillRound = function(skillInfo, battleData, battleController)
@ -141,7 +165,7 @@ local _addSkillRound = function(skillInfo, battleData, battleController)
local effectCfg = entity:getEffect()[index] local effectCfg = entity:getEffect()[index]
if effectCfg then if effectCfg then
effect = GFunc.getTable(effectCfg) effect = GFunc.getTable(effectCfg)
effect.num = value effect.round = value
end end
end end
@ -149,7 +173,17 @@ local _addSkillRound = function(skillInfo, battleData, battleController)
return return
end 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 end
local _addSkillEffect = function(skillInfo, battleData, battleController) local _addSkillEffect = function(skillInfo, battleData, battleController)
@ -168,18 +202,22 @@ end
local _addSkillInInfluenceAtkp = function(skillInfo, battleData, battleController) local _addSkillInInfluenceAtkp = function(skillInfo, battleData, battleController)
local elementType = skillInfo.skill_position local elementType = skillInfo.skill_position
if not elementType or not skillInfo.parameter then if not elementType or not skillInfo.effect then
return return
end end
local atkp = skillInfo.parameter[1] if not battleController.battleData or not battleController.battleData.atkTeam then
if not atkp then return
end
local unitEntity = battleController.battleData.atkTeam:getAllMembers()[elementType]
if not unitEntity then
return return
end end
local entity = battleData:getSkillEntityByElement(elementType) local entity = battleData:getSkillEntityByElement(elementType)
if entity then for _, effect in ipairs(skillInfo.effect) do
entity:addInInfluenceAtkp(atkp) entity:addInInfluenceEffect(effect, unitEntity)
end end
end end
@ -189,10 +227,19 @@ local _addSkillGeneralAttackEffect = function(skillInfo, battleData, battleContr
return return
end 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) local entity = battleData:getSkillEntityByElement(elementType)
if entity then if entity then
for _, effect in ipairs(skillInfo.effect) do for _, effect in ipairs(skillInfo.effect) do
entity:addGeneralAttackEffect(effect) entity:addGeneralAttackEffect(effect, unitEntity)
end end
end end
end end
@ -203,10 +250,19 @@ local _addSkillElementCountEffect = function(skillInfo, battleData, battleContro
return return
end 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) local entity = battleData:getSkillEntityByElement(elementType)
if entity then if entity then
for _, effect in ipairs(skillInfo.effect) do for _, effect in ipairs(skillInfo.effect) do
entity:addElementCountEffect(effect) entity:addElementCountEffect(effect, unitEntity)
end end
end end
end end

View File

@ -96,6 +96,10 @@ function BattleTeam:changeMainUnit(matchType)
unit:playSwitchIn() unit:playSwitchIn()
end end
function BattleTeam:getUnitComp()
return self.unitMap
end
function BattleTeam:tick(dt) function BattleTeam:tick(dt)
for k, v in ipairs(self.unitList) do for k, v in ipairs(self.unitList) do
v:tick(dt) v:tick(dt)

View File

@ -1,13 +1,15 @@
local BattleBoardSkillEnity = class("BattleBoardSkillEnity", BaseData) local BattleBoardSkillEnity = class("BattleBoardSkillEnity", BaseData)
local BattleBuffEntity = require "app/userdata/battle/skill/battle_buff_entity"
function BattleBoardSkillEnity:ctor(skillId) function BattleBoardSkillEnity:ctor(skillId)
self:refreshSkillId(skillId) self:refreshSkillId(skillId)
self.curEnergy = 0 self.curEnergy = 0
self.addRange = {} self.addRange = {}
self.linkAtkp = 0 self.linkEffectEntities = 0
self.inInfluenceAtkp = 0 self.inInfluenceEntities = 0
self.generalAttackEffect = {} self.generalAttackEffectEntities = {}
self.elementCountEffect = {} self.elementCountEffectEntities = {}
self.cacheBuffEntities = {}
end end
function BattleBoardSkillEnity:refreshSkillId(skillId) function BattleBoardSkillEnity:refreshSkillId(skillId)
@ -153,44 +155,89 @@ function BattleBoardSkillEnity:setIgnoreElementType(ignore)
self.ignoreElementType = ignore self.ignoreElementType = ignore
end end
function BattleBoardSkillEnity:getLinkAtkp() function BattleBoardSkillEnity:getLinkEffects()
return self.linkAtkp return self.linkEffectEntities
end end
function BattleBoardSkillEnity:addLinkAtkp(atkp) function BattleBoardSkillEnity:addLinkEffect(effect, unitEntity)
self.linkAtkp = self.linkAtkp + atkp 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 end
function BattleBoardSkillEnity:getInInfluenceAtkp() function BattleBoardSkillEnity:getInInfluenceAtkp()
return self.inInfluenceAtkp return self.inInfluenceEntities
end end
function BattleBoardSkillEnity:addInInfluenceAtkp(atkp) function BattleBoardSkillEnity:addInInfluenceEffect(effect, unitEntity)
self.inInfluenceAtkp = self.inInfluenceAtkp + atkp local buffEntity = self.inInfluenceEntities[effect.type]
end if not buffEntity then
buffEntity = BattleBuffEntity:create()
function BattleBoardSkillEnity:addGeneralAttackEffect(effect) buffEntity:init(effect, unitEntity)
if not self.generalAttackEffect[effect.type] then self.inInfluenceEntities[effect.type] = buffEntity
self.generalAttackEffect[effect.type] = GFunc.getTable(effect)
else 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
end end
function BattleBoardSkillEnity:getGeneralAttackEffect() function BattleBoardSkillEnity:getGeneralAttackEffect()
return self.generalAttackEffect return self.generalAttackEffectEntities
end end
function BattleBoardSkillEnity:addElementCountEffect(effect) function BattleBoardSkillEnity:addElementCountEffect(effect, unitEntity)
if not self.elementCountEffect[effect.type] then local buffEntity = self.elementCountEffectEntities[effect.type]
self.elementCountEffect[effect.type] = GFunc.getTable(effect) if not buffEntity then
buffEntity = BattleBuffEntity:create()
buffEntity:init(effect, unitEntity)
self.elementCountEffectEntities[effect.type] = buffEntity
else 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
end end
function BattleBoardSkillEnity:getElementCountEffect() 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 end
return BattleBoardSkillEnity return BattleBoardSkillEnity

View File

@ -13,6 +13,10 @@ function BattleBuffEntity:init(effectParams, owner)
self.buffType = self.buffInfo.buff_type self.buffType = self.buffInfo.buff_type
end end
function BattleBuffEntity:setOwner(owner)
self.owner = owner
end
function BattleBuffEntity:getName() function BattleBuffEntity:getName()
return self.name return self.name
end end
@ -25,6 +29,10 @@ function BattleBuffEntity:getEffectNum()
return self.effectNum return self.effectNum
end end
function BattleBuffEntity:setEffectNum(num)
self.effectNum = num
end
function BattleBuffEntity:getFormula() function BattleBuffEntity:getFormula()
return self.buffInfo.formula return self.buffInfo.formula
end end
@ -33,10 +41,18 @@ function BattleBuffEntity:getRatio()
return self.ratio return self.ratio
end end
function BattleBuffEntity:setRatio(ratio)
self.ratio = ratio
end
function BattleBuffEntity:getRound() function BattleBuffEntity:getRound()
return self.round return self.round
end end
function BattleBuffEntity:setRound(num)
self.round = num
end
function BattleBuffEntity:getBuffHitFxId() function BattleBuffEntity:getBuffHitFxId()
return nil return nil
end end

View File

@ -25,6 +25,49 @@ function BattleSkillEntity:initSkillEffect()
end end
end 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() function BattleSkillEntity:getMoveType()
return self.skillInfo.position return self.skillInfo.position
end end

View File

@ -79,6 +79,33 @@ function BattleUnitEntity:getNormalSkillNameList()
return self.normalSkillNameList, count return self.normalSkillNameList, count
end 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) function BattleUnitEntity:takeDamageOrCure(num)
return self.team:takeDamageOrCure(num) return self.team:takeDamageOrCure(num)
end end