--巡逻相关 local PatrolComponent = class("PatrolComponent") function PatrolComponent:initialize(entity, pos, bornItemID) --巡逻行为:每Idle3-5秒的随机时间,360°随机转换一次移动方向移动(使用walk_front_loop动作)3-5秒 --巡逻的计时器 self.PatrolFrame = 0 --用来记录随机出的 3-5秒的随机时间 self.PatrolTimeLimit = 0 --用来记录随机出的朝向 self.PatrolDir = FP.newV2(0,0) --所属的 MonsterItem 的 ID self.MonsterItemID = 0 --在所属 MonsterItem 中的 序号 self.IndexInMonsterItem = 0 --当前的目标是第几个路径点 self.CurPatrolPathIndex = 1 --在往复的类型下,正向还是反向 self.IsPatrolForward = true --是否按阵形排列 self.InOrder = true --是否强制脱战 self.IsForceReturn = false self.ExitPatrolPoint = entity._logicInitData.BornPoint local itemData = LevelItemManager.GetItemDataByID(bornItemID) if itemData and itemData.LayoutType == LuaConst.EntityLayoutType.Matrix then self.PosOffset = pos - itemData.ItemPos else self.PosOffset = FP.newV2(0,0) end end function PatrolComponent:ResetPathIndex() self.CurPatrolPathIndex = 1 end function PatrolComponent:ForceReturn() self.IsForceReturn = true end function PatrolComponent:CancelForceReturn() self.IsForceReturn = false end return PatrolComponent