Пример #1
0
 private void Button_Play(object sender, EventArgs e)
 {
     Sound.Click();
     WindowManager.ReopenWindow(this, MenuWindow.menuWindow);
     MenuWindow.menuWindow.Button_Play(null, null);
     SaveScore();
 }
Пример #2
0
        void ProcessObstacles()
        {
            if (tick % ((ulong)(50 / speedArr[speedArrIndex])) == 0)
            {
                if (obstacles[0] != null)
                {
                    obstacles[0].Destroy();
                    score += (ulong)(speedArr[speedArrIndex]);
                }
                obstacles.RemoveAt(0);
                AddRandomObstacle();
            }

            if (obstacles[2] != null)
            {
                if (playerState != obstacles[2].stateToAvoid)
                {
                    gameCanvas.Children.Remove(playerImage);
                    playerImage        = new Image();
                    playerImage.Width  = 150;
                    playerImage.Height = 150;
                    ImageBehavior.SetAnimatedSource(playerImage, new BitmapImage(new Uri(@"Resources\img\playerFall.gif", UriKind.Relative)));
                    ImageBehavior.SetRepeatBehavior(playerImage, new System.Windows.Media.Animation.RepeatBehavior(1));
                    gameCanvas.Children.Add(playerImage);
                    Canvas.SetLeft(playerImage, 0);
                    Canvas.SetTop(playerImage, 50);
                    Canvas.SetZIndex(playerImage, 5);

                    Sound.Fall();
                    timer.Stop();
                    Timer gameoverTimer = new Timer()
                    {
                        AutoReset = false,
                        Interval  = 1100,
                        Enabled   = false,
                    };
                    gameoverTimer.Elapsed += (a, b) => {
                        System.Windows.Application.Current.Dispatcher.Invoke((Action) delegate {
                            WindowManager.ReopenWindow(this, MenuWindow.GameOverWindow);
                        });
                    };
                    gameoverTimer.Start();
                }
                else if (obstacles[2].stateToAvoid == PlayerState.Slash)
                {
                    obstacles[2].Destroy();
                    obstacles[2] = null;
                    score       += (ulong)(speedArr[speedArrIndex]);
                }
            }
            if (obstacles[3] != null)
            {
                if (obstacles[3].stateToAvoid == PlayerState.Slash && playerState == PlayerState.Slash)
                {
                    obstacles[3].Destroy();
                    obstacles[3] = null;
                    score       += (ulong)(speedArr[speedArrIndex]);
                }
            }
        }
Пример #3
0
 private void Button_Back(object sender, RoutedEventArgs e)
 {
     Sound.Click();
     WindowManager.ReopenWindow(this, MenuWindow.menuWindow);
 }