コード例 #1
0
        private void AnimateCell(GameCell cell, CellPosition origin, CellPosition target, Action finished = null)
        {
            Action <double> animationFunction = origin.X == target.X
                ?
                                                new Action <double>(translation => cell.TranslationY = translation)
                :
                                                new Action <double>(translation => cell.TranslationX = translation);

            var distance = origin.X == target.X ?
                           CalculateDistance(origin.Y, target.Y)
                :
                           CalculateDistance(origin.X, target.X);

            cell.Animate("tileMove", new Animation(animationFunction, distance.Item1, 0), length: distance.Item2 * _moveAnimationLength, finished: (d, b) =>
            {
                cell.TranslationX = 0;
                cell.TranslationY = 0;
                finished?.Invoke();
            });
        }
コード例 #2
0
 private void AnimateNew(GameCell cell)
 {
     cell.Animate("newTile", new Animation((double scale) => cell.Scale = scale, .1, 1), length: _newAnimationLength, finished: (d, b) => cell.Scale = 1);
 }