Beispiel #1
0
        private void btnStartNewGame_Click(object sender, RoutedEventArgs e)
        {
            PlayingWindow.Visibility = Visibility.Visible;
            ScoringWindow.Visibility = Visibility.Visible;
            StartupWindow.Visibility = Visibility.Hidden;

            //If the user has clicked New Game, create a new player
            if (currentPlayer == null)
            {
                currentPlayer = new Player(allPlayers.Count, tbxPlayerName.Text, 0, levels[0]);
                allPlayers.Add(currentPlayer);

                //Level 1 will begin with this window which gives instructions
            }

            MdiChild BeginningMessageWindow = new MdiChild()
            {
                Width  = StartupWindow.Width + 130,
                Height = StartupWindow.Height
            };

            //Add a stackpanel to hold the following elements
            StackPanel spMessages  = new StackPanel();
            TextBlock  lblMessage1 = new TextBlock()
            {
                Text = currentPlayer.CurrentLevel.LevelId == 0 ? "SANTA NEEDS YOUR HELP! \n" : "Level Complete", FontSize = 29, FontFamily = new FontFamily("Kristen ITC"), TextWrapping = TextWrapping.Wrap, Foreground = new SolidColorBrush(Colors.Red)
            };
            TextBlock lblMessage2 = new TextBlock()
            {
                Text = currentPlayer.CurrentLevel.LevelBeginningMessage, FontSize = 20, FontFamily = new FontFamily("Kristen ITC"), TextWrapping = TextWrapping.Wrap, Foreground = new SolidColorBrush(Colors.RosyBrown)
            };
            Button btnGotIt = new Button()
            {
                Content = "Got it!", FontSize = 20, FontFamily = new FontFamily("Kristen ITC"), MaxWidth = 100
            };

            spMessages.Children.Add(lblMessage1);
            spMessages.Children.Add(lblMessage2); spMessages.Children.Add(btnGotIt);
            BeginningMessageWindow.Content = spMessages;
            Container.Children.Add(BeginningMessageWindow);
            BeginningMessageWindow.Position = new Point((SystemParameters.PrimaryScreenWidth / 2 - StartupWindow.Width / 2), SystemParameters.PrimaryScreenHeight / 4 - StartupWindow.Height / 2);
            btnGotIt.Click          += btnGotIt_Click;
            ScoringWindow.Visibility = Visibility.Hidden;
            PlayingWindow.Visibility = Visibility.Hidden;

            allPlayers = Player.Deserialize(allPlayers);

            //PlayingWindow_Loaded(sender, e);
            //ScoringWindow_Loaded(sender, e);
        }
Beispiel #2
0
        private void StartupWindow_Loaded(object sender, RoutedEventArgs e)
        {
            StartupWindow.Position = new Point((SystemParameters.PrimaryScreenWidth / 2 - StartupWindow.Width / 2), SystemParameters.PrimaryScreenHeight / 4 - StartupWindow.Height / 2);
            Canvas.SetZIndex(StartupWindow, 2);
            StartupWindow.Width  = 350;
            StartupWindow.Height = 350;
            TextBox tbxPlayerName = new TextBox()
            {
                FontSize = 27, Width = 150
            };

            PopulateListLevels();
            allPlayers.Clear();
            allPlayers = Player.Deserialize(allPlayers);
        }