//------------------------------------------------------------------ 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; } // Debug if (this is Police) { // duration *= 5; // Debugger.Break(); } // Add to new Lane action.Add(new Generic(() => lane.Add(Car))); #region Debug if (Settings.NoChangeLaneAnimation) { action.Add(new Generic(DockToLane)); return; } #endregion // Rotate Action <float> rotate = share => Car.Angle += 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(DockToLane)); }
//------------------------------------------------------------------ public void AddInSequnce(Action action) { Sequence.Add(action); }
//------------------------------------------------------------------ public void AddInLoop(Action action) { Loop.Add(action); }