private void PlaceTownsInSecondPassOrder() { GameSessionMessage message = null; UInt32[] playerIndexes = this.gameManager.GetSecondSetupPassOrder(); for (var index = 0; index < this.clients.Length; index++) { var playerIndex = playerIndexes[index]; this.clients[playerIndex].ChooseTownLocation(); Debug.Print("Second pass: Choose town message sent for Index " + playerIndex); while (!this.messageQueue.TryDequeue(out message)) { this.cancellationToken.ThrowIfCancellationRequested(); Thread.Sleep(50); } var placeTownMessage = (PlaceTownMessage)message; Debug.Print("Second pass: Request town message received for location " + placeTownMessage.Location); this.gameManager.PlaceTown(placeTownMessage.Location); for (var clientIndex = 0; clientIndex < this.clients.Length; clientIndex++) { if (clientIndex == playerIndex) { continue; } this.clients[clientIndex].TownPlacedDuringSetup(placeTownMessage.Location); } } }
private void ProcessConfirmGameInitializedMessage(GameSessionMessage message) { if (!this.AllClientsHaveSentMessage(message.Client)) { return; } this.clientsThatReceivedMessages.Clear(); // Clients have all confirmed they received game initialization data // Now ask each client to place a town in dice roll order. this.setupOrder = new Queue <UInt32>(this.gameManager.GetFirstSetupPassOrder()); var index = this.setupOrder.Dequeue(); this.clientExpectingMessage = this.clients[index]; this.clientExpectingMessage.ChooseTownLocation(); }
public void ConfirmGameInitialized(IClientCallback client) { var message = new GameSessionMessage(GameSessionMessage.Types.ConfirmGameInitialized, client); this.messageQueue.Enqueue(message); }