--这个只能是给玩家使用,其他怪全部为默认值false local AutoFightComponent = class("AutoFightComponent") local FirstPersonEventDispatcher = require"Battle/Logic/Event/FirstPersonEventDispatcher" function AutoFightComponent:initialize(entity) self.entity = entity --主城自动寻路 self.IsAutoFindPath = false --是否自动联机战斗 self.IsSyncAuto = false --是否自动单机战斗 self.IsStandaloneAuto = false --是否系统级别的自动战斗(不显示自动战斗提示、无法打断自动战斗、遥杆界面会隐藏UIVirtualController) self.IsSystemLevel = false self.TargetPos = nil self.RadiusSqr = nil --自动战斗暂停时长 self.PauseTimer = FP.newV1(0) self.CallBack = nil end function AutoFightComponent:OnEntitySyncFinished(entity) end function AutoFightComponent:IsAuto() return self.IsAutoFindPath or self.IsSyncAuto or self.IsStandaloneAuto end function AutoFightComponent:SetAutoFindPath(pos, radius, callback) self.IsAutoFindPath = true self.TargetPos = pos self.RadiusSqr = radius * radius self.CallBack = callback end function AutoFightComponent:StartAutoFindPath() self.IsAutoFindPath = true end function AutoFightComponent:StopAutoFindPath(townFindPathType) self.IsAutoFindPath = false self.TargetPos = nil self.RadiusSqr = nil self.CallBack = nil if self.entity._logicInitData.IsPlayerSelf then NotSyncBattleSetter.OnStopAutoFindPath(townFindPathType) end end function AutoFightComponent:SwitchPveAutoFightState() self.IsStandaloneAuto = not self.IsStandaloneAuto if not self.IsStandaloneAuto then self.entity.components.aiBase:OnStopAutoFight() --为了省事 这里就这么写了 end FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(self.entity) if self.entity.components.drive.BeDrivedByEntity then LevelManager.CurLevelFunc:SwitchAutoFight(self.entity.components.drive.BeDrivedByEntity) end end function AutoFightComponent:StopPveAutoFight() self.IsSyncAuto = false self.IsStandaloneAuto = false self.IsSystemLevel = false self.entity.components.aiBase:OnStopAutoFight() --为了省事 这里就这么写了 FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(self.entity) end function AutoFightComponent:StartPveAutoFight(isSystemLevel) self.IsStandaloneAuto = true if isSystemLevel == true then self.IsSystemLevel = true else self.IsSystemLevel = false end FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(self.entity) end function AutoFightComponent:SwitchPvpAutoFightState() self.IsSyncAuto = not self.IsSyncAuto if not self.IsSyncAuto then self.entity.components.aiBase:OnStopAutoFight() --为了省事 这里就这么写了 end FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(self.entity) end function AutoFightComponent:StopPvpAutoFight() self.IsSyncAuto = false self.IsSystemLevel = false self.entity.components.aiBase:OnStopAutoFight() --为了省事 这里就这么写了 FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(self.entity) end function AutoFightComponent:StartPvpAutoFight(isSystemLevel) self.IsSyncAuto = true if isSystemLevel == true then self.IsSystemLevel = true else self.IsSystemLevel = false end FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(self.entity) end function AutoFightComponent:IsAutoFight() return self.IsSyncAuto or self.IsStandaloneAuto end return AutoFightComponent