public OrbitModifier2D DeepCopy(IModifiable2D newOwner) { OrbitModifier2D clone = new OrbitModifier2D(orbitPivot, orbitDist, orbitAngle, orbitSpeed, RemoveIfComplete, frames); clone.owner = newOwner; return(clone); }
public ColorModifier2D(Color color, bool removeIfComplete, IModifiable2D owner, int time) { prevColor = owner.Color; targetColor = color; frames = time; Active = true; RemoveIfComplete = removeIfComplete; }
/// <summary> /// Causes the owner to follow the target for a set period of time. /// </summary> /// <param name="targetPosition">Point to follow.</param> /// <param name="time">How long to follow it for. Set to -1 for forever.</param> public FollowModifier2D(IModifiable2D target, int time) { this.target = target; frames = time; Active = true; followX = true; followY = true; }
/// <summary> /// Creates a new RotateTo Modifier. /// </summary> /// <param name="targetRotation">Rotation, in radians, that the owner will rotate to.</param> /// <param name="owner">The object the modifier will be applied to.</param> /// <param name="removeIfComplete">Set to true to delete this modifier when Active is false.</param> /// <param name="time">Time, in frames, it will take to rotate. Set to 1 for immediate rotation.</param> public RotateToModifier2D(float targetRotation, IModifiable2D owner, bool removeIfComplete, int time) { if (time < 1) { throw new ArgumentException("This modifier takes at least 1 frame to execute.", "time"); } frames = time; this.owner = owner; Active = true; if (targetRotation != -1) { lerpSpeed = (owner.Rotation - targetRotation) / time; } }
/// <summary> /// Causes the owner to follow the target for a set period of time. /// </summary> /// <param name="target">Other object to follow.</param> /// <param name="followAxes">Axes to follow the target on. Set to -1 for false, and anything else for true.</param> /// <param name="time">Time, in frames, to follow the other object for. Set to -1 to follow forever.</param> public FollowModifier2D(IModifiable2D target, Vector2 followAxes, int time) { this.target = target; frames = time; Active = true; if (followAxes.X != -1) { followX = true; } if (followAxes.Y != -1) { followY = true; } }
/// <summary> /// Creates a new MoveTo Modifier. /// </summary> /// <param name="targetPosition">Position the object will move to.</param> /// <param name="owner">The object the modifier will be applied to.</param> /// <param name="removeIfComplete">Set to true to delete this modifier when Active is false.</param> /// <param name="time">Time, in frames, it will take to move. Set to 1 for immediate movement.</param> public MoveToModifier2D(Vector2 targetPosition, IModifiable2D owner, bool removeIfComplete, int time) { if (time < 1) { throw new ArgumentException("This modifier takes at least 1 frame to execute.", "time"); } frames = time; Active = true; RemoveIfComplete = removeIfComplete; if (targetPosition.X != -1) { lerpSpeed.X = (owner.WorldPosition.X - targetPosition.X) / time; } if (targetPosition.Y != -1) { lerpSpeed.Y = (owner.WorldPosition.Y - targetPosition.Y) / time; } }
/// <summary> /// Creates a new SmoothStep Modifier. /// </summary> /// <param name="targetPosition">Position the object will move to.</param> /// <param name="owner">The object the modifier will be applied to.</param> /// <param name="removeIfComplete">Set to true to delete this modifier when Active is false.</param> /// <param name="time">Time, in frames, it will take to move. Set to 1 for immediate movement.</param> public SmoothStepModifier2D(Vector2 targetPosition, IModifiable2D owner, bool removeIfComplete, int time) { if (time < 1) { throw new ArgumentException("This modifier takes at least 1 frame to execute.", "time"); } frames = time; Active = true; startPoint = owner.WorldPosition; RemoveIfComplete = removeIfComplete; endPoint = startPoint; if (targetPosition.X != -1) { endPoint.X = targetPosition.X; } if (targetPosition.Y != -1) { endPoint.Y = targetPosition.Y; } }