示例#1
0
        private void Explode(object sender, EventArgs e)
        {
            pa.Visibility = Visibility.Visible;
            double          x       = bul.lastX();
            double          y       = bul.lastY();
            DoubleAnimation expanim = new DoubleAnimation();
            PathFigure      expl    = new PathFigure();

            expl.StartPoint = (new Point(x, y + 10));
            expl.Segments.Add(new LineSegment(new Point(x - 20, y - 20), true));
            expl.Segments.Add(new LineSegment(new Point(x - 10, y - 15), true));
            expl.Segments.Add(new LineSegment(new Point(x - 18, y - 40), true));
            expl.Segments.Add(new LineSegment(new Point(x, y - 16), true));
            expl.Segments.Add(new LineSegment(new Point(x + 18, y - 40), true));
            expl.Segments.Add(new LineSegment(new Point(x + 10, y - 15), true));
            expl.Segments.Add(new LineSegment(new Point(x + 20, y - 20), true));
            expl.Segments.Add(new LineSegment(new Point(x, y + 10), true));
            PathGeometry pa2 = new PathGeometry();

            pa2.Figures.Add(expl);
            pa.Data   = pa2;
            pa.Stroke = Brushes.Red;
            if (hit)
            {
                GameMessage.Content = "Есть попадание!";
            }
            else
            {
                GameMessage.Content = "Мимо";
            }
            HitCount.Content       = hitCount;
            GameMessage.Visibility = Visibility.Visible;
            DoubleAnimation dop = new DoubleAnimation();

            dop.From           = 1;
            dop.To             = 0;
            dop.Duration       = TimeSpan.FromSeconds(2);
            expanim.Duration   = TimeSpan.FromSeconds(2);
            expanim.From       = 120;
            expanim.To         = 50;
            expanim.Completed += new EventHandler(Expanim_Completed);
            GameMessage.BeginAnimation(Canvas.TopProperty, expanim);
            GameMessage.BeginAnimation(Label.OpacityProperty, dop);
            Wheel.Visibility = Visibility.Hidden;
        }