Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MainWindow window = new MainWindow();

            StartingData = new StartingData(
                new Player(1, Player1Name.Text, Player1Color),
                new Player(2, Player2Name.Text,
                           Player2Color,
                           Constants.PlayerSize,
                           Constants.StartingPlayer2Position),
                new Ball(BallColor),
                window.Pitch);
            window.InitGame(StartingData);
            window.Show();
            this.Close();
        }
        public void InitGame(StartingData data)
        {
            _game = new Game(data.Pitch);
            Player1Name.Content   = data.Player1.Name;
            Player1Points.Content = 0;
            Player2Name.Content   = data.Player2.Name;
            Player2Points.Content = 0;
            _game.AddObjectToGame(data.Player1);
            _game.AddObjectToGame(data.Player2);
            _game.AddObjectToGame(data.Ball);
            _game.DrawObjects();
            DispatcherTimer timer = new DispatcherTimer();

            timer.Tick    += new EventHandler(Update);
            timer.Interval = TimeSpan.FromMilliseconds(Constants.TimeSpan);
            timer.Start();
        }