private void CheckAllPlayersReady() { bool ready = true; if (players.Count < MatchManagerInfoAccessor.GetInfo(lastTournamentSettings.MMType).MinPlayerCount) { ready = false; } if (ready) { foreach (Player p in players) { if (!p.Data.LobbyReady) { ready = false; break; } } } if (Application.Current != null) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { LobbyUC wnd = LogicalTreeHelper.FindLogicalNode(Application.Current.MainWindow, "lobbyWindow") as LobbyUC; if (wnd != null) { wnd.AllReady(ready); } })); } }
public void ExecuteCommands() { foreach (CommandType c in commands) { switch (c) { case CommandType.START_LOCAL_TOURNAMENT: App.Instance.StartTournamentFinder("127.0.0.1"); break; case CommandType.CONNECT_FIRST_TOURNAMENT: TournamentFinderUC tuc = LogicalTreeHelper.FindLogicalNode(App.WindowInstance, "tournamentFinderUC") as TournamentFinderUC; if (tuc != null) { tuc.ReceivedNewTournamentsCallback = (settings, serverAddress) => { if (settings.Count > 0) { App.Instance.StartTournamentGame(serverAddress, settings[0].ServerId); tuc.ReceivedNewTournamentsCallback = null; } }; } break; case CommandType.CREATE_COMPETITION_TOURNAMENT: TournamentSettings s = new TournamentSettings(); s.Name = "Automatic Test Competition"; s.Leader = App.Instance.PlayerName; s.MMType = MatchManagerType.ONLY_SCORE; s.Level = GameLevel.BASIC_MAP; s.RoundCount = 10; s.BotCount = 0; s.BotType = BotType.NONE; App.Instance.StartTournamentLobby("127.0.0.1"); App.Instance.GetSceneMgr().Enqueue(new Action(() => { App.Instance.GetSceneMgr().ProcessNewTournamentSettings(s); })); LobbyUC lobby = LogicalTreeHelper.FindLogicalNode(Application.Current.MainWindow, "lobbyWindow") as LobbyUC; if (lobby != null) { lobby.UpdateTournamentSettings(s); } break; } } }
private void UpdateLobbyPlayers() { if (Application.Current == null) { return; } List <LobbyPlayerData> data = CreateLobbyPlayerData(); Application.Current.Dispatcher.BeginInvoke(new Action(() => { LobbyUC lobby = LogicalTreeHelper.FindLogicalNode(Application.Current.MainWindow, "lobbyWindow") as LobbyUC; if (lobby != null) { lobby.UpdateShownPlayers(data); lobby.SetIsLeader(currentPlayer.Data.LobbyLeader); } })); }
private void ReceivedTournamentSettingsMsg(NetIncomingMessage msg) { players.ForEach(p => { if (!p.Data.LobbyLeader) { p.Data.LobbyReady = false; } }); lastTournamentSettings = msg.ReadTournamentSettings(); List <LobbyPlayerData> data = CreateLobbyPlayerData(); Application.Current.Dispatcher.BeginInvoke(new Action(() => { LobbyUC lobby = LogicalTreeHelper.FindLogicalNode(Application.Current.MainWindow, "lobbyWindow") as LobbyUC; if (lobby != null) { lobby.UpdateTournamentSettings(lastTournamentSettings); lobby.UpdateShownPlayers(data); } })); }
private void ReceivedPlayerReadyCheck() { if (GameWindowState != WindowState.IN_LOBBY) { return; } if (currentPlayer != null && currentPlayer.Data.LobbyReady) { return; } Application.Current.Dispatcher.BeginInvoke(new Action(() => { LobbyUC lobby = LogicalTreeHelper.FindLogicalNode(Application.Current.MainWindow, "lobbyWindow") as LobbyUC; if (lobby != null) { lobby.ReadyCheckRequested(); } })); }
private void TournamentGameEnded() { gameEnded = false; isGameInitialized = false; userActionsDisabled = true; CleanObjects(); foreach (Player p in players) { p.ClearActions(); p.ClearObjects(); } AttachStateManagers(); stopUpdating = false; Application.Current.Dispatcher.Invoke(new Action(() => { App.Instance.CreateLobbyGui(currentPlayer.Data.LobbyLeader); LobbyUC lobby = LogicalTreeHelper.FindLogicalNode(Application.Current.MainWindow, "lobbyWindow") as LobbyUC; if (lobby != null) { lobby.UpdateTournamentSettings(lastTournamentSettings); } })); SendChatMessage(String.Format(Strings.Culture, Strings.lobby_joined, GetCurrentPlayer().Data.Name), true); SendPlayerDataRequestMessage(); if (currentPlayer.Data.LobbyLeader) { currentPlayer.Data.LobbyReady = true; SendPlayerReadyMessage(true); } }