public MainWindow() { InitializeComponent(); if (!File.Exists(fileName)) { game.Init(); } else { Stream stream = File.Open("Dodgeball.dat", FileMode.Open); BinaryFormatter bf = new BinaryFormatter(); game = (Games.Game)bf.Deserialize(stream); stream.Close(); } DataContext = this; //DispatcherTimer settings and Dispatcher start dispatcherTimer = new DispatcherTimer(); //adding event dispatcherTimer.Tick += new EventHandler(DispatcherTimer_Tick); dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 1500); dispatcherTimer.Start(); buttons.AddRange(new[] { SquareZero, SquareOne, SquareTwo, SquareThree, SquareFour, SquareFive, SquareSix, SquareSeven, SquareEight }); TamagotchiImage.Source = new BitmapImage(ImageUri); MissesText.Text = "Misses: " + game.Misses; HitsText.Text = "Hits: " + game.Points; }
private void Init() { Points = (int)game.Points; Misses = game.Misses; millis = 2000; Points = 0; Misses = 0; game.Init(); ChangePicture(); PointTxt(); MissesTxt(); }