local Base = require("Battle/Logic/Level/LevelFunction/LevelFunction") local ResourceLevelFunction = class("ResourceLevelFunction",Base) local MONSTER_SHOW_RANGE_SQR = FP.newV1(1000000) function ResourceLevelFunction:GetMonsterShowRangeSqr() return MONSTER_SHOW_RANGE_SQR end function ResourceLevelFunction:BeginLevel() Base.BeginLevel(self) self.frameCount = 0 self.isDriving = false end function ResourceLevelFunction:CreatePlayers(pos, dir) Base.CreatePlayers(self) --增加禁止下载具的buff SystemManager.AddBuff(LogicUpdateManager._curEntity, LuaConst.SpecialBuffs.CantOffDrive, LogicUpdateManager._curEntity) --SystemManager.Background(LogicUpdateManager._curEntity) end function ResourceLevelFunction:OnUpdate() self.frameCount = self.frameCount + 1 if not self.isDriving and self.frameCount < 50 then --ugly 写死一个持续50帧的判断,看看有没有载具,有就上车 self:TryDrive() end end function ResourceLevelFunction:TryDrive() for k,v in pairs(LogicUpdateManager._entityDic) do if v:IsVehicle() then self.isDriving = true --SystemManager.Active(LogicUpdateManager._curEntity) SystemManager.ForceDrive(LogicUpdateManager._curEntity, v) break end end end function ResourceLevelFunction:OnLevelSucceed(withShow) SystemManager.DeleteBuff(LogicUpdateManager._curEntity, LuaConst.SpecialBuffs.CantOffDrive) Base.OnLevelSucceed(self, withShow) end return ResourceLevelFunction