private void Update(int square) { game.IsHit(square); if (game.Points % 10 == 0 && game.Points != 0) { t.AddHappiness(1); dispatcherTimer.Interval.Subtract(new TimeSpan(0, 0, 0, 0, 50)); } if (game.IsReady()) { MissesText.Text = "Misses: " + game.Misses; MessageBox.Show("Game Over!"); t.AddHappiness(-10); this.Close(); game.Init(); } MissesText.Text = "Misses: " + game.Misses; HitsText.Text = "Hits: " + game.Points; }
private void MyCanvas_MouseDown(object sender, MouseButtonEventArgs e) { PointTxt(); MissesTxt(); int value = temp.HappinessIndex + game.Pointss(); double x = e.GetPosition(MyCanvas).X; double y = e.GetPosition(MyCanvas).Y; int hit = 1; if (x >= 100 && x <= 200 && y >= 100 && y < 200) { hit = 1; } else if (x >= 300 && x <= 400 && y >= 100 && y < 200) { hit = 2; } else if (x >= 500 && y <= 600 && y >= 100 && y < 200) { hit = 3; } else if (x >= 100 && x <= 200 && y >= 200 && y < 300) { hit = 4; } else if (x >= 300 && x <= 400 && y >= 200 && y < 300) { hit = 5; } else if (x >= 500 && y <= 600 && y >= 200 && y < 300) { hit = 6; } else if (x >= 100 && x <= 200 && y >= 300 && y < 400) { hit = 7; } else if (x >= 300 && x <= 400 && y >= 300 && y < 400) { hit = 8; } else if (x >= 500 && y <= 600 && y >= 300 && y < 400) { hit = 9; } if (game.IsHit(hit)) { Points = (int)game.Points; millis = (Points % 10 == 0) ? millis - 100 : millis; ChangePicture(); } else { Misses++; if (game.IsReady()) { dispatcherTimer.Stop(); if (MessageBoxResult.Yes == MessageBox.Show("Do you want to play again?", "Third miss!", MessageBoxButton.YesNo)) { temp.HappinessIndex = value; MessageBox.Show(value.ToString()); Init(); dispatcherTimer.Start(); } else { temp.HappinessIndex = value; Close(); } } } }