Example #1
0
        private MoveElementAnimation AddMoveAnimation(Element el, Rectangle dest)
        {
            double duration = Math.Abs(dest.Center.Y - el.rectangle.Center.Y + dest.Center.X - el.rectangle.Center.X)
                              / Config.shift * Config.shiftTime;
            MoveElementAnimation res = new MoveElementAnimation(Game, el, dest, duration);

            res.onEnd += MoveAnimationEnd;
            el.AddAnimation(res);
            el.lastMoved = gameTime.TotalGameTime.TotalMilliseconds + moveAnimations * 1.0 / 1000;
            ++moveAnimations;
            return(res);
        }
Example #2
0
        private void AddSwapAnimation(Info.Turn turn, EventHandler onEnd = null)
        {
            Element from = GetElementByPoint(turn.from);
            Element to   = GetElementByPoint(turn.to);

            AddMoveAnimation(to, GetRectangleByColAndRow(turn.from.X, turn.from.Y));
            MoveElementAnimation moveSelectedAnimation = AddMoveAnimation(from, GetRectangleByColAndRow(turn.to.X, turn.to.Y));

            if (onEnd != null)
            {
                moveSelectedAnimation.onEnd += onEnd;
            }
        }