示例#1
0
        private void PlayLoseHealthAnimation(int oldHealth, int newHealth)
        {
            List <LoseHealthAnimation> animations = new List <LoseHealthAnimation>();

            if (MaxHealth > 5)
            {
                LoseHealthAnimation animation = new LoseHealthAnimation();
                animation.HorizontalAlignment = HorizontalAlignment.Left;
                animation.VerticalAlignment   = VerticalAlignment.Bottom;
                AlignLoseHealthAnimation(animation, imgBloodDrop);
                animations.Add(animation);
            }
            else if (oldHealth <= MaxHealth && newHealth <= MaxHealth)
            {
                oldHealth = Math.Min(oldHealth, 5);
                newHealth = Math.Max(newHealth, 0);
                for (int i = newHealth; i < oldHealth; i++)
                {
                    Trace.Assert(i < 5);
                    LoseHealthAnimation animation = new LoseHealthAnimation();
                    AlignLoseHealthAnimation(animation, spSmallHealth.Children[i] as Image);
                    animations.Add(animation);
                }
            }

            foreach (var animation in animations)
            {
                animation.Completed += animation_Completed;
                canvasRoot.Children.Add(animation);
                animation.Start();
            }
        }
示例#2
0
        private void AlignLoseHealthAnimation(LoseHealthAnimation animation, Image bloodDrop)
        {
            UpdateLayout();
            Point leftTop = bloodDrop.TranslatePoint(new Point(0, 0), canvasRoot);

            animation.Width  = 50;
            animation.Height = 120;
            animation.SetValue(Canvas.LeftProperty, leftTop.X - 10);
            animation.SetValue(Canvas.TopProperty, leftTop.Y - 100);
        }
示例#3
0
        private void AlignLoseHealthAnimation(LoseHealthAnimation animation, Image bloodDrop)
        {
            UpdateLayout();
            Point leftBottom = bloodDrop.TranslatePoint(new Point(0, bloodDrop.ActualHeight), canvasRoot);

            animation.Width  = 50;
            animation.Height = 120;
            animation.SetValue(Canvas.LeftProperty, leftBottom.X - 8);
            animation.SetValue(Canvas.BottomProperty, leftBottom.Y - 18);
        }