private void BtnRe_Click(object sender, RoutedEventArgs e) { int x = r.Next(1, 500 / Size) * Size; int y = r.Next(1, (500 - 5 * Size) / Size) * Size; CreateSnake(x, y); InitEgg(); eaten = 0; EggScore.Text = "0"; score = 0; move = ""; visibleCount = 5; timer.IsEnabled = false; txtScore.Text = "0.0"; TimeScore = 100; DoubleAnimation BloodShow = new DoubleAnimation(); BloodShow.To = 0.0; BloodShow.From = Blood.Opacity; BloodShow.BeginTime = TimeSpan.Parse("0:0:0.1"); BloodShow.RepeatBehavior = new RepeatBehavior(1); Blood.BeginAnimation(Image.OpacityProperty, BloodShow); dead = 0; for (int i = visibleCount; i < SnakeSize; i++) { Snakes[i].Visibility = Visibility.Hidden; } }
private void DeadSnakes() { timer.IsEnabled = false; Canvas.SetLeft(Blood, tmp.X - 50); Canvas.SetTop(Blood, tmp.Y - 75); DoubleAnimation BloodShow = new DoubleAnimation(); BloodShow.To = 1.0; BloodShow.From = 0.0; BloodShow.RepeatBehavior = new RepeatBehavior(1); BloodShow.BeginTime = TimeSpan.Parse("0:0:0.1"); Blood.BeginAnimation(Image.OpacityProperty, BloodShow); MessageBox.Show("Dead!\nScore : " + txtScore.Text); }