Example #1
0
            public Vector2 GetOffset()
            {
                time++;
                float x = time / (float)duration;

                return(new Vector2(MathTransformations.Transform(MathTransformations.Type.NormalizedSmoothStop2, x) * magnitude * (float)Math.Sin(intensity * time + initialOffset.X), MathTransformations.Transform(MathTransformations.Type.NormalizedSmoothStop2, x) * magnitude * (float)Math.Sin(intensity * time + initialOffset.Y)));
            }
Example #2
0
            public override void Draw(DrawBatch drawBatch)
            {
                Color newColor = Color.Lerp(color, Color.Transparent, MathTransformations.Transform(MathTransformations.Type.NormalizedSmoothStart2, timeAlive / (float)timeToLive) + .4f);

                drawBatch.Draw(DrawBatch.DrawCall.Tag.GameObject, Game1.pixel, new Rectangle((int)(PositionXY.X - 1 * scale), (int)((position.Y - position.Z) - 1 * scale), (int)(2 * scale), (int)(2 * scale)), new Rectangle(0, 0, 1, 1), newColor, DrawBatch.CalculateDepth(PositionXY), (short)2, 1);
                drawBatch.Draw(DrawBatch.DrawCall.Tag.Light, Game1.fader, new Vector2(PositionXY.X, PositionXY.Y - position.Z), .35f * scale, 0f, new Vector2(Game1.fader.Width * .5f), Color.Lerp(newColor, Color.DarkGray, .05f), DrawBatch.CalculateDepth(PositionXY));

                base.Draw(drawBatch);
            }
Example #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="frameA"></param>
        /// <param name="frameB"></param>
        /// <param name="amount"></param>
        /// <param name="blockedKeys">Refers to keys not allowed to compute. Will probably be used by another animation with a higher priority</param>
        /// <returns></returns>
        public KeyFrame LerpKeyFrames(KeyFrame frameA, KeyFrame frameB, float amount, string[] blockedKeys)
        {
            if (amount >= 1f)
            {
                return(frameB);
            }
            else if (amount <= 0f)
            {
                return(frameA);
            }
            Dictionary <string, Vector4> values = new Dictionary <string, Vector4>();

            foreach (KeyValuePair <string, Vector4> pair in frameA.values)
            {
                if (!blockedKeys.Contains(pair.Key) && frameB.values.ContainsKey(pair.Key))
                {
                    values.Add(pair.Key, new Vector4(Extensions.LerpAngles(frameA.values[pair.Key].X, frameB.values[pair.Key].X, MathTransformations.Transform(frameB.transformations[pair.Key].x, amount), frameB.invertRotation[pair.Key].a)
                                                     , Extensions.LerpAngles(frameA.values[pair.Key].Y, frameB.values[pair.Key].Y, MathTransformations.Transform(frameB.transformations[pair.Key].y, amount), frameB.invertRotation[pair.Key].b)
                                                     , Extensions.LerpAngles(frameA.values[pair.Key].Z, frameB.values[pair.Key].Z, MathTransformations.Transform(frameB.transformations[pair.Key].z, amount), frameB.invertRotation[pair.Key].c)
                                                     , Extensions.LerpFloat(frameA.values[pair.Key].W, frameB.values[pair.Key].W, MathTransformations.Transform(frameB.transformations[pair.Key].w, amount))));
                }
            }

            return(new KeyFrame(currentTime, values, frameA.invertRotation, frameA.transformations));
        }