/// <summary> /// move and animate a single line in the group of datapoints /// </summary> /// <param name="CenterX"></param> /// <param name="CenterY"></param> /// <param name="linesGeom"></param> /// <param name="dp"></param> /// <param name="location"></param> private void animateLine(double CenterX, double CenterY, GeometryGroup linesGeom, DependencyProperty dp, int location) { LineGeometry thisLine = (LineGeometry)linesGeom.Children[location]; PointAnimation movePointAnimation = new PointAnimation(new Point(CenterX, CenterY), TimeSpan.FromMilliseconds(_animationTime)); movePointAnimation.EasingFunction = new QuarticEase() { EasingMode = EasingMode.EaseOut }; thisLine.BeginAnimation(dp, movePointAnimation); }
/*! * \fn void showShootTrace() * \brief Affiche l'animation de la trace du shoot sur l'ecran de jeu * \return */ public virtual void showShootTrace() { List <double> shootList = App.wrapper.getLastShootTrace(); Storyboard sb = new Storyboard(); for (int i = 0; i + 2 < shootList.Count;) { LineGeometry l = new LineGeometry(); double x1 = shootList[i] * sqLong; i++; double y1 = shootList[i] * sqHaut; i++; double x2 = shootList[i] * sqLong; double y2 = shootList[i + 1] * sqHaut; l.StartPoint = new Point(x1, y1); l.EndPoint = new Point(x1, y1); Point realEndPoint = new Point(x2, y2); PointAnimation pointAnim = new PointAnimation(); PointAnimation pointAnim2 = new PointAnimation(); pointAnim.From = l.StartPoint; pointAnim2.From = l.StartPoint; pointAnim.To = realEndPoint; pointAnim2.To = realEndPoint; pointAnim.Duration = TimeSpan.FromMilliseconds(100); pointAnim2.Duration = TimeSpan.FromMilliseconds(300); pointAnim.BeginTime = TimeSpan.FromMilliseconds(i * 100 - 100); pointAnim2.BeginTime = TimeSpan.FromMilliseconds(i * 100); l.BeginAnimation(LineGeometry.EndPointProperty, pointAnim); l.BeginAnimation(LineGeometry.StartPointProperty, pointAnim2); Path myPath = new Path(); myPath.StrokeThickness = 2; myPath.Stroke = System.Windows.Media.Brushes.Cyan; myPath.Data = l; gridGame2.Children.Add(myPath); } }