Guest User

Untitled

a guest
Aug 1st, 2019
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. /// <summary>
  2. /// This takes the property/trick you want to play (imagine the skater is in standard footing, non-switch), converts it to the property appropriate
  3. /// for current stance, then plays that instead. It plays the motion you naively expect, which internally depends on stance/direction/etc.
  4. /// </summary>
  5. /// <param name="propertyName">the property name associated with the trick anim you want to play.</param>
  6. public void PlayTrickAnim(string propertyName)
  7. {
  8.     // We store both original property name, AND the name we convert that into, for later clearing
  9.     if (!trickAnimProperties.Contains(propertyName)) { trickAnimProperties.Add(propertyName); }
  10.  
  11.     // Now, mirror the movements front/back as appropriate.
  12.     string newPropertyName = propertyName;
  13.     string[] propertyTokens = newPropertyName.Split('_');
  14.  
  15.     if (InSwitch)
  16.     {
  17.         if (propertyTokens[propertyTokens.Length -1] == "left") { propertyTokens[propertyTokens.Length - 1] = "right"; }
  18.         else if (propertyTokens[propertyTokens.Length - 1] == "right") { propertyTokens[propertyTokens.Length - 1] = "left"; }
  19.     }
  20.  
  21.     if (goofyStance)
  22.     {
  23.         if (propertyTokens[propertyTokens.Length - 1] == "left") { propertyTokens[propertyTokens.Length - 1] = "right"; }
  24.         else if (propertyTokens[propertyTokens.Length - 1] == "right") { propertyTokens[propertyTokens.Length - 1] = "left"; }
  25.     }
  26.  
  27.     newPropertyName = propertyTokens[0];
  28.     for (int index = 1; index < propertyTokens.Length; index++)
  29.     {
  30.         newPropertyName += "_" + propertyTokens[index];
  31.     }
  32.            
  33.     // (we gotta store both, to clear this properly, because of how you can enter switch state at or before the end of a trick, meaning we can't rely on current state telling us what anim was played)
  34.     if (!trickAnimProperties.Contains(newPropertyName)) { trickAnimProperties.Add(newPropertyName); }
  35.  
  36.     // Now, apply the animation!
  37.     character.SetBool(newPropertyName, true);
  38. }
Advertisement
Add Comment
Please, Sign In to add comment