private static void Clean(Connection connection) { try { clientsPlaying.Remove(connection); clientAI.Remove(connection); } catch (ArgumentOutOfRangeException) // Called in middle of stopping server { return; } for (int i = 0; i < futureMoves.Count; i++) { FutureMove tmp = futureMoves.Dequeue(); if (tmp.connection != connection) { futureMoves.Enqueue(tmp); } } Program.playground.board[connection.position.X][connection.position.Y] = Square.Empty; GameLogic.changes.Add(new Change(new Point(connection.position.X, connection.position.Y), Square.Empty)); lock (futureMoves) { if (futureMoves.Count == clientsPlaying.Count * 2) { ProcessMoves(); } } }
private static void ProcessMoves() { Program.playground.UpdateFire(); int moveCount = futureMoves.Count / 2; for (int i = 0; i < moveCount; i++) { FutureMove futureMove = futureMoves.Dequeue(); GameLogic.Process(futureMove.movement, futureMove.connection); futureMoves.Enqueue(futureMoves.Dequeue()); } Program.playground.UpdateBombs(); for (int i = 0; i < clientUpdate.Count; i++) { SendChanges(clientUpdate[i]); } GameLogic.changes.Clear(); Form1.updatePictureBox(); Program.playground.UpdateFire(); moveCount = futureMoves.Count; for (int i = 0; i < moveCount; i++) { FutureMove futureMove = futureMoves.Dequeue(); GameLogic.Process(futureMove.movement, futureMove.connection); } Program.playground.UpdateBombs(); updateTimer.Enabled = true; }