Exemple #1
0
        //------------------------------------------------------------------
        public void ChangeLane(Sequence action, Lane lane, float duration)
        {
            if (lane == null)
            {
                return;
            }

            // No Lane changing when car doesn't move
            if (Car.Velocity < 10)
            {
                return;
            }

            // Add to the new Lane
            action.Add(new Generic(() => lane.Add(Car)));

            if (IsAnimationDisabled(action))
            {
                return;
            }

            // Rotate
            Action <float> rotate     = share => Car.Drawable.Rotation += share;
            float          finalAngle = MathHelper.ToRadians((lane.Position.X < Car.Position.X) ? -10 : 10);

            action.Add(new Controller(rotate, finalAngle, duration * 0.3f));

            // Moving
            Action <Vector2> move = shift => Car.LocalPosition += shift;
            var diapason          = new Vector2(lane.Position.X - Car.Position.X, 0);

            action.Add(new Controller(move, diapason, duration * 0.4f));

            // Inverse rotating
            var inverseRotating = new Controller(rotate, -finalAngle, duration * 0.3f);

            action.Add(inverseRotating);

            // Fix accuracy error in Car's Position
            action.Add(new Generic(() => Car.DockToLane()));
        }
Exemple #2
0
 //------------------------------------------------------------------
 public override void Add(Action action)
 {
     newActions.Add (action);
 }
Exemple #3
0
 //------------------------------------------------------------------
 public static void Add(Action action)
 {
     Instance.actions.Add (action);
 }
Exemple #4
0
 //------------------------------------------------------------------
 public void AddInSequnce(Action action)
 {
     Sequence.Add (action);
 }
Exemple #5
0
 //------------------------------------------------------------------
 public void AddInLoop(Action action)
 {
     Loop.Add (action);
 }
Exemple #6
0
 //------------------------------------------------------------------
 public virtual void Add(Action action)
 {
     Actions.Add (action);
 }
Exemple #7
0
 //------------------------------------------------------------------
 public void AddInSequnce(Action action)
 {
     Sequence.Add(action);
 }
Exemple #8
0
 //------------------------------------------------------------------
 public void AddInLoop(Action action)
 {
     Loop.Add(action);
 }