public MoveAnimation(ImageCandy candy, Coordonate startCoordonate, Coordonate finishCoordonate, int height, int width, double time) : base() { MoveCandy = candy; this.startCoordonate = new Coordonate(startCoordonate.X * height, startCoordonate.Y * width); this.finishCoordonate = new Coordonate(finishCoordonate.X * height, finishCoordonate.Y * width); this.time = time; if (MoveCandy.Type == CandyType.Inimioara) { BitmapImage logo = new BitmapImage(); logo.BeginInit(); logo.UriSource = new Uri("C:\\Users\\Andreea Florea\\Desktop\\tenerife\\joculet T\\joculet\\Resources\\scaredHeart.png"); logo.EndInit(); MoveCandy.Source = logo; } }
public void AnimateChange(Change change) { switch (change.Type) { case ChangeType.FallDown: Coordonate startCoordonate = ((FallDownChange)change).Start; Coordonate finishCoordonate = ((FallDownChange)change).Finish; animatedObject = imageCandies[startCoordonate.X, startCoordonate.Y]; imageCandies[finishCoordonate.X, finishCoordonate.Y] = (ImageCandy)animatedObject; animations.Add(new MoveAnimation(imageCandies[finishCoordonate.X, finishCoordonate.Y], startCoordonate, finishCoordonate, ImageSlot.SlotHeight, ImageSlot.SlotWidth, change.FallTime)); break; case ChangeType.CreateCandy: CreateCandyChange createChange = (CreateCandyChange)change; animatedObject = new ImageCandy(createChange.TipBomboana); canvasDisplay.Children.Add(animatedObject); MoveToCoordonate(animatedObject, createChange.CoordonateCandy); imageCandies[createChange.CoordonateCandy.X, createChange.CoordonateCandy.Y] = (ImageCandy)animatedObject; //animation = null; break; case ChangeType.DestroyCandy: DestroyCandyChange destroyChange = ((DestroyCandyChange)change); ImageCandy destroyImage = imageCandies[destroyChange.CoordonateCandy.X, destroyChange.CoordonateCandy.Y]; //Canvas.SetLeft(destroyImage, Canvas.GetLeft(destroyImage) + 10); //destroyImage.Width -= 20; canvasDisplay.Children.Remove(destroyImage); //animation = null break; } fullAnimationTime = change.FallTime; animationTime = change.FallTime; animationTimer.Start(); }