예제 #1
0
 /// 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);
 }
예제 #2
0
        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;
        }
예제 #3
0
 /// 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);
 }
        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;
        }
        /// <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);
       }
 }
예제 #7
0
        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;
     }
       }
 }
예제 #9
0
        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;
                }
            }
        }
예제 #10
0
 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;
     }
       }
 }
예제 #11
0
 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;
         }
     }
 }
예제 #12
0
        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;
            }
        }
        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;
              }
        }
예제 #14
0
        // 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);
        }
예제 #15
0
파일: Shape.cs 프로젝트: OkashiKami/Odyssey
        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);
        }
예제 #16
0
 private IAnimationCurve animationCurve;                                 // 6
 public BeatBlockBuilder_Recyclable AnimationCurve(IAnimationCurve c)
 {
     setchecks[6]   = true;
     animationCurve = c;
     return(this);
 }
예제 #17
0
 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;
 }
예제 #19
0
 internal AnimationObject(IAnimationCurve curve)
 {
     ArgumentNullException.ThrowIfNull(nameof(curve));
     _func = IntPtr.Zero;
     _obj  = curve;
 }
예제 #20
0
 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);
 }
예제 #21
0
 public void AddCurve(IAnimationCurve animationCurve)
 {
     Contract.Requires <ArgumentException>(!Contains(animationCurve), "animationCurve");
     animationCurves.Add(animationCurve.Name, animationCurve);
 }
예제 #22
0
 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);
 }