Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public KMSelectable[] ProcessTwitchCommand(string command)
- {
- string[] split = command.ToUpperInvariant().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
- if (split.Length < 2)
- return null;
- switch (split[0])
- {
- case "SUBMIT":
- string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
- string digits = "0123456789*";
- if (split[1].Length < 2 || !letters.Contains(split[1].Substring(0, 1)) || !digits.Contains(split[1].Substring(1, 1)))
- return null;
- int desiredLetter = letters.IndexOf(split[1].Substring(0, 1), StringComparison.Ordinal);
- int desiredDigit = digits.IndexOf(split[1].Substring(1, 1), StringComparison.Ordinal);
- int currentLetter = letters.IndexOf(lettersText.text, StringComparison.Ordinal);
- int currentDigit = digits.IndexOf(digitsText.text, StringComparison.Ordinal);
- List <KMSelectable> list = new List<KMSelectable>();
- for(int i = currentLetter; i != desiredLetter; i = ((i + 1) % letters.Length))
- list.Add(lettersDown);
- for(int i = currentDigit; i != desiredDigit; i = ((i + 1) % digits.Length))
- list.Add(digitsDown);
- list.Add(submitBut);
- return list.ToArray();
- break;
- case "PRESS":
- switch (split[1])
- {
- case "LETTER":
- if (split.Length < 3) return null;
- if(split[2] == "UP")
- return new KMSelectable[] { lettersDown };
- if(split[2] == "DOWN")
- return new KMSelectable[] { lettersUp };
- return null;
- case "DIGIT":
- if (split.Length < 3) return null;
- if (split[2] == "UP")
- return new KMSelectable[] { digitsDown };
- if (split[2] == "DOWN")
- return new KMSelectable[] { digitsUp };
- return null;
- break;
- case "SUBMIT":
- return new KMSelectable[] { submitBut };
- default:
- return null;
- }
- default:
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement