Advertisement
caitsith2

Symbolic Coordinates Twitch play code

Jan 15th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.89 KB | None | 0 0
  1.         public KMSelectable[] ProcessTwitchCommand(string command)
  2.         {
  3.             string[] split = command.ToUpperInvariant().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
  4.  
  5.             if (split.Length < 2)
  6.                 return null;
  7.  
  8.             switch (split[0])
  9.             {
  10.                 case "SUBMIT":
  11.                     string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
  12.                     string digits = "0123456789*";
  13.                     if (split[1].Length < 2 || !letters.Contains(split[1].Substring(0, 1)) || !digits.Contains(split[1].Substring(1, 1)))
  14.                         return null;
  15.                     int desiredLetter = letters.IndexOf(split[1].Substring(0, 1), StringComparison.Ordinal);
  16.                     int desiredDigit = digits.IndexOf(split[1].Substring(1, 1), StringComparison.Ordinal);
  17.                     int currentLetter = letters.IndexOf(lettersText.text, StringComparison.Ordinal);
  18.                     int currentDigit = digits.IndexOf(digitsText.text, StringComparison.Ordinal);
  19.                     List <KMSelectable> list = new List<KMSelectable>();
  20.                     for(int i = currentLetter; i != desiredLetter; i = ((i + 1) % letters.Length))
  21.                         list.Add(lettersDown);
  22.                     for(int i = currentDigit; i != desiredDigit; i = ((i + 1) % digits.Length))
  23.                         list.Add(digitsDown);
  24.                     list.Add(submitBut);
  25.                     return list.ToArray();
  26.                     break;
  27.                 case "PRESS":
  28.                     switch (split[1])
  29.                     {
  30.                         case "LETTER":
  31.                             if (split.Length < 3) return null;
  32.                             if(split[2] == "UP")
  33.                                 return new KMSelectable[] { lettersDown };
  34.                             if(split[2] == "DOWN")
  35.                                 return new KMSelectable[] { lettersUp };
  36.                             return null;
  37.                         case "DIGIT":
  38.                             if (split.Length < 3) return null;
  39.                             if (split[2] == "UP")
  40.                                 return new KMSelectable[] { digitsDown };
  41.                             if (split[2] == "DOWN")
  42.                                 return new KMSelectable[] { digitsUp };
  43.                             return null;
  44.                             break;
  45.                         case "SUBMIT":
  46.                             return new KMSelectable[] { submitBut };
  47.                         default:
  48.                             return null;
  49.                     }
  50.                 default:
  51.                     return null;
  52.             }
  53.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement