コード例 #1
0
 public static void AddTranslationAnimation(this Storyboard storyboard,
                                            FrameworkElement fe, Point from, Point to, Duration duration,
                                            EasingFunctionBase easingFunction)
 {
     storyboard.AddAnimation(fe.RenderTransform,
                             storyboard.CreateDoubleAnimation(duration, from.X, to.X, easingFunction),
                             CompositeTransform.TranslateXProperty);
     storyboard.AddAnimation(fe.RenderTransform,
                             storyboard.CreateDoubleAnimation(duration, from.Y, to.Y, easingFunction),
                             CompositeTransform.TranslateYProperty);
 }
コード例 #2
0
 public static void AddScalingAnimation(this Storyboard storyboard,
                                        FrameworkElement fe, double fromX, double toX, double fromY, double toY, Duration duration,
                                        EasingFunctionBase easingFunction)
 {
     storyboard.AddAnimation(fe.RenderTransform,
                             storyboard.CreateDoubleAnimation(duration, fromX, toX, easingFunction),
                             CompositeTransform.ScaleXProperty);
     storyboard.AddAnimation(fe.RenderTransform,
                             storyboard.CreateDoubleAnimation(duration, fromY, toY, easingFunction),
                             CompositeTransform.ScaleYProperty);
 }
コード例 #3
0
ファイル: Window1.xaml.cs プロジェクト: iyevhen/VerseGlow
        private void ChangeColors()
        {
            // randomly select light colors
            EffectColors colors = effectColors[random.Next(0, effectColors.Count)];

            Storyboard lightStoryboard = new Storyboard();

            lightStoryboard.AddAnimation(new ColorAnimation(colors.Fill, Duration.Automatic), "lightEffect", PointLightEffect.FillColorProperty);
            lightStoryboard.AddAnimation(new ColorAnimation(colors.Light1, Duration.Automatic), "lightEffect", PointLightEffect.Light1ColorProperty);
            lightStoryboard.AddAnimation(new ColorAnimation(colors.Light2, Duration.Automatic), "lightEffect", PointLightEffect.Light2ColorProperty);
            lightStoryboard.Begin(this);
        }
コード例 #4
0
        public static void AddTranslationAnimation(this Storyboard storyboard,
                                                   FrameworkElement fe, double dx, double dy, Duration duration,
                                                   EasingFunctionBase easingFunction)
        {
            var from = fe.GetTranslatePoint();
            var to   = new Point(from.X + dx, from.Y + dy);

            storyboard.AddAnimation(fe.RenderTransform,
                                    storyboard.CreateDoubleAnimation(duration, from.X, to.X, easingFunction),
                                    "TranslateX");
            storyboard.AddAnimation(fe.RenderTransform,
                                    storyboard.CreateDoubleAnimation(duration, from.Y, to.Y, easingFunction),
                                    "TranslateY");
        }
コード例 #5
0
ファイル: Sprite2D.cs プロジェクト: bikrone/hexagon
        public void AddNewState(Animation a)
        {
            Storyboard sb = new Storyboard();

            sb.AddAnimation(a);
            states.Add(sb);
        }
コード例 #6
0
        public static void Assign(Sprite2D btn)
        {
            Global.gMouseHelper.Register(btn);
            btn.ClearState();
            Storyboard sb = new Storyboard();

            sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(255, 255, 255, 255), false));

            btn.AddNewState(sb);

            sb = new Storyboard();
            sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(255, 0, 255, 255), false));

            btn.AddNewState(sb);

            sb = new Storyboard();
            sb.AddAnimation(new ScaleAnimation(sb, btn, 0.1f, new Vector2(0.95f, 0.95f), true, null, false, false, true));

            btn.AddNewState(sb);

            btn.OnMouseMove  += btn_OnMouseMove;
            btn.OnMouseLeave += btn_OnMouseLeave;
            btn.OnMouseDown  += btn_OnMouseDown;
            btn.OnMouseUp    += btn_OnMouseUp;
        }
コード例 #7
0
 public static void AddColorAnimation <T, TValue>(this Storyboard storyboard, T target, Expression <Func <T, TValue> > targetProperty,
                                                  Color fromValue, Color toValue, Duration?duration = null
                                                  )
     where T : DependencyObject
 {
     storyboard.AddAnimation(new ColorAnimation(fromValue, toValue, duration ?? new Duration(TimeSpan.FromSeconds(0))), target, targetProperty);
 }
コード例 #8
0
        public static void Assign(Sprite2D btn)
        {
            Global.gMouseHelper.Register(btn);
            btn.ClearState();

            btn.SetOverlay(new Vector4(0, 0, 0, 0));

            Storyboard sb = new Storyboard();

            sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(0, 0, 0, 0), false));

            btn.AddNewState(sb);

            sb = new Storyboard();
            sb.AddAnimation(new ColorAnimation(sb, btn, 0.3f, new Vector4(255, 255, 255, 255), false));

            btn.AddNewState(sb);

            sb = new Storyboard();
            sb.AddAnimation(new ColorAnimation(sb, btn, 0.1f, new Vector4(255, 230, 230, 230), false));

            btn.AddNewState(sb);

            btn.OnMouseMove  += btn_OnMouseMove;
            btn.OnMouseLeave += btn_OnMouseLeave;
            btn.OnMouseDown  += btn_OnMouseDown;
            btn.OnMouseUp    += btn_OnMouseUp;
        }
