public void OnGameMessage(GameMessage message) { RegisterClient registerClient = message as RegisterClient; if (registerClient != null) { IAIBase.ETeam team; int teamOrder; if (manager.RegisterClient(registerClient, out team, out teamOrder)) { IEnumerable <ClientDataOnServer> redTeam = manager.GetTeam(IAIBase.ETeam.TEAM_RED); TeamList redList = new TeamList(IAIBase.ETeam.TEAM_RED, redTeam.ToArray()); IEnumerable <ClientDataOnServer> blueTeam = manager.GetTeam(IAIBase.ETeam.TEAM_BLUE); TeamList blueList = new TeamList(IAIBase.ETeam.TEAM_BLUE, blueTeam.ToArray()); manager.networkManager.SendClientRegistration(registerClient.NetworkPlayer, team, teamOrder); manager.networkManager.SendTeamSetupUpdate(redList, blueList); return; } } ClientReadyToPlay clientReady = message as ClientReadyToPlay; if (clientReady != null) { manager.RegisteredClients.First(c => c.NetworkPlayer == clientReady.Player).ReadyToPlay = true; if (manager.RegisteredClients.Count() >= Constants.GAME_MIN_PLAYERS && manager.RegisteredClients.All(c => c.ReadyToPlay == true)) { manager.networkManager.StartMatch(); manager.ChangeState(manager.ServerGameSetupState); } return; } }