private void Pause() { bool flag = this.simulationState == AbstractLockstep.SimulationState.RUNNING; if (flag) { this.OnGamePaused(); this.simulationState = AbstractLockstep.SimulationState.PAUSED; } }
private void End() { if (this.simulationState != AbstractLockstep.SimulationState.ENDED) { this.OnGameEnded(); if (this.replayMode == ReplayMode.RECORD_REPLAY) { ReplayRecord.SaveRecord(this.replayRecord); } this.simulationState = AbstractLockstep.SimulationState.ENDED; } }
private void End() { Debug.Log("End"); if (simulationState != SimulationState.ENDED) { OnGameEnded(); if (replayMode == ReplayMode.RECORD_REPLAY) { ReplayRecord.SaveRecord(replayRecord); } simulationState = SimulationState.ENDED; } }
private void Run() { if (this.simulationState == AbstractLockstep.SimulationState.NOT_STARTED) { this.simulationState = AbstractLockstep.SimulationState.WAITING_PLAYERS; //Update函数检测到等待玩家状态,那么就会一直调用ChckeGameStart来确定远端玩家是否连上来了 } else { //checkGameStart里检测到双方玩家都准备好后,会再次调用此函数来执行OnGameStarted if (this.simulationState == AbstractLockstep.SimulationState.WAITING_PLAYERS || this.simulationState == AbstractLockstep.SimulationState.PAUSED) { if (this.simulationState == AbstractLockstep.SimulationState.WAITING_PLAYERS) { this.OnGameStarted(); } else { this.OnGameUnPaused(); } this.simulationState = AbstractLockstep.SimulationState.RUNNING; } } }
private void Run() { Debug.Log("Run"); if (simulationState == SimulationState.NOT_STARTED) { simulationState = SimulationState.WAITING_PLAYERS; } else { if (simulationState == SimulationState.WAITING_PLAYERS || simulationState == SimulationState.PAUSED) { if (simulationState == SimulationState.WAITING_PLAYERS) { OnGameStarted(); } else { OnGameUnPaused(); } simulationState = SimulationState.RUNNING; } } }
public AbstractLockstep(float deltaTime, ICommunicator communicator, IPhysicsManagerBase physicsManager, int syncWindow, int panicWindow, int rollbackWindow, FrameSyncEventCallback OnGameStarted, FrameSyncEventCallback OnGamePaused, FrameSyncEventCallback OnGameUnPaused, FrameSyncEventCallback OnGameEnded, FrameSyncPlayerDisconnectionCallback OnPlayerDisconnection, FrameSyncUpdateCallback OnStepUpdate, FrameSyncInputCallback GetLocalData, FrameSyncInputDataProvider InputDataProvider) { AbstractLockstep.instance = this; this.deltaTime = deltaTime; this.syncWindow = syncWindow; this.panicWindow = panicWindow; this.rollbackWindow = rollbackWindow; this.totalWindow = syncWindow + rollbackWindow; this.StepUpdate = OnStepUpdate; this.OnGameStarted = OnGameStarted; this.OnGamePaused = OnGamePaused; this.OnGameUnPaused = OnGameUnPaused; this.OnGameEnded = OnGameEnded; this.OnPlayerDisconnection = OnPlayerDisconnection; this.GetLocalData = GetLocalData; this.InputDataProvider = InputDataProvider; this.ticks = 0; this.players = new Dictionary <byte, FPPlayer>(4); this.activePlayers = new List <FPPlayer>(4); this.auxPlayersSyncedData = new List <SyncedData>(4); this.auxPlayersInputData = new List <InputDataBase>(4); this.communicator = communicator; bool flag = communicator != null; if (flag) { this.communicator.AddEventListener(new OnEventReceived(this.OnEventDataReceived)); } this.physicsManager = physicsManager; this.compoundStats = new CompoundStats(); this.bufferSyncedInfo = new GenericBufferWindow <SyncedInfo>(3); this.checksumOk = true; this.simulationState = AbstractLockstep.SimulationState.NOT_STARTED; this.bodiesToDestroy = new Dictionary <int, List <IBody> >(); this.playersDisconnect = new Dictionary <int, List <byte> >(); this.ReplayMode = ReplayRecord.replayMode; }