Beispiel #1
0
        // Start playing the mode, adding all relevant elements to the canvas
        public virtual void StartMode()
        {
            paddle = new Widget.WidgetPaddle(mainWindow.Border.Width * 0.5, mainWindow.Border.Height - 50, 0, mainWindow.Border.Width);
            paddle.InitIcon(mainWindow.CanvasPlayArea);

            lBalls = new List<Widget.WidgetBall>();

            mainWindow.KeyDown += Mode_KeyDown;

            updateTimer = new DispatcherTimer();
            updateTimer.Interval = new TimeSpan(100000);
            updateTimer.Tick += Timer_Tick;
            updateTimer.Start();

            mainWindow.TextBlockLeft.Text = "Press B to add a ball, R to rese the field or ESC to return to main menu";

            ResetMode();
        }
Beispiel #2
0
        // Stop running the mode and clean up all canvas elements
        public virtual void EndMode()
        {
            updateTimer.Stop();
            mainWindow.KeyDown -= Mode_KeyDown;
            mainWindow.TextBlockLeft.Text = "";
            mainWindow.TextBlockRight.Text = "";

            foreach (Widget.WidgetBall ball in lBalls)
                ball.Destroy();

            lBalls.Clear();

            if (paddle != null)
            {
                paddle.Destroy();

                paddle = null;
            }
        }