战斗加速
This commit is contained in:
parent
5328e6dc7c
commit
fa4e1ebd3c
@ -38,6 +38,13 @@ BattleConst.BATTLE_ROUND_STEP = {
|
|||||||
ON_END = 10, -- 回合结束
|
ON_END = 10, -- 回合结束
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BattleConst.TIME_SCALE = {
|
||||||
|
LEVEL_0 = 0,
|
||||||
|
LEVEL_1 = 1,
|
||||||
|
LEVEL_2 = 1.5,
|
||||||
|
LEVEL_3 = 2,
|
||||||
|
}
|
||||||
|
|
||||||
-- 为方便存储,这里使用字符串
|
-- 为方便存储,这里使用字符串
|
||||||
BattleConst.BATTLE_TYPE = {
|
BattleConst.BATTLE_TYPE = {
|
||||||
STAGE = "1",
|
STAGE = "1",
|
||||||
|
|||||||
@ -67,6 +67,7 @@ function BattleUnitComp:_initBase()
|
|||||||
self.currActiveSkill = nil
|
self.currActiveSkill = nil
|
||||||
self.targetX = nil
|
self.targetX = nil
|
||||||
self.assistingDmgAddition = 0
|
self.assistingDmgAddition = 0
|
||||||
|
self.attackCount = 0
|
||||||
self.currState = UNIT_STATE.INIT
|
self.currState = UNIT_STATE.INIT
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -88,6 +89,10 @@ function BattleUnitComp:prepare()
|
|||||||
self:checkPassiveEvent(PASSIVE_EVENT.HP_LOWER_THAN, nil, self.unitEntity:getHpPercent())
|
self:checkPassiveEvent(PASSIVE_EVENT.HP_LOWER_THAN, nil, self.unitEntity:getHpPercent())
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:resetBeforeAttack()
|
||||||
|
self.attackCount = 0
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUnitComp:initPassiveSkills()
|
function BattleUnitComp:initPassiveSkills()
|
||||||
local pasSkills = self.unitEntity:getPassiveSkills()
|
local pasSkills = self.unitEntity:getPassiveSkills()
|
||||||
if pasSkills and #pasSkills > 0 then
|
if pasSkills and #pasSkills > 0 then
|
||||||
@ -503,6 +508,7 @@ function BattleUnitComp:enterAssistingAttackState()
|
|||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
|
self:attackAndSpeedUp()
|
||||||
self:initPosition()
|
self:initPosition()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -564,6 +570,7 @@ function BattleUnitComp:enterSkillAttackState()
|
|||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
|
self:attackAndSpeedUp()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -695,12 +702,22 @@ function BattleUnitComp:onAttackOver()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleUnitComp:attackAndSpeedUp()
|
||||||
|
self.attackCount = self.attackCount + 1
|
||||||
|
if self.attackCount == 3 then
|
||||||
|
DataManager.BattleData:addTimeSpeed()
|
||||||
|
elseif self.attackCount == 5 then
|
||||||
|
DataManager.BattleData:addTimeSpeed()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function BattleUnitComp:doNextSkillAttack()
|
function BattleUnitComp:doNextSkillAttack()
|
||||||
self.attackTime = 0
|
self.attackTime = 0
|
||||||
local attackName = self.currActiveSkill:getSkillAttackName()
|
local attackName = self.currActiveSkill:getSkillAttackName()
|
||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
|
self:attackAndSpeedUp()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:doNextNormalAttack()
|
function BattleUnitComp:doNextNormalAttack()
|
||||||
@ -710,6 +727,7 @@ function BattleUnitComp:doNextNormalAttack()
|
|||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
|
self:attackAndSpeedUp()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleUnitComp:doNextAttack()
|
function BattleUnitComp:doNextAttack()
|
||||||
@ -725,6 +743,7 @@ function BattleUnitComp:doNextAttack()
|
|||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
|
self:attackAndSpeedUp()
|
||||||
else -- 归位
|
else -- 归位
|
||||||
self:moveBackToInitPosition()
|
self:moveBackToInitPosition()
|
||||||
end
|
end
|
||||||
@ -753,6 +772,7 @@ function BattleUnitComp:enterNormalAttackState()
|
|||||||
self.currAttackDuration = self:getAnimationDuration(attackName)
|
self.currAttackDuration = self:getAnimationDuration(attackName)
|
||||||
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
self.currAttackKeyTime = self:getAnimationKeyFrameTime(attackName)
|
||||||
self:playAnimation(attackName, false, false)
|
self:playAnimation(attackName, false, false)
|
||||||
|
self:attackAndSpeedUp()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -148,11 +148,23 @@ function BattleController:init(params)
|
|||||||
BattleScheduler:init()
|
BattleScheduler:init()
|
||||||
BattleHelper:init()
|
BattleHelper:init()
|
||||||
BattlePassive:init()
|
BattlePassive:init()
|
||||||
|
self:setTimeScale(DataManager.BattleData:getTimeScale())
|
||||||
|
self:bindData()
|
||||||
self:initBattleTeam()
|
self:initBattleTeam()
|
||||||
self:initOther()
|
self:initOther()
|
||||||
self:prepareFight()
|
self:prepareFight()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleController:bindData()
|
||||||
|
DataManager.BattleData:bind("timeSpeed", ModuleManager.BattleManager, function()
|
||||||
|
self:setTimeScale(DataManager.BattleData:getTimeScale())
|
||||||
|
end, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleController:unBindAll()
|
||||||
|
DataManager.BattleData:unBind("timeSpeed", ModuleManager.BattleManager)
|
||||||
|
end
|
||||||
|
|
||||||
function BattleController:initBattleTeam()
|
function BattleController:initBattleTeam()
|
||||||
self.atkTeam = BattleTeam:create()
|
self.atkTeam = BattleTeam:create()
|
||||||
self.atkTeam:init(BattleConst.SIDE_ATK, self)
|
self.atkTeam:init(BattleConst.SIDE_ATK, self)
|
||||||
@ -245,6 +257,12 @@ function BattleController:battleStart()
|
|||||||
self:enterNextWave()
|
self:enterNextWave()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleController:setTimeScale(timeScale)
|
||||||
|
GFunc.setDOTweenTimeScale(GConst.DOTWEEN_IDS.BATTLE, timeScale)
|
||||||
|
BattleScheduler:setTimeScale(timeScale)
|
||||||
|
BattleHelper:setTimeScale(timeScale)
|
||||||
|
end
|
||||||
|
|
||||||
---- start 回合步骤
|
---- start 回合步骤
|
||||||
|
|
||||||
function BattleController:enterNextWave()
|
function BattleController:enterNextWave()
|
||||||
@ -366,6 +384,7 @@ function BattleController:enterRefreshBoard()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:enterRoundEnd()
|
function BattleController:enterRoundEnd()
|
||||||
|
DataManager.BattleData:resetTimeSpeed()
|
||||||
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_END
|
self.roundStep = BattleConst.BATTLE_ROUND_STEP.ON_END
|
||||||
local defTeam = self.battleData:getDefTeam()
|
local defTeam = self.battleData:getDefTeam()
|
||||||
if not defTeam or defTeam:getIsDead() then -- 怪物死了, 直接进入刷新逻辑
|
if not defTeam or defTeam:getIsDead() then -- 怪物死了, 直接进入刷新逻辑
|
||||||
@ -1299,6 +1318,8 @@ function BattleController:clear()
|
|||||||
BattleScheduler:clear()
|
BattleScheduler:clear()
|
||||||
BattleHelper:clear()
|
BattleHelper:clear()
|
||||||
BattlePassive:clear()
|
BattlePassive:clear()
|
||||||
|
self:unBindAll()
|
||||||
|
DataManager.BattleData:resetTimeSpeed()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleController:endBattleAndExit()
|
function BattleController:endBattleAndExit()
|
||||||
|
|||||||
@ -12,6 +12,19 @@ function BattleHelper:init()
|
|||||||
self.seed = tonumber(tostring(os.time()):reverse():sub(1,6))
|
self.seed = tonumber(tostring(os.time()):reverse():sub(1,6))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleHelper:setTimeScale(timeScale)
|
||||||
|
if self.effectMap then
|
||||||
|
for k, effect in pairs(self.effectMap) do
|
||||||
|
effect:setTimeScale(timeScale)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if self.characterMap then
|
||||||
|
for k, character in pairs(self.characterMap) do
|
||||||
|
character:setTimeScale(timeScale)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function BattleHelper:random(min, max)
|
function BattleHelper:random(min, max)
|
||||||
self.seed = (self.seed*9301 + 49297)%233280
|
self.seed = (self.seed*9301 + 49297)%233280
|
||||||
return min + self.seed*(max - min + 1)//233280
|
return min + self.seed*(max - min + 1)//233280
|
||||||
@ -25,12 +38,16 @@ function BattleHelper:loadBattleHeroModel(id, parent, callback)
|
|||||||
if self.characterMap then
|
if self.characterMap then
|
||||||
self.characterMap[spineObject:getInstanceID()] = spineObject
|
self.characterMap[spineObject:getInstanceID()] = spineObject
|
||||||
end
|
end
|
||||||
|
local timeScale = DataManager.BattleData:getTimeScale()
|
||||||
|
spineObject:setTimeScale(timeScale)
|
||||||
callback(spineObject)
|
callback(spineObject)
|
||||||
else
|
else
|
||||||
SpineManager:loadHeroAsync(id, parent, function(spineObject)
|
SpineManager:loadHeroAsync(id, parent, function(spineObject)
|
||||||
spineObject:setDefaultMix(0)
|
spineObject:setDefaultMix(0)
|
||||||
if self.characterMap then
|
if self.characterMap then
|
||||||
self.characterMap[spineObject:getInstanceID()] = spineObject
|
self.characterMap[spineObject:getInstanceID()] = spineObject
|
||||||
|
local timeScale = DataManager.BattleData:getTimeScale()
|
||||||
|
spineObject:setTimeScale(timeScale)
|
||||||
callback(spineObject)
|
callback(spineObject)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
@ -56,6 +56,7 @@ function BattleTeam:useNormalSkill(matchType, count, callback)
|
|||||||
self.mainUnit = unit
|
self.mainUnit = unit
|
||||||
self.battleController:setIsPauseHpProgress(true)
|
self.battleController:setIsPauseHpProgress(true)
|
||||||
unit:beforeAttack()
|
unit:beforeAttack()
|
||||||
|
unit:resetBeforeAttack()
|
||||||
unit:useNormalSkill(count, callback)
|
unit:useNormalSkill(count, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,6 +73,7 @@ function BattleTeam:useSkill(matchType, count, callback)
|
|||||||
self.mainUnit = unit
|
self.mainUnit = unit
|
||||||
self.battleController:setIsPauseHpProgress(true)
|
self.battleController:setIsPauseHpProgress(true)
|
||||||
unit:beforeAttack()
|
unit:beforeAttack()
|
||||||
|
unit:resetBeforeAttack()
|
||||||
unit:useSkill(1, count, callback)
|
unit:useSkill(1, count, callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -89,6 +91,7 @@ function BattleTeam:useAssistingSkill(assistingList, callback)
|
|||||||
for _, v in ipairs(assistingList) do
|
for _, v in ipairs(assistingList) do
|
||||||
local unit = self.unitMap[v.skillMatch]
|
local unit = self.unitMap[v.skillMatch]
|
||||||
if unit then
|
if unit then
|
||||||
|
unit:resetBeforeAttack()
|
||||||
unit:useAssistingSkill(v.count, finish)
|
unit:useAssistingSkill(v.count, finish)
|
||||||
else
|
else
|
||||||
finish()
|
finish()
|
||||||
@ -99,6 +102,7 @@ end
|
|||||||
function BattleTeam:mainUnitUseAllSkills(callback)
|
function BattleTeam:mainUnitUseAllSkills(callback)
|
||||||
self.battleController:setIsPauseHpProgress(true)
|
self.battleController:setIsPauseHpProgress(true)
|
||||||
self.mainUnit:beforeAttack()
|
self.mainUnit:beforeAttack()
|
||||||
|
self.mainUnit:resetBeforeAttack()
|
||||||
self.mainUnit:useAllSkills(callback)
|
self.mainUnit:useAllSkills(callback)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,8 @@ function BattleData:init()
|
|||||||
self.curBattleExp = 0
|
self.curBattleExp = 0
|
||||||
self.needBattleExp = self:getLvNeedExp()
|
self.needBattleExp = self:getLvNeedExp()
|
||||||
self.addLvCount = 0
|
self.addLvCount = 0
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
||||||
|
self.data.timeSpeed = 1
|
||||||
self.data.lvDirty = false
|
self.data.lvDirty = false
|
||||||
BattleSkillEntity.sid = 0
|
BattleSkillEntity.sid = 0
|
||||||
self.atkTeam = self:initTeam(BattleConst.SIDE_ATK)
|
self.atkTeam = self:initTeam(BattleConst.SIDE_ATK)
|
||||||
@ -24,6 +26,68 @@ function BattleData:init()
|
|||||||
self:initRogueSkills()
|
self:initRogueSkills()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function BattleData:getTimeScale()
|
||||||
|
return self.timeScale
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleData:pauseBattle()
|
||||||
|
self.cacheSpeed = self.data.timeSpeed
|
||||||
|
self:setTimeSpeed(0)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleData:resumeBattle()
|
||||||
|
if self.cacheSpeed == nil then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.data.timeSpeed ~= 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:setTimeSpeed(self.cacheSpeed or 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleData:resetTimeSpeed()
|
||||||
|
if self.cacheSpeed then -- 目前处于暂停状态
|
||||||
|
self.cacheSpeed = 1
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.data.timeSpeed <= 1 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
self:setTimeSpeed(1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleData:addTimeSpeed()
|
||||||
|
if self.data.timeSpeed >= 3 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.cacheSpeed then -- 目前处于暂停状态
|
||||||
|
if self.cacheSpeed < 3 then
|
||||||
|
self.cacheSpeed = self.cacheSpeed + 1
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local timeSpeed = self.data.timeSpeed + 1
|
||||||
|
self:setTimeSpeed(timeSpeed)
|
||||||
|
end
|
||||||
|
|
||||||
|
function BattleData:setTimeSpeed(timeSpeed)
|
||||||
|
if timeSpeed == self.data.timeSpeed then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if timeSpeed == 0 then
|
||||||
|
self.timeScale = 0
|
||||||
|
elseif timeSpeed == 1 then
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
||||||
|
elseif timeSpeed == 2 then
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_2
|
||||||
|
elseif timeSpeed == 3 then
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_3
|
||||||
|
else
|
||||||
|
self.timeScale = BattleConst.TIME_SCALE.LEVEL_1
|
||||||
|
end
|
||||||
|
self.data.timeSpeed = timeSpeed
|
||||||
|
end
|
||||||
|
|
||||||
function BattleData:initRogueSkills()
|
function BattleData:initRogueSkills()
|
||||||
self.skillPool = {}
|
self.skillPool = {}
|
||||||
self.skillMap = {}
|
self.skillMap = {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user