Ejemplo n.º 1
0
        private void GameEnded()
        {
            gameEnded = true;
            List <Player> Results = new List <Player>();

            for (int i = 0; i < ActivePlayers.Count; i++)
            {
                Results = ActivePlayers.ToList <Player>();
                //Results.OrderBy(ActivePlayer => ActivePlayer.TotalScore).ToList();
            }

            var orderByResult = from r in Results
                                orderby r.TotalScore descending
                                select r;

            PlayVictorySound();
            MessageBox.Show(orderByResult.First().Firstname.ToString() + " vann med " + orderByResult.First().TotalScore.ToString() + " poäng");
            dbOps.SaveGameTransaction(ActivePlayers);



            if (MessageBox.Show("Spelet är s**t, vill du avsluta?", "Avsluta spel", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
            {
                //rutan stängs ned här
            }
            else
            {
                gameEngine.NullProps();
                playerEngine.NullProps();

                SelectedViewModel = new MainMenuViewModel();
            }
        }