コード例 #9
0
        private void DuplicateCell(int i, int j, int x, int y)
        {
            visualState = VisualState.Transitioning;
            Gems[x, y]  = new Gem(Gems[i, j]);

            Gems[x, y].i = x;
            Gems[x, y].j = y;

            this.gems.AddChild(Gems[x, y]);
            if (Gems[x, y].team == Gem.Team.Blue)
            {
                ScoreBlue++;
            }
            else
            {
                ScoreRed++;
            }

            Storyboard sb   = new Storyboard();
            Animation  anim = new TranslationAnimation(sb, Gems[x, y].sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false);

            sb.AddAnimation(anim);
            sb.argument = Gems[x, y];
            sb.Start();
            sb.OnCompleted += OnMoveCellCompleted;
        }
コード例 #10
0
 public static void AddOpacityAnimation(this Storyboard storyboard,
                                        UIElement fe, double from, double to, Duration duration,
                                        EasingFunctionBase easingFunction)
 {
     storyboard.AddAnimation(fe,
                             storyboard.CreateDoubleAnimation(duration, from, to, easingFunction),
                             UIElement.OpacityProperty);
 }
コード例 #11
0
        public static void AddWayPointAnimation(this Storyboard storyboard, FrameworkElement fe,
                                                IList <Point> points, double speed)
        {
            var durations = new List <Duration> {
                new Duration(TimeSpan.FromSeconds(0))
            };

            for (var i = 0; i < points.Count - 1; i++)
            {
                durations.Add(points[i].CalculateDuration(points[i + 1], speed));
            }
            var xValues = points.Select(p => p.X).ToList();

            storyboard.AddAnimation(fe.RenderTransform,
                                    storyboard.CreateKeyFrameAnimation(xValues, durations), CompositeTransform.TranslateXProperty);
            var yValues = points.Select(p => p.Y).ToList();

            storyboard.AddAnimation(fe.RenderTransform,
                                    storyboard.CreateKeyFrameAnimation(yValues, durations), CompositeTransform.TranslateYProperty);
        }
コード例 #12
0
        public void OvertakeEnemies(Gem gem)
        {
            visualState = VisualState.Transitioning;
            List <Tile> adjacents = GetAdjacentCell(gem);

            if (adjacents.Count == 0)
            {
                OnOvertakeCompleted(this, null);
                return;
            }

            Storyboard sb      = new Storyboard();
            List <Gem> toFades = new List <Gem>();

            foreach (Tile adjacent in adjacents)
            {
                Gem toOvertake = new Gem(gem);
                toOvertake.i = adjacent.i;
                toOvertake.j = adjacent.j;

                gems.AddChild(toOvertake);

                Gem toFade = Gems[adjacent.i, adjacent.j];
                toFades.Add(toFade);

                Gems[toOvertake.i, toOvertake.j] = toOvertake;

                Animation anim = new TranslationAnimation(sb, toOvertake.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(toOvertake.i, toOvertake.j), false);
                sb.AddAnimation(anim);

                anim = new ColorAnimation(sb, toFade.sprite, GameSettings.GemTranslationDuration, new Vector4(0, 0, 0, 0), false);
                sb.AddAnimation(anim);
            }

            sb.argument = toFades;
            sb.Start();
            sb.OnCompleted += OnOvertakeCompleted;
        }
コード例 #13
0
        public static void AddObjectAnimationUsingKeyFrames <T, TValue>(this Storyboard storyboard, T target, Expression <Func <T, TValue> > targetProperty,
                                                                        Duration?duration, params ObjectKeyFrame[] keyFrames
                                                                        )
            where T : DependencyObject
        {
            var animation = new ObjectAnimationUsingKeyFrames();

            animation.Duration = duration ?? new Duration(TimeSpan.FromSeconds(0));
            foreach (var keyFrame in keyFrames)
            {
                animation.KeyFrames.Add(keyFrame);
            }
            storyboard.AddAnimation(animation, target, targetProperty);
        }
コード例 #14
0
        public static void Assign(Sprite2D btn)
        {
            if (btn.states.Count > 0)
            {
                btn.ChangeState(0);
                return;
            }
            Storyboard sb = new Storyboard();

            btn.ClearState();
            sb.Clear();
            var toScale   = new Vector2(1.07f, 1.07f);
            var fromScale = Vector2.Divide(Vector2.One, toScale);

            sb.AddAnimation(new ScaleAnimation(sb, btn, GameSettings.GemSelectedEffectDuration, toScale, true, fromScale, true, true, true));
            btn.AddNewState(sb);
            btn.ChangeState(0);
        }
コード例 #15
0
        private void MoveCell(int i, int j, int x, int y)
        {
            visualState = VisualState.Transitioning;
            var toMove = Gems[i, j];

            toMove.i = x;
            toMove.j = y;

            Gems[i, j] = null;
            Gems[x, y] = toMove;

            Storyboard sb   = new Storyboard();
            Animation  anim = new TranslationAnimation(sb, toMove.sprite, GameSettings.GemTranslationDuration, GetGemVisualPosition(x, y), false);

            sb.AddAnimation(anim);
            sb.argument = Gems[x, y];
            sb.Start();
            sb.OnCompleted += OnMoveCellCompleted;
        }