コード例 #1
0
        private void GameOver()
        {
            //clear the map
            _map.Clear();
            //hide the player
            _player.Image.Visibility = Visibility.Collapsed;
            //hide tutorial
            if (_player.tutorial)
            {
                _tutorialTextBlock.Visibility = Visibility.Collapsed;
            }

            gameOverFx.Play();
            //reset force
            _forceOnPlayer = 1;
            //stop timer
            _timer.Stop();

            //open game over screen
            #region GameOver Screen

            ImageBrush brush = new ImageBrush
            {
                ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Backgrounds/GameOver.jpg")),
                Stretch     = Stretch.Fill
            };
            _game.Background = brush;

            //stop music
            backgroundMusicMediaElement.Stop();

            //activate sound effect
            //TODO

            //retryBnt
            _retryBtn = new Button
            {
                FontSize     = 40,
                Content      = "Retry",
                Background   = new SolidColorBrush(Color.FromArgb(200, 255, 0, 0)),
                Width        = 200,
                Height       = 200,
                CornerRadius = new CornerRadius(100)
            };
            Canvas.SetLeft(_retryBtn, _game.ActualWidth / 2 - 250);
            Canvas.SetTop(_retryBtn, _game.ActualHeight / 2 + 150);
            _game.Children.Add(_retryBtn);
            _retryBtn.Click += RetryBtn_Click;


            //Main Menu btn
            _mainMenuBtn = new Button
            {
                Width        = 200,
                Height       = 200,
                Content      = (!_map.IsUserGenerated) ? "Return to\nmain menu" : "Create a new\nMap",
                Background   = new SolidColorBrush(Color.FromArgb(200, 200, 0, 0)),
                FontSize     = 30,
                CornerRadius = new CornerRadius(100)
            };
            Canvas.SetLeft(_mainMenuBtn, _game.ActualWidth / 2 + 50);
            Canvas.SetTop(_mainMenuBtn, _game.ActualHeight / 2 + 150);
            _game.Children.Add(_mainMenuBtn);
            if (!_map.IsUserGenerated)
            {
                _mainMenuBtn.Click += MainMenuBtn_Click;
            }
            else
            {
                _mainMenuBtn.Click += LevelCreationBtn_Click;
            }
            #endregion
        }