/// <summary>
        /// Vytvori a zobrazi okno se statistikami za posledni hru a nastavi akci, ktera se ma provest po zavreni statistik
        /// </summary>
        /// <param name="endType">typ konce hry</param>
        private void ShowEndGameStats(GameEnd endType)
        {
            //zrusime static mouse a zabranime dalsimu update - hrac pozna ze je konec
            StaticMouse.Enable(false);
            stopUpdating = true;

            Invoke(new Action(() =>
            {
                // vytvorime okno se statistikami za posledni hru
                EndGameStats s = GuiObjectFactory.CreateAndAddPlayerStatsUc(this, currentPlayer, currentPlayer.IsActivePlayer(), new Vector((SharedDef.VIEW_PORT_SIZE.Width - 800) / 2, (SharedDef.VIEW_PORT_SIZE.Height - 500) / 2));
                // a vytvorime akci, ktera se zavola pri zavreni statistik
                s.CloseAction = new Action(() =>
                {
                    // zavreni vyvola bud uzivatel (vlakno gui) nebo GameState (vlakno sceny), proto je potreba synchronizovat
                    Enqueue(new Action(() =>
                    {
                        if (endType != GameEnd.TOURNAMENT_FINISHED)
                        {
                            CloseGameWindowAndCleanup(endType);
                        }
                        else
                        {
                            TournamentFinished();
                        }
                    }));
                });
            }));
        }
 private void mainWindow_Activated(object sender, EventArgs e)
 {
     if (GameRunning)
     {
         StaticMouse.Enable(true);
     }
 }
 public void ShowOptionsMenu()
 {
     AddMenu(new OptionsUC());
     if (GameRunning)
     {
         StaticMouse.Enable(false);
     }
 }
Exemple #4
0
 private void btnBack_Click(object sender, RoutedEventArgs e)
 {
     App.Instance.ClearMenus();
     if (App.WindowInstance.GameRunning)
     {
         StaticMouse.Enable(true);
     }
 }
        public void TournamentFinished()
        {
            if (Application.Current == null)
            {
                return;
            }

            StaticMouse.Enable(false);

            List <LobbyPlayerData> data = CreateLobbyPlayerData();

            RequestStop();

            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                App.Instance.CreateScoreboardGui(data);
            }));
        }
Exemple #6
0
        private void settings_MouseDown(object sender, MouseButtonEventArgs e)
        {
            UIElement esc = LogicalTreeHelper.FindLogicalNode(App.WindowInstance.mainGrid, "escMenu") as UIElement;

            if (esc != null)
            {
                App.WindowInstance.ClearMenus();
                if (App.WindowInstance.GameRunning)
                {
                    StaticMouse.Enable(true);
                }
            }
            else
            {
                App.WindowInstance.AddMenu(new EscMenu());
                if (App.WindowInstance.GameRunning)
                {
                    StaticMouse.Enable(false);
                }
            }
        }
 public void GameEnded()
 {
     ShutdownServerIfExists();
     StaticMouse.Enable(false);
     ShowStartScreen();
 }
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Escape:
                UIElement uc;
                if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "botSelection") as UIElement) != null)
                {
                    ClearMenus();
                    if (GameRunning)
                    {
                        StaticMouse.Enable(true);
                    }
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "colorPicker") as UIElement) != null)
                {
                    AddMenu(new PlayerSettings());
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "mouseMenu") as UIElement) != null)
                {
                    ShowOptionsMenu();
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "soundMenu") as UIElement) != null)
                {
                    ShowOptionsMenu();
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "playerSettings") as UIElement) != null)
                {
                    ShowOptionsMenu();
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "keyBindingsMenu") as UIElement) != null)
                {
                    ShowOptionsMenu();
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "optionsUC") as UIElement) != null)
                {
                    AddMenu(new EscMenu());
                    if (GameRunning)
                    {
                        StaticMouse.Enable(false);
                    }
                }
                else if ((uc = LogicalTreeHelper.FindLogicalNode(menuGrid, "escMenu") as UIElement) != null)
                {
                    ClearMenus();
                    if (GameRunning)
                    {
                        StaticMouse.Enable(true);
                    }
                }
                else if (menuGrid.Children.Count == 0)
                {
                    AddMenu(new EscMenu());
                    if (GameRunning)
                    {
                        StaticMouse.Enable(false);
                    }
                }
                else
                {
                    ClearMenus();
                }
                break;

            case Key.Tab:
                if (tabDown)
                {
                    return;
                }

                tabDown = true;
                GameOverviewUC go = LogicalTreeHelper.FindLogicalNode(menuGrid, "gameOverview") as GameOverviewUC;
                if (go != null)
                {
                    menuGrid.Children.Remove(go);
                }
                break;
            }

            App.Instance.OnKeyEvent(e);
        }
 public void InitStaticMouse()
 {
     StaticMouse.Init(this);
     StaticMouse.Enable(true);
     StateMgr.AddGameState(StaticMouse.Instance);
 }