/// Add an animation to a specific stream public void Add(TStream stream, IAnimation animation, IAnimationCurve curve, IAnimationTarget target) { Validate(); animation.AnimationCurve = curve; animation.AnimationTarget = target; Streams.Add(stream, animation); }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject spawned) { // Normal linear transforms transform.Rotation = Quaternion.Slerp(Origin.transform.rotation, Target.transform.rotation, curve.Value); transform.Scale = Vector3.Lerp(Origin.transform.localScale, Target.transform.localScale, curve.Value); // Find new position by speed var direction = (Target.transform.position - spawned.GameObject.transform.position).normalized; var delta = Speed * curve.Delta * direction; var output = spawned.GameObject.transform.position + delta; // Force position to be on the correct path var correctGap = (Target.transform.position - Origin.transform.position); var correctDirection = correctGap.normalized; var step = (output - Origin.transform.position).magnitude; // If the movement moves past the target, halt at target if (step > correctGap.magnitude) { step = correctGap.magnitude; transform.Active = false; } // Save output output = Origin.transform.position + step * correctDirection; transform.Position = output; }
/// Add an animation to a specific stream public void Add(TStream stream, IAnimation animation, IAnimationCurve curve, GameObject target) { Validate(); animation.AnimationCurve = curve; animation.AnimationTarget = new TargetSingle(target); Streams.Add(stream, animation); }
/// <summary> /// Initializes the animation context with the specified /// animation curve. /// </summary> /// <param name="curve">The animation curve</param> /// <exception cref="ArgumentNullException">Thrown if |curve| is null.</exception> public AnimationContext(IAnimationCurve curve) { if (curve == null) { throw new ArgumentNullException("curve"); } this.m_curve = curve; }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject origin) { var distance = (Target.transform.position - origin.GameObject.transform.position).magnitude; if (distance < Offset) { var total = 1f - (distance - Offset) / Offset; byte alpha = (byte) (255 - (byte) Math.Ceiling(255 * total)); alpha = transform.Active ? alpha : (byte) 255; transform.Color = new Color32(Color.r, Color.g, Color.b, alpha); } }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject origin) { var distance = (Target.transform.position - origin.GameObject.transform.position).magnitude; if (distance < Offset) { var total = 1f - (distance - Offset) / Offset; byte alpha = (byte)(255 - (byte)Math.Ceiling(255 * total)); alpha = transform.Active ? alpha : (byte)255; transform.Color = new Color32(Color.r, Color.g, Color.b, alpha); } }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject target) { var delta = (target.GameObject.transform.position - target.Origin.Position).magnitude; if (Distance > 0) { if (delta <= Distance) { var total = delta / Distance; byte alpha = (byte) Math.Ceiling(255 * total); transform.Color.a = alpha; } } }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject target) { var delta = (target.GameObject.transform.position - target.Origin.Position).magnitude; if (Distance > 0) { if (delta <= Distance) { var total = delta / Distance; byte alpha = (byte)Math.Ceiling(255 * total); transform.Color.a = alpha; } } }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject target) { if (curve.Value > Offset) { var total = 1.0f - Offset; if (total >= 0) { var value = (curve.Value - Offset) / total; byte alpha = (byte) (255 - (byte) Math.Ceiling(255 * value)); alpha = transform.Active ? alpha : (byte) 255; transform.Color.a = alpha; } } }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject target) { if (curve.Value > Offset) { var total = 1.0f - Offset; if (total >= 0) { var value = (curve.Value - Offset) / total; byte alpha = (byte)(255 - (byte)Math.Ceiling(255 * value)); alpha = transform.Active ? alpha : (byte)255; transform.Color.a = alpha; } } }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject spawned) { // Normal linear transforms transform.Scale = Vector3.Lerp(Origin.transform.localScale, Target.transform.localScale, curve.Value); // Find new position by speed var direction = (Target.transform.position - spawned.GameObject.transform.position).normalized; var delta = Speed * curve.Delta * direction; var output = spawned.GameObject.transform.position + delta; if (Math.Abs(direction.magnitude) < DirectionTolerance) { transform.Active = false; return; } // Force position to be on the correct path var correctDirection = (Origin.transform.position - Target.transform.position).normalized; var offset = output - spawned.Origin.Position; var pathLength = (correctDirection * Vector3.Dot(offset, correctDirection) / correctDirection.magnitude); var projected = Origin.transform.position + pathLength; // Distance from here to origin var left = (projected - Target.transform.position).magnitude; var total = (spawned.Origin.Position - Target.transform.position).magnitude; var increment = 1f - left / total; // Apply arc // NB. f(x) -> (x, sin(x)) ie. f'(x) -> (1, cos(x)) var currentHeight = Mathf.Sin(increment * 180f * Mathf.Deg2Rad) * this.Height; var right = Vector3.Cross(Up, direction); var tangentDirection = Mathf.Cos(increment * 180f * Mathf.Deg2Rad) * Up - correctDirection; var normal = Vector3.Cross(right, -tangentDirection); transform.Rotation = Quaternion.LookRotation(tangentDirection, normal); transform.Position = projected + Up * currentHeight; spawned.Origin.Position = Origin.transform.position; // Halt? if ((transform.Position - Target.transform.position).magnitude < ArcFixedPath.CutoffDistance) { transform.Active = false; } }
// Most of the properties are configured here. public BeatBlock(int beatBlockTypeId, float speed, float hitboxPlaybackSpeedScale, IAnimationCurve animationCurve, float intensity, bool comboable, int comboFactor, int layoutLayer, float sizeScalingFactor, bool sizeScalable, GameSpaceOccupationOverTimeTemplate hitBoxSpaceOccupation, GameSpaceOccupationOverTimeTemplate animationSpaceOccupation, IAnimationGameObjectController animationGameObjectController, IHitboxGameObjectController hitboxGameObjectController) { BeatBlockTypeId = beatBlockTypeId; Speed = speed; HitboxPlaybackSpeedScale = hitboxPlaybackSpeedScale; AnimationCurve = animationCurve; Intensity = intensity; Comboable = comboable; this.comboFactor = comboFactor; LayoutLayer = layoutLayer; this.sizeScalingFactor = sizeScalingFactor; SizeScalable = sizeScalable; this.hitBoxSpaceOccupation = hitBoxSpaceOccupation; this.animationSpaceOccupation = animationSpaceOccupation; AnimationGameObjectController = animationGameObjectController; HitboxGameObjectController = hitboxGameObjectController; OnLayoutTrack = false; GameSpaceAreaOccupation = new BeatBlockGameSpaceOccupation(() => this.hitBoxSpaceOccupation, () => this.animationSpaceOccupation, () => this.GridPosition); }
public IAnimationCurve CacheAnimation(Type type, string propertyName, IAnimationCurve animationCurve) { // Checks whether the curve affects a property marked with the CacheAnimationAttribute var property = (from p in ReflectionHelper.GetProperties(GetType()) let attributes = p.GetCustomAttributes <CacheAnimationAttribute>() from attribute in attributes where attribute != null && attribute.Type == type && attribute.PropertyName == propertyName select p).FirstOrDefault(); if (property != null) { object value = property.GetValue(this); var bGradient = value as GradientBrush; if (value == null) { throw new NotImplementedException("Solid Color animation not yet supported"); } return(GradientBrushCurve.FromColor4Curve(Device, (Color4Curve)animationCurve, bGradient)); } return(null); }
private IAnimationCurve animationCurve; // 6 public BeatBlockBuilder_Recyclable AnimationCurve(IAnimationCurve c) { setchecks[6] = true; animationCurve = c; return(this); }
public bool Contains(IAnimationCurve animationCurve) { Contract.Requires <ArgumentNullException>(animationCurve != null, "animationCurve"); return(animationCurves.ContainsKey(animationCurve.Name)); }
/// <summary> /// Initializes the animation context with the default animation curve /// |AnimationCurve.Default|. /// </summary> public AnimationContext() { this.m_curve = AnimationCurve.Default; }
internal AnimationObject(IAnimationCurve curve) { ArgumentNullException.ThrowIfNull(nameof(curve)); _func = IntPtr.Zero; _obj = curve; }
public void Update(IAnimationCurve curve, PathTransform transform, SpawnedObject spawned) { transform.Position = Vector3.Lerp(Origin.transform.position, Target.transform.position, curve.Value); transform.Rotation = Quaternion.Slerp(Origin.transform.rotation, Target.transform.rotation, curve.Value); transform.Scale = Vector3.Lerp(Origin.transform.localScale, Target.transform.localScale, curve.Value); }
public void AddCurve(IAnimationCurve animationCurve) { Contract.Requires <ArgumentException>(!Contains(animationCurve), "animationCurve"); animationCurves.Add(animationCurve.Name, animationCurve); }