public void ReadytoStart(GameState state) { lock (gameHistory) { if (!gameHistory.ContainsKey(state.getRound())) { gameHistory.Add(state.getRound(), state); } } if (!gameStarted) { gameStarted = true; } form.Invoke(new startDelegate(form.StartScreen)); }
public void ClientGameLoop() { SpinWait.SpinUntil(() => ScreenStarted == true); GameState stateRound = RemoteClient.updateRound; new Thread(() => updateGhostsPositions(stateRound)) { Priority = ThreadPriority.Highest }.Start(); Task.Run(() => { checkCoins(stateRound); updateScore(stateRound); }); new Thread(() => updatePacmansPositions(stateRound)).Start(); checkWinLost(stateRound); round = stateRound.getRound() + 1; if (!urlFile.Equals("noFile") && commandsDic.ContainsKey(round)) { Thread t5 = new Thread(() => { try { int roundThread = round; if (InjectDelay(RemoteClient.serverPID)) { Thread.Sleep(TIMEDELAY); } server.SendMovement(PID_init, roundThread, commandsDic[round]); } catch (Exception) { } }); t5.Start(); } }
public void StateRound(GameState state) { updateRound = state; lock (gameHistory) { if (!gameHistory.ContainsKey(state.getRound())) { gameHistory.Add(state.getRound(), state); } } if (!gameStarted) { ReadytoStart(state); } if (!isFroozen) { form.Invoke(new updateDelegate(form.ClientGameLoop)); } }