Example #1
0
        public void AddToQueue(Movement m) 
        {
            //adds a Movement object to the list of movements to be run

            moveQueue.Add(m);
        
        }
Example #2
0
 public void Move(Movement m)
 {
     if (targetMoving == false)
     {
         targetMoving = true;
         //moves the grid, so that the world.player can never leave the form
         ThicknessAnimation ta = new ThicknessAnimation();
         ta.From = targetGrid.Margin;
         ta.To = new Thickness(targetGrid.Margin.Left + m.Displacement.X, targetGrid.Margin.Top + m.Displacement.Y, 0, 0);
         ta.AccelerationRatio = m.Acceleration;
         ta.DecelerationRatio = m.Deceleration;
         ta.Completed += (o, i) => { targetMoving = false; };
         targetGrid.BeginAnimation(Grid.MarginProperty, ta);
     }
     //comment
 }
Example #3
0
        public void StartAnimation(Movement m, Boolean toggleQueue = false)
        {

            //Moves the player, accepts a Movement object, can only run one movement at once


            if (isMoving == false )//&& VerifyMovement(m))
            {

                isMoving = true; //forces an animation to complete before the next one can toggle

                ThicknessAnimation ta = new ThicknessAnimation();
                ta.From = this.Margin;
                ta.To = new Thickness(this.Margin.Left + m.Displacement.X, this.Margin.Top + m.Displacement.Y, 0, 0);
                ta.Duration = TimeSpan.FromMilliseconds(m.timeMs);
                ta.AccelerationRatio = m.Acceleration;
                ta.DecelerationRatio = m.Deceleration;

                ta.Completed += (o, i) => { isMoving = false; };

                if (toggleQueue)
                {
                    ta.Completed += (o, i) => { ProcessNextQueueItem(toggleQueue); };
                }

                this.BeginAnimation(MarginProperty, ta);

            }
        }