--副将 local FirstPersonEventDispatcher = require"Battle/Logic/Event/FirstPersonEventDispatcher" local AdjutantSystem = {} local private = {} local LuaConst=LuaConst --事件系统 local EventSystem = require('Event/EventSystem') --[[ Tick --]] function AdjutantSystem.OnLogicUpdate(entity) local comp_Adjutant = entity.components.adjutant if comp_Adjutant.AdjutantCD > 0 then comp_Adjutant.AdjutantCD = comp_Adjutant.AdjutantCD - LuaConst.TimeSpanMs if comp_Adjutant.AdjutantCD <= 0 then private.ExitCD(entity,comp_Adjutant) end end end --[[ 释放副将技 --]] function AdjutantSystem.OnReleaseAdjutantSkill(entity, skillJoystickPosX, skillJoystickPosZ) --这里要用主将的skillBase判断键位是否被禁用 if not entity.components.skillBase:IsKeyPosBanned(LuaConst.ESkillKeyPosition.Adjutant) and entity.components.buff.CurrentBuffStates:Get(LuaConst.SpecialBuffs.CanSkill) then --新增判断,必须能使用技能时,才能放副将技 local comp_Adjutant = entity.components.adjutant local adjustEntity = comp_Adjutant.AdjutantEntity if comp_Adjutant.AdjutantCD > 0 or not adjustEntity then return end local adjutantSkillData local masterMoveComponent = entity.components.move if skillJoystickPosX == FP.Const.Zero and skillJoystickPosZ == FP.Const.Zero then comp_Adjutant:SetCurHasSkillJoy(false) local target = entity.components.target.Target if target then adjutantSkillData = entity.components.adjutant.AdjutantEntity.components.skillBase:GetSkillDataByKeyPosition(LuaConst.ESkillKeyPosition.AdjutantSkillMain) if adjutantSkillData then local adjutantSkillJoystickData = adjustEntity.components.skillBase:GetSkillJoystickData(adjutantSkillData.ID) if adjutantSkillJoystickData and adjutantSkillJoystickData.UEType == LuaConst.ESkillJoystickUEType.JOYSTICK_RANGE then local targetLogicPos = target:GetLogicPos() local entityPos = entity:GetLogicPos() skillJoystickPosX = targetLogicPos.x - entityPos.x skillJoystickPosZ = targetLogicPos.z - entityPos.z end end end else comp_Adjutant:SetCurHasSkillJoy(true) end local pos = private.GetAdjutantPos(masterMoveComponent, adjustEntity, skillJoystickPosX, skillJoystickPosZ) local dir = private.GetAdjutantDir(entity, skillJoystickPosX, skillJoystickPosZ) SystemManager.OnConvey(adjustEntity, pos, dir) adjustEntity:OnActive() BattleEventSystem.OnUseAdjutantSkill(entity, adjustEntity, adjutantSkillData) if GlobalBattleData.Get_IsSkillNoCD() and entity._logicInitData.IsPlayerSelf then return end local time =adjustEntity.components.base.CurCharacterData.FuJiangCD * 1000 -- m -> ms private.EnterCD(entity, comp_Adjutant, time) end end function AdjutantSystem.ForceEnterCD(entity) local comp_Adjutant = entity.components.adjutant local adjutantEntity = comp_Adjutant.AdjutantEntity if adjutantEntity then private.EnterCD(entity, comp_Adjutant, adjutantEntity.components.base.CurCharacterData.FuJiangCD * 1000) end end function AdjutantSystem.OnConvey(entity) local comp_Adjutant = entity.components.adjutant local entity_Adjutant = comp_Adjutant.AdjutantEntity if entity_Adjutant then SystemManager.ChangeToSwitchAll(entity, false, LuaConst.SkillInterruptType.BreakEffect) SystemManager.SetNextState(LuaConst.StateType.Idle, entity_Adjutant, 0) SystemManager.OnBreakPSEffectAll(entity_Adjutant) SystemManager.Background(entity_Adjutant) end end function private.EnterCD(entity,comp_Adjutant,time) comp_Adjutant.AdjutantCD = time if not comp_Adjutant.TotalCD then comp_Adjutant.TotalCD = time end -- 主视角事件统一用 FirstPersonEventDispatcher 派发 FirstPersonEventDispatcher.Player_AdjutantCoolDown(entity, time) end function private.ExitCD(entity, comp_Adjutant) comp_Adjutant.AdjutantCD = -1 comp_Adjutant.TotalCD = nil -- 主视角事件统一用 FirstPersonEventDispatcher 派发 FirstPersonEventDispatcher.Player_AdjutantCoolDown(entity, nil) end --[[ 获得副将位置 --]] function private.GetAdjutantPos(masterMoveComponent, adjustEntity, skillJoystickPosX, skillJoystickPosZ) --new 走双摇杆的副将技的位置 return masterMoveComponent.LogicPos + FP.newV2(skillJoystickPosX, skillJoystickPosZ) end --[[ 获得副将朝向 --]] function private.GetAdjutantDir(entity, skillJoystickPosX, skillJoystickPosZ) if skillJoystickPosX ~= FP.Const.Zero or skillJoystickPosZ ~= FP.Const.Zero then --new 走双摇杆的副将技的位置 return FP.newV2(skillJoystickPosX, skillJoystickPosZ) else local masterMoveComponent = entity.components.move return masterMoveComponent.LogicRotateDir end end return AdjutantSystem