Example #1
0
        /// <summary>
        ///     Makes all necessary calculations to figure out where the current point at this step of the animation is.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <returns></returns>
        public bool Tick(GameTime gameTime)
        {
            if (actor != null && (actor.StatusType & StatusType.Update) == StatusType.Update)
            {
                bool done = Looper.Loop(loopMethod, ref currentTime, ref step, maxTime);

                float timePercent     = (float)currentTime / maxTime;
                float smoothedPercent = Smoother.SmoothValue(smoothing, timePercent);

                Vector3 currentPoint = Vector3.Lerp(isRelative ? Vector3.Zero : start, destination, smoothedPercent);

                FinalOperation finalOperation = PerformOperation(currentPoint, lastPoint);

                process(finalOperation);

                lastPoint = currentPoint;

                currentTime += gameTime.ElapsedGameTime.Milliseconds * step;

                if (done)
                {
                    if (resetAfterDone)
                    {
                        process(target => start);
                    }
                    callback?.Invoke();
                }

                return(done);
            }

            return(false);
        }
Example #2
0
        private void ApplyAnimation(FinalOperation finalOperation)
        {
            Vector3 pos = finalOperation.Invoke(actor.Transform3D.Translation);

            if (body != null)
            {
                Tile tile = body.ExternalData as Tile;
                tile?.SetTranslation(pos);
            }
            else
            {
                actor.Transform3D.Translation = pos;
            }
        }
Example #3
0
 protected void ApplyAnimation(FinalOperation finalOperation)
 {
     actor.Transform3D.RotationInDegrees = finalOperation.Invoke(actor.Transform3D.RotationInDegrees);
 }
Example #4
0
 protected void ApplyAnimation(FinalOperation finalOperation)
 {
     actor.Transform3D.Scale = finalOperation.Invoke(actor.Transform3D.Scale);
 }