예제 #1
0
        /// <summary>
        /// This gives the tail upwards momentum when turning (when the player direction and the side the last tail segement are on dont match
        /// </summary>
        /// <param name="tailInstance"></param>
        /// <param name="strength"></param>
        public static void UpwardsTurn(this TailInstance tailInstance, float strength = 2)
        {
            float startLocation = tailInstance.tailBones.ropeSegments[0].ScreenPos.X;
            int   directionMult = startLocation > tailInstance.tailBones.ropeSegments[tailInstance.tailBones.segmentCount - 1].ScreenPos.X ? -1 : 1;

            if (directionMult != tailInstance.facingDirection.X)
            {
                tailInstance.tailBones.ropeSegments[tailInstance.tailBones.segmentCount - 1].posNow.Y -= (strength * tailInstance.facingDirection.Y);
            }
        }
예제 #2
0
 /// <summary>
 /// Wobbles the tail when idle or running.
 /// </summary>
 /// <param name="tailInstance">passed instance to run this on</param>
 /// <param name="startIndex">first index that is moved</param>
 /// <param name="endIndex">last index that is moved</param>
 /// <param name="freq">frequency of the cycles</param>
 /// <param name="runningFreq">frequency of the cycles when running</param>
 /// <param name="amplitude">ampiltude of the cycles</param>
 /// <param name="runningAmplitude">amplitude of the cycles when running</param>
 /// <param name="multX">multiplier for the X axis. For tails that rest vertically</param>
 /// <param name="multY">multiplier for the Y axis. For tails that rest horizontally</param>
 /// <param name="runThreshold">speed threshold for when the player is running</param>
 public static void TailWobble(this TailInstance tailInstance, int startIndex, int endIndex, float freq = 0.05f, float runningFreq = 0.2f, float amplitude = 1f, float runningAmplitude = 1.2f, float multX = 1, float multY = 0, float runThreshold = 0.1f)
 {
     for (int i = startIndex; i < endIndex; i++)
     {
         float str = Math.Abs(tailInstance.tailBones.ropeSegments[0].posOld.X - tailInstance.tailBones.ropeSegments[0].posNow.X);
         float sin = str > 0.1f ? (float)Math.Sin((float)Main.GameUpdateCount * runningFreq) * runningAmplitude :
                     (float)Math.Sin((float)Main.GameUpdateCount * freq) * amplitude;
         tailInstance.tailBones.ropeSegments[i].posNow += new Vector2(-sin * multX, sin * multY);
     }
 }
예제 #3
0
        /// <summary>
        /// Wobbles the tail when idle or running. is run on the last segment in the tail. Use the other overload to run it on other segments.
        /// </summary>
        /// <param name="tailInstance">passed instance to run this on</param>
        /// <param name="freq">frequency of the cycles</param>
        /// <param name="runningFreq">frequency of the cycles when running</param>
        /// <param name="amplitude">ampiltude of the cycles</param>
        /// <param name="runningAmplitude">amplitude of the cycles when running</param>
        /// <param name="multX">multiplier for the X axis. For tails that rest vertically</param>
        /// <param name="multY">multiplier for the Y axis. For tails that rest horizontally</param>
        public static void TailWobble(this TailInstance tailInstance, float freq = 0.05f, float runningFreq = 0.2f, float amplitude = 0.25f, float runningAmplitude = 0.6f, float multX = 1, float multY = 0)
        {
            int index = tailInstance.tailBones.segmentCount - 1;

            tailInstance.TailWobble(index - 1, index, freq, runningFreq, amplitude, runningAmplitude, multX, multY);
        }