예제 #1
0
#pragma warning restore 414

    /// <summary>
    /// TwitchPlays Compatibility, detects every chat message and clicks buttons accordingly.
    /// </summary>
    /// <param name="command">The twitch command made by the user.</param>
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] commands = command.Split(' ');

        //if command is formatted correctly
        if (Regex.IsMatch(commands[0], @"^\s*cut\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            //if command has no parameters
            if (commands.Length < 2)
            {
                yield return("sendtochaterror Please specify the wire you want to cut! (Valid: 1-7)");
            }

            //if command has too many parameters
            else if (commands.Length > 2)
            {
                yield return("sendtochaterror Too many wires requested! Only one can be cut at any time.");
            }

            //if command has an invalid parameter
            else if (!IsValid(commands.ElementAt(1), true))
            {
                yield return("sendtochaterror Invalid number! Only wires 1-7 can be pushed.");
            }

            //if command is valid, cut wire accordingly
            else
            {
                while (true)
                {
                    if (char.GetNumericValue(commands[1].ToCharArray()[0]) == _wireSelected + 1)
                    {
                        break;
                    }

                    btn[1].OnInteract();
                    yield return(new WaitForSeconds(0.1f));
                }

                submit.OnInteract();
            }
        }

        //if command is formatted correctly
        if (Regex.IsMatch(commands[0], @"^\s*manual\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            //if command has no parameters
            if (commands.Length < 2)
            {
                yield return("sendtochaterror Please specify the manual section you want to read! (Valid: <#>.<#>, 2-7.1-8)");
            }

            //if command has too many parameters
            else if (commands.Length > 2)
            {
                yield return("sendtochaterror Too many instructions sent! Only one page can be viewed at a time.");
            }

            //if command has an invalid parameter
            else if (!IsValid(commands.ElementAt(1), false))
            {
                yield return("sendtochaterror Invalid instruction! Expected: <#>.<#>, 2-7.1-8");
            }

            //if command is valid, go to section accordingly
            else
            {
                btn[4].OnInteract();

                while (char.GetNumericValue(commands[1][0]) != (_instructionsIndex / 9) + 1)
                {
                    btn[4].OnInteract();
                    yield return(new WaitForSeconds(0.02f));
                }

                while (char.GetNumericValue(commands[1][2]) != _instructionsIndex % 9)
                {
                    btn[3].OnInteract();
                    yield return(new WaitForSeconds(0.02f));
                }
            }
        }
    }
예제 #2
0
    #pragma warning restore 414

    IEnumerator ProcessTwitchCommand(string Command)
    {
        string[] parameters = Command.Trim().ToUpperInvariant().Split(' ');

        if (parameters.Length == 1 && new string[] { "COLORBLIND", "COLOURBLIND", "COLOR-BLIND", "COLOUR-BLIND", "CB" }.Contains(parameters[0]))
        {
            yield return(null);

            cbON = !cbON;
            SetCB();
        }

        if ((parameters.Length == 1) && (parameters[0] == "SUBMIT"))
        {
            yield return(null);

            submitButton.OnInteract();
            yield return(new WaitForSecondsRealtime(0.1f));
        }
        else if ((parameters.Length > 1) && (parameters[0] == "BREAK"))
        {
            List <string> rungsToBreak = new List <string>();
            switch (stage)
            {
            case 0: yield return("sendtochaterror You can't break any ladders yet you silly goose!"); yield break;

            case 1: possibleLetters = " ABCDEFGH"; break;

            case 2: possibleLetters = " ABCDEFGHIJKLMNOPQ"; break;

            case 3: possibleLetters = " ABCDEFGHIJKLMNOPQRSTUVWX"; break;
            }
            for (int i = 1; i < parameters.Length; i++)
            {
                rungsToBreak.Add(parameters[i]);
            }
            if (!rungsToBreak.All(x => possibleLetters.Contains(x)))
            {
                yield return("sendtochaterror You cannot break that rung yet.");
            }
            else
            {
                yield return(null);

                foreach (string letter in rungsToBreak)
                {
                    foreach (GameObject[] array in allRungs)
                    {
                        foreach (GameObject rung in array)
                        {
                            if (rung.GetComponentInChildren <TextMesh>().text == letter)
                            {
                                if (!allLadderStatuses[Array.IndexOf(allRungs, array)][Array.IndexOf(array, rung)])
                                {
                                    rung.GetComponentInChildren <KMSelectable>().OnInteract();
                                    yield return(new WaitForSecondsRealtime(0.2f));
                                }
                            }
                        }
                    }               /* :) */
                }
            }
        }
    }
예제 #3
0
 // TPK Methods
 protected void DoInteractionStart(KMSelectable interactable)
 {
     interactable.OnInteract();
 }
 IEnumerator TwitchHandleForcedSolve()
 {
     if (ThatWasGreat[Sure] == (Ann * 3) + Need)
     {
         Joon.OnInteract();
         yield return(new WaitForSeconds(0.1f));
     }
     else
     {
         if (SingleNote != 1)
         {
             JuneFifteenth[1].OnInteract();
             yield return(new WaitForSeconds(0.1f));
         }
         int   ct     = Sure;
         int   ct2    = Sure;
         int[] counts = new int[2];
         while (ct != Array.IndexOf(ThatWasGreat, (Ann * 3) + Need))
         {
             ct++;
             if (ct > 7)
             {
                 ct = 0;
             }
             counts[1]++;
         }
         while (ct2 != Array.IndexOf(ThatWasGreat, (Ann * 3) + Need))
         {
             ct2--;
             if (ct2 < 0)
             {
                 ct2 = 7;
             }
             counts[0]++;
         }
         if (counts[0] > counts[1])
         {
             for (int i = 0; i < counts[1]; i++)
             {
                 JuneEleventh[1].OnInteract();
                 yield return(new WaitForSeconds(0.1f));
             }
         }
         else if (counts[0] < counts[1])
         {
             for (int i = 0; i < counts[0]; i++)
             {
                 JuneEleventh[0].OnInteract();
                 yield return(new WaitForSeconds(0.1f));
             }
         }
         else
         {
             int rand = UnityEngine.Random.Range(0, 2);
             for (int i = 0; i < counts[rand]; i++)
             {
                 JuneEleventh[rand].OnInteract();
                 yield return(new WaitForSeconds(0.1f));
             }
         }
         while (ThatWasGreat[Sure] != (Ann * 3) + Need)
         {
             yield return(null);
         }
         Joon.OnInteract();
         yield return(new WaitForSeconds(0.1f));
     }
 }
예제 #5
0
#pragma warning restore 414

    // Commands
    private IEnumerator ProcessTwitchCommand(string command)
    {
        Match m;

        // Stage 1 tap
        if (Regex.IsMatch(command, @"^\s*touch\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            ModuleButton.OnInteract();
        }

        // Stage 2 tap
        else if ((m = Regex.Match(command, @"^\s*touch\s+(\d)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            yield return(null);

            int value = int.Parse(m.Groups[1].Value);

            // !cancel-able
            while (((int)Bomb.GetTime()) % 10 != value)
            {
                yield return("trycancel");
            }

            ModuleButton.OnInteract();
        }

        // Stage 3 tap
        else if ((m = Regex.Match(command, @"^\s*touch\s+(\d\d)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            int value = int.Parse(m.Groups[1].Value);

            // If arguement is invalid
            if (value >= 60)
            {
                yield return("sendtochaterror The number of seconds must be 00-59.");

                yield break;
            }

            // Elevator music calculation
            int currentTime = (int)Bomb.GetTime() % 60;

            int interval =
                ZenModeActive ? (value > currentTime ? value - currentTime : value - currentTime + 60)
                              : (currentTime > value ? currentTime - value : currentTime - value + 60);

            yield return(null);

            if (interval > 10)
            {
                yield return("waiting music");
            }

            // !cancel-able
            while (((int)Bomb.GetTime()) % 60 != value)
            {
                yield return("trycancel");
            }

            yield return("solve");

            ModuleButton.OnInteract();
        }
    }
예제 #6
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (Regex.IsMatch(command, @"^\s*start\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (logo.gameObject.activeSelf)
            {
                logo.OnInteract();
            }
            else
            {
                yield return("sendtochaterror A game of Sonic & Knuckles has already been started!");
            }
            yield break;
        }
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*press\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 4)
            {
                if (Regex.IsMatch(parameters[2], @"^\s*at\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    yield return(null);

                    if (cmdIsValid(parameters[3]))
                    {
                        int time = 0;
                        int.TryParse(parameters[3], out time);
                        if (Regex.IsMatch(parameters[1], @"^\s*badnik\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                        {
                            if (badniks[backgroundIndex].gameObject.activeSelf)
                            {
                                while ((secondsCount != time - 40) && (secondsCount != time - 20) && (secondsCount != time) && (secondsCount != time + 20) && (secondsCount != time + 40))
                                {
                                    yield return(new WaitForSeconds(0.1f));

                                    yield return("trycancel The Badnik press was cancelled due to a cancel request.");
                                }
                                badniks[backgroundIndex].GetComponent <KMSelectable>().OnInteract();
                            }
                            else
                            {
                                yield return("sendtochaterror The Badnik cannot be pressed right now!");
                            }
                        }
                        if (Regex.IsMatch(parameters[1], @"^\s*hero\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                        {
                            if (heroes[heroIndex].gameObject.activeSelf)
                            {
                                while ((secondsCount != time - 40) && (secondsCount != time - 20) && (secondsCount != time) && (secondsCount != time + 20) && (secondsCount != time + 40))
                                {
                                    yield return(new WaitForSeconds(0.1f));

                                    yield return("trycancel The Hero press was cancelled due to a cancel request.");
                                }
                                heroes[heroIndex].GetComponent <KMSelectable>().OnInteract();
                            }
                            else
                            {
                                yield return("sendtochaterror The Hero cannot be pressed right now!");
                            }
                        }
                        if (Regex.IsMatch(parameters[1], @"^\s*monitor\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                        {
                            if (monitors[backgroundIndex].gameObject.activeSelf)
                            {
                                while ((secondsCount != time - 40) && (secondsCount != time - 20) && (secondsCount != time) && (secondsCount != time + 20) && (secondsCount != time + 40))
                                {
                                    yield return(new WaitForSeconds(0.1f));

                                    yield return("trycancel The Monitor press was cancelled due to a cancel request.");
                                }
                                monitors[backgroundIndex].GetComponent <KMSelectable>().OnInteract();
                            }
                            else
                            {
                                yield return("sendtochaterror The Monitor cannot be pressed right now!");
                            }
                        }
                    }
                    else
                    {
                        yield return("sendtochaterror The specified time is invalid! Valid times are between 00 and 59!");
                    }
                }
            }
            else if (parameters.Length == 2)
            {
                if (Regex.IsMatch(parameters[1], @"^\s*badnik\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    yield return(null);

                    if (badniks[backgroundIndex].gameObject.activeSelf)
                    {
                        while ((secondsCount == (ringCount % 20)) || (secondsCount == (ringCount % 20) + 20) || (secondsCount == (ringCount % 20) + 40))
                        {
                            yield return(new WaitForSeconds(0.1f));
                        }
                        badniks[backgroundIndex].GetComponent <KMSelectable>().OnInteract();
                    }
                    else
                    {
                        yield return("sendtochaterror The Badnik cannot be pressed right now!");
                    }
                }
                if (Regex.IsMatch(parameters[1], @"^\s*hero\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    yield return(null);

                    if (heroes[heroIndex].gameObject.activeSelf)
                    {
                        while ((secondsCount == (ringCount % 20)) || (secondsCount == (ringCount % 20) + 20) || (secondsCount == (ringCount % 20) + 40))
                        {
                            yield return(new WaitForSeconds(0.1f));
                        }
                        heroes[heroIndex].GetComponent <KMSelectable>().OnInteract();
                    }
                    else
                    {
                        yield return("sendtochaterror The Hero cannot be pressed right now!");
                    }
                }
                if (Regex.IsMatch(parameters[1], @"^\s*monitor\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    yield return(null);

                    if (monitors[backgroundIndex].gameObject.activeSelf)
                    {
                        while ((secondsCount == (ringCount % 20)) || (secondsCount == (ringCount % 20) + 20) || (secondsCount == (ringCount % 20) + 40))
                        {
                            yield return(new WaitForSeconds(0.1f));
                        }
                        monitors[backgroundIndex].GetComponent <KMSelectable>().OnInteract();
                    }
                    else
                    {
                        yield return("sendtochaterror The Monitor cannot be pressed right now!");
                    }
                }
            }
            yield break;
        }
        if (Regex.IsMatch(parameters[0], @"^\s*even\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 2)
            {
                yield return(null);

                if (cmdIsValid2(parameters[1]))
                {
                    if (boss.gameObject.activeSelf)
                    {
                        int temp = 0;
                        int.TryParse(parameters[1], out temp);
                        for (int i = 0; i < temp; i++)
                        {
                            while (hitting == true)
                            {
                                yield return(new WaitForSeconds(0.1f));
                            }
                            while (secondsCount % 2 != 0)
                            {
                                yield return(new WaitForSeconds(0.1f));
                            }
                            boss.GetComponent <KMSelectable>().OnInteract();
                            yield return(new WaitForSeconds(0.5f));
                        }
                        yield return(new WaitForSeconds(0.1f));

                        if (moduleSolved)
                        {
                            yield return("solve");
                        }
                    }
                    else
                    {
                        yield return("sendtochaterror Dr. Robotnik cannot be hit right now!");
                    }
                }
                else
                {
                    yield return("sendtochaterror The number of times to hit Dr. Robotnik is invalid! Valid number of times are between 1 and 10!");
                }
            }
            yield break;
        }
        if (Regex.IsMatch(parameters[0], @"^\s*odd\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 2)
            {
                yield return(null);

                if (cmdIsValid2(parameters[1]))
                {
                    if (boss.gameObject.activeSelf)
                    {
                        int temp = 0;
                        int.TryParse(parameters[1], out temp);
                        for (int i = 0; i < temp; i++)
                        {
                            while (hitting == true)
                            {
                                yield return(new WaitForSeconds(0.1f));
                            }
                            while (secondsCount % 2 == 0)
                            {
                                yield return(new WaitForSeconds(0.1f));
                            }
                            boss.GetComponent <KMSelectable>().OnInteract();
                        }
                        yield return(new WaitForSeconds(0.1f));

                        if (moduleSolved)
                        {
                            yield return("solve");
                        }
                    }
                    else
                    {
                        yield return("sendtochaterror Dr. Robotnik cannot be hit right now!");
                    }
                }
                else
                {
                    yield return("sendtochaterror The number of times to hit Dr. Robotnik is invalid! Valid number of times are between 1 and 10!");
                }
            }
            yield break;
        }
    }
예제 #7
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (Regex.IsMatch(command, @"^\s*reset\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            Debug.LogFormat("[Bamboozling Button #{0}] TP reset called!", moduleID);
            StopCoroutine(textCycle);
            Start();
            yield break;
        }
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*press\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 2)
            {
                if (isInputValid(parameters[1]))
                {
                    yield return(null);

                    int timepress = 0;
                    int.TryParse(parameters[1], out timepress);
                    if (parameters[1].Length == 1)
                    {
                        Debug.LogFormat("[Bamboozling Button #{0}] Pressing the button at '##:#{1}'!", moduleID, timepress);
                        while ((((int)Bomb.GetTime() % 60) % 10) != timepress)
                        {
                            yield return("trycancel The button was not pressed due to a request to cancel.");
                        }
                    }
                    else
                    {
                        Debug.LogFormat("[Bamboozling Button #{0}] Pressing the button at '##:{1}'!", moduleID, timepress);
                        while (((int)Bomb.GetTime() % 60) != timepress)
                        {
                            yield return("trycancel The button was not pressed due to a request to cancel.");
                        }
                    }
                    button.OnInteract();
                }
                else
                {
                    yield return("sendtochat That specified set of digits is invalid!");
                }
            }
            yield break;
        }
        if (Regex.IsMatch(parameters[0], @"^\s*dtap\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 2)
            {
                if (isInputValid(parameters[1]))
                {
                    yield return(null);

                    int timepress = 0;
                    int.TryParse(parameters[1], out timepress);
                    if (parameters[1].Length == 1)
                    {
                        Debug.LogFormat("[Bamboozling Button #{0}] Double Tapping the button at '##:#{1}'!", moduleID, timepress);
                        while ((((int)Bomb.GetTime() % 60) % 10) != timepress)
                        {
                            yield return("trycancel The button was not double tapped due to a request to cancel.");
                        }
                    }
                    else
                    {
                        Debug.LogFormat("[Bamboozling Button #{0}] Double Tapping the button at '##:{1}'!", moduleID, timepress);
                        while (((int)Bomb.GetTime() % 60) != timepress)
                        {
                            yield return("trycancel The button was not double tapped due to a request to cancel.");
                        }
                    }
                    button.OnInteract();
                    yield return(new WaitForSeconds(0.05f));

                    button.OnInteract();
                }
                else
                {
                    yield return("sendtochat That specified set of digits is invalid!");
                }
            }
            yield break;
        }
    }
예제 #8
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (Regex.IsMatch(command, @"^\s*colorblind\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            Debug.LogFormat("[Codenames #{0}] Colorblind mode toggled! (TP)", moduleId);
            if (colorblindActive)
            {
                colorblindActive = false;
                cblindback.GetComponent <TextMesh>().text = "";
                cblindtext.GetComponent <TextMesh>().text = "";
            }
            else
            {
                colorblindActive = true;
                if (colorNames[teamIndex - 1].Equals("blue"))
                {
                    cblindback.GetComponent <TextMesh>().text = "Blue";
                }
                else
                {
                    cblindback.GetComponent <TextMesh>().text = "Red";
                }
            }
            yield break;
        }
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length >= 2)
            {
                string temp  = "";
                int    index = -1;
                for (int i = 1; i < parameters.Length; i++)
                {
                    if (i == 1)
                    {
                        temp += parameters[i];
                    }
                    else
                    {
                        temp += " " + parameters[i];
                    }
                }
                for (int i = 0; i < grid.Length; i++)
                {
                    if (grid[i].EqualsIgnoreCase(temp))
                    {
                        index = i;
                    }
                }
                if (index == -1)
                {
                    yield return("sendtochaterror The specified word '" + temp + "' is not on any of the cards!");

                    yield break;
                }
                yield return(null);

                if (solution[index] == false)
                {
                    yield return("strike");
                }
                else if (aboutToSolve(index))
                {
                    yield return("solve");
                }
                speed = true;
                StartCoroutine(cancelSpeed());
                while (!mainword.text.EqualsIgnoreCase(temp))
                {
                    yield return("trycancel Card submission halted due to a request to cancel!");

                    yield return(new WaitForSeconds(0.1f));
                }
                speed = false;
                mainbutton.OnInteract();
            }
            else
            {
                yield return("sendtochaterror Please include a word to submit!");
            }
            yield break;
        }
    }
예제 #9
0
    public IEnumerator ProcessTwitchCommand(string command)
    {
        string[] pieces = command.Trim().ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

        if (pieces.Length > 1 && (pieces[0] == "submit" || pieces[0] == "sell" || pieces[0] == "middle" || pieces[0] == "s" || pieces[0] == "m"))
        {
            command = command.Substring(pieces[0].Length).Trim();
            if (Flavours.All(x => !x.Name.StartsWith(command, StringComparison.InvariantCultureIgnoreCase)))
            {
                yield return(string.Format("sendtochaterror I don't know of a flavour called {0}", command));

                yield break;
            }

            yield return(null);

            string originalLabel = FlavourLabel.text;
            do
            {
                if (FlavourLabel.text.StartsWith(command, StringComparison.InvariantCultureIgnoreCase))
                {
                    SellButton.OnInteract();
                    yield break;
                }
                RightButton.OnInteract();
                yield return(new WaitForSeconds(0.25f));
            }while (FlavourLabel.text != originalLabel);
            yield return("unsubmittablepenalty");

            yield break;
        }
        else if (pieces.Length == 1 && pieces[0] == "cycle")
        {
            yield return(null);

            string originalLabel = FlavourLabel.text;
            do
            {
                RightButton.OnInteract();
                yield return(new WaitForSeconds(1.5f));
            }while (FlavourLabel.text != originalLabel);
            yield break;
        }
        else if (pieces.Length == 1 && pieces[0] == "hours")
        {
            if (modSettings.HoursCommandEnabled())
            {
                yield return("sendtochat " + (modSettings.OpeningTimeEnabled() ? "We are open every other hour today." : "We're open all day today!"));
            }
            else
            {
                yield return("sendtochat Sorry, hours are currently unavailable. Enjoy your ice cream!");
            }
        }

        var buttons = new List <KMSelectable>();

        for (int i = 0; i < pieces.Length; i++)
        {
            switch (pieces[i])
            {
            case "l":
            case "left":
                buttons.Add(LeftButton);
                break;

            case "r":
            case "right":
                buttons.Add(RightButton);
                break;

            case "s":
            case "m":
            case "sell":
            case "submit":
            case "middle":
                buttons.Add(SellButton);
                break;

            default:
                yield break;
            }
        }

        if (buttons.Count > 0)
        {
            yield return(null);

            foreach (var button in buttons)
            {
                button.OnInteract();
                yield return(new WaitForSeconds(.1f));
            }
        }
    }
예제 #10
0
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Recalling)
        {
            yield return("sendtochaterror The module is recalling. The command was not processed.");

            yield break;
        }

        if (Processing)
        {
            yield return("sendtochaterror The module is currently processing the answer. The command was not processed.");

            yield break;
        }

        if (Regex.IsMatch(command, @"^\s*recall\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Guessing)
            {
                yield return("sendtochaterror You are currently guessing a person. The command was not processed.");

                yield break;
            }
            MainButton.OnInteract();
        }

        if (Regex.IsMatch(command, @"^\s*recallfocus\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Guessing)
            {
                yield return("sendtochaterror You are currently guessing a person. The command was not processed.");

                yield break;
            }

            MainButton.OnInteract();
            while (Recalling)
            {
                yield return(null);
            }
        }

        if (Regex.IsMatch(parameters[0], @"^\s*guess\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length > 2 || parameters.Length < 2)
            {
                yield return("sendtochaterror Parameter length is not valid. The command was not processed.");

                yield break;
            }

            if (!Guessing)
            {
                yield return("sendtochaterror You are currently not guessing a person. The command was not processed.");

                yield break;
            }

            if (parameters[1].Length > 5 || parameters[1].Length < 5)
            {
                yield return("sendtochaterror Name length is too long/short. The command was not processed.");

                yield break;
            }

            foreach (char c in parameters[1])
            {
                if (!c.ToString().EqualsAny(Alphabet))
                {
                    yield return("sendtochaterror The name contains an invalid character. The command was not processed.");

                    yield break;
                }
            }

            for (int x = 0; x < parameters[1].Length; x++)
            {
                int ct1   = 0;
                int ct2   = 0;
                int start = NumberBase[x];
                int check = Array.IndexOf(Alphabet, parameters[1][x].ToString());
                while (start != check)
                {
                    start++;
                    ct1++;
                    if (start > 25)
                    {
                        start = 0;
                    }
                }
                start = NumberBase[x];
                while (start != check)
                {
                    start--;
                    ct2++;
                    if (start < 0)
                    {
                        start = 25;
                    }
                }
                if (ct1 < ct2)
                {
                    for (int i = 0; i < ct1; i++)
                    {
                        ButtonRight[x].OnInteract();
                        yield return(new WaitForSecondsRealtime(0.05f));
                    }
                }
                else if (ct2 < ct1)
                {
                    for (int i = 0; i < ct2; i++)
                    {
                        ButtonLeft[x].OnInteract();
                        yield return(new WaitForSecondsRealtime(0.05f));
                    }
                }
                else
                {
                    int type = UnityEngine.Random.Range(0, 2);
                    if (type == 0)
                    {
                        for (int i = 0; i < ct1; i++)
                        {
                            ButtonLeft[x].OnInteract();
                            yield return(new WaitForSecondsRealtime(0.05f));
                        }
                    }
                    else
                    {
                        for (int i = 0; i < ct1; i++)
                        {
                            ButtonRight[x].OnInteract();
                            yield return(new WaitForSecondsRealtime(0.05f));
                        }
                    }
                }
            }
            yield return("solve");

            yield return("strike");

            MainButton.OnInteract();
        }
    }
예제 #11
0
    private IEnumerator ProcessTwitchCommand(string command)
    {
        command = command.ToLowerInvariant().Trim();
        var split = command.Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);

        if ((split.Length == 2 && split[0].StartsWith("press") && split[1].StartsWith("screen")) || (split.Length == 1 && split[0].StartsWith("screen")))
        {
            yield return(new WaitForSeconds(0.05f));

            Display.OnInteract();
            yield return(false);
        }
        else if (split.Length == 3 && split[0].StartsWith("start") && split[1].StartsWith("on"))
        {
            if (!screened || solved || bruh || split[2].Length != 1 || split[2].Any(letter => !letter.EqualsAny('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')))
            {
                yield break;
            }
            pressed = false;
            int tptime = Int32.Parse(split[2]);
            while (!pressed)
            {
                if (time == tptime)
                {
                    Bottom.OnInteract();
                    pressed = true;
                }
                yield return(new WaitForSeconds(.1f));
            }
        }
        else if (split.Length == 1 && split[0].StartsWith("reset"))
        {
            yield return(new WaitForSeconds(1.0f));

            R.OnInteract();
            yield return(null);
        }
        else if (split.Length == 2 && split[0].StartsWith("submit"))
        {
            string code = split[1];
            if (code.Any(letter => letter.EqualsAny('l', 'r')) && code.Length < 8)
            {
                yield return("sendtochat Sorry, there is not enough digits! If your answer lower than 10000000, add zeros before your number to make 8 digits.");
            }
            else if (code.Any(letter => letter.EqualsAny('l', 'r')) && code.Length == 8)
            {
                foreach (char c in code)
                {
                    yield return(new WaitForSeconds(.1f));

                    if (c == 'l')
                    {
                        B[0].OnInteract();
                    }
                    else if (c == 'r')
                    {
                        B[1].OnInteract();
                    }
                }
            }
            Send.OnInteract();
            yield return(null);
        }
    }
예제 #12
0
#pragma warning restore 414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        command = command.ToLowerInvariant();
        if (command == "cycle")
        {
            int d = placed.Count(x => x == false);
            for (int i = 0; i < d; i++)
            {
                yield return(new WaitForSeconds(1f));

                scrolls[1].OnInteract();
            }
            yield break;
        }
        if (command == "reset")
        {
            yield return(null);

            reset.OnInteract();
            yield break;
        }
        string[] commands = command.Split(' ');
        if (commands.Length > 2)
        {
            yield return("sendtochaterror!f Too many arguments.");

            yield break;
        }
        if (commands[0] == "scroll")
        {
            int dir = Array.IndexOf(new string[] { "left", "right", "l", "r" }, commands[1]) % 2;
            if (dir < 0)
            {
                yield return("sendtochaterror!f Invalid scroll direction.");

                yield break;
            }
            yield return(null);

            scrolls[dir].OnInteract();
        }
        else
        {
            if (command.Length < 2)
            {
                yield return("sendtochaterror!f Too few arguments.");

                yield break;
            }
            if (commands.Length == 1)
            {
                commands = new string[] { command[0].ToString(), command[1].ToString() }
            }
            ;
            int[] arr = new int[] { Array.IndexOf(new string[] { "r", "d", "l", "u" }, commands[0]), Array.IndexOf(new string[] { "1", "2", "3", "4", "5" }, commands[1]) };
            if (arr[0] < 0 || arr[1] < 0)
            {
                yield return("sendtochaterror!f " + command + " is not a valid command.");

                yield break;
            }
            yield return(null);

            arrows[(arr[0] * 5) + arr[1]].OnInteract();
        }
    }
}
예제 #13
0
#pragma warning restore 414

    public IEnumerator ProcessTwitchCommand(string command)
    {
        Match match;

        // !{0} add 1 9, 2 2 [add 9 times ingredient 1, 2 times ingredient 2]
        if ((match = Regex.Match(command, @"^\s*add\s+(\d\s+\d+(,\s*\d\s+\d+)*)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            var data = match.Groups[1].Value.Split(',')
                       .Select(inf => Regex.Match(inf, @"^\s*(\d+)\s+(\d+)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                       .Select(m => new { Ingredient = int.Parse(m.Groups[1].Value), Amount = int.Parse(m.Groups[2].Value) })
                       .ToArray();
            if (data.Any(inf => inf.Ingredient < 1 || inf.Ingredient > 5 || inf.Amount < 1 || inf.Amount > 20))
            {
                yield return("sendtochaterror Ingredients must be 1–5 (reading order) and amount must be 1–20.");

                yield break;
            }
            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;
            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            yield return(data.SelectMany(inf => Enumerable.Repeat(ingredients[inf.Ingredient - 1], inf.Amount)).ToArray());

            yield break;
        }

        // !{0} slot 1, slot 2
        else if ((match = Regex.Match(command, @"^\s*slot\s+([12])\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;
            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            yield return(new[] { match.Groups[1].Value == "1" ? slot1 : slot2 });
        }

        // !{0} trash
        else if (Regex.IsMatch(command, @"^\s*trash\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;
            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            yield return(new[] { trash });
        }

        else if (Regex.IsMatch(command, @"^\s*stopmixing\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (mixing)
            {
                yield return(null);

                yield return(new[] { mix });
            }
        }

        // !{0} mix 4 [mix for that many seconds]
        else if ((match = Regex.Match(command, @"^\s*mix\s+(\d+)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            if (mixing)
            {
                yield return("sendtochaterror The drink is already mixing. To cancel it, use: !{0} stopmixing");

                yield break;
            }

            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;

            mix.OnInteract();
            var remainingDuration = float.Parse(match.Groups[1].Value);
            TwitchShouldCancelCommand = false;

            while (remainingDuration > 0 && !TwitchShouldCancelCommand)
            {
                yield return(null);

                remainingDuration -= Time.deltaTime;
            }
            yield return(new[] { mix });

            if (TwitchShouldCancelCommand)
            {
                yield return("cancelled");
            }
        }

        // !{0} iced
        else if (Regex.IsMatch(command, @"^\s*iced\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;
            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            yield return(new[] { iced });
        }

        // !{0} aged
        else if (Regex.IsMatch(command, @"^\s*aged\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;
            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            yield return(new[] { aged });
        }

        // !{0} bottled <drink>
        else if ((match = Regex.Match(command, @"^\s*bottled\s+(.*?)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            var button =
                Regex.IsMatch(match.Groups[1].Value, @"^\s*absinthe\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) ? BottledOptions[0] :
                Regex.IsMatch(match.Groups[1].Value, @"^\s*rum\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) ? BottledOptions[1] :
                Regex.IsMatch(match.Groups[1].Value, @"^\s*mulan\s+tea\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) ? BottledOptions[2] :
                Regex.IsMatch(match.Groups[1].Value, @"^\s*a\s+fedora\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) ? BottledOptions[3] : null;
            if (button == null)
            {
                yield return(@"sendtochaterror That’s not a bottled drink I recognize!");

                yield break;
            }

            yield return(null);

            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            if (!bottleDrinkMenuVisible)
            {
                yield return new[] { bottled }
            }
            ;
            yield return(new[] { button });
        }

        // !{0} serve
        else if (Regex.IsMatch(command, @"^\s*serve\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (bottleDrinkMenuVisible)
            {
                yield return new[] { close }
            }
            ;
            if (mixing)
            {
                yield return new[] { mix }
            }
            ;
            yield return(new[] { serve });
        }
    }
}
#pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        do
        {
            yield return("trycancel");
        } while (stageCompleteActive || strikeHandlerActive);
        if (moduleSolved)
        {
            yield return("sendtochaterror The module has entered its Harmony Phase, causing this module to be solve shortly.");

            yield break;
        }
        if (Regex.IsMatch(command, @"^\s*start\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (listen)
            {
                yield return("sendtochaterror The module is already listening.");

                yield break;
            }
            yield return(null);

            LstnBtn.OnInteract();
            yield break;
        }
        if (Regex.IsMatch(command, @"^\s*stop\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (!listen)
            {
                yield return("sendtochaterror The module is already not listening.");

                yield break;
            }
            yield return(null);

            LstnBtn.OnInteractEnded();
            yield break;
        }
        if (Regex.IsMatch(command, @"^\s*reset\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            correctNotes = 0;
            DisableLights();
            yield break;
        }
        Match m;

        if ((m = Regex.Match(command, @"^\s*instrument\s+(xylo|piano|music|harp)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            yield return(null);

            if (listen)
            {
                LstnBtn.OnInteractEnded();
            }
            var targetInstrument =
                m.Groups[1].Value.EqualsIgnoreCase("music") ? 0 :
                m.Groups[1].Value.EqualsIgnoreCase("piano") ? 1 :
                m.Groups[1].Value.EqualsIgnoreCase("xylo") ? 2 : 3;

            while (moduleInstrument != targetInstrument)
            {
                yield return(new WaitForSeconds(0.1f));

                InsCycBtns[0].OnInteract();
            }
            yield break;
        }
        if ((m = Regex.Match(command, @"^\s*sound\s+([\d,;]+)$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            var numbers = m.Groups[1].Value.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).Select(str =>
            {
                int value;
                return(int.TryParse(str, out value) ? value : (int?)null);
            }).ToArray();
            if (numbers.Length == 0 || numbers.Any(n => n == null || n.Value < 1 || n.Value > 4))
            {
                yield break;
            }

            yield return(null);

            if (listen)
            {
                LstnBtn.OnInteractEnded();
                yield return(new WaitForSeconds(.1f));
            }
            yield return(numbers.Select(n => SeqBtns[n.Value - 1]).ToArray());

            yield return("solve");

            yield break;
        }
    }
예제 #15
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(command, @"^\s*send\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            SendButton.OnInteract();
            yield break;
        }

        if (Regex.IsMatch(command, @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            for (int x = 0; x < 5; x++)
            {
                if (BottomRenderer[x].sprite == null)
                {
                    yield return("sendtochaterror Pressing submit will only work when 5 letters have been sent!");

                    yield break;
                }
            }
            yield return("strike");

            yield return("solve");

            SubmitButton.OnInteract();
        }

        if (Regex.IsMatch(parameters[0], @"^\s*left\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length == 1)
            {
                Arrows[0].OnInteract();
            }

            else if (parameters.Length == 2)
            {
                int  temp  = 0;
                bool check = int.TryParse(parameters[1], out temp);
                if (!check)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is not a number!");

                    yield break;
                }

                if (temp < 1 || temp > 32)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is under 1 or over 32!");

                    yield break;
                }

                for (int i = 0; i < temp; i++)
                {
                    Arrows[0].OnInteract();
                    yield return(new WaitForSecondsRealtime(0.1f));
                }
            }

            else if (parameters.Length == 3)
            {
                int  temp  = 0;
                bool check = int.TryParse(parameters[1], out temp);
                if (!check)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is not a number!");

                    yield break;
                }

                if (temp < 1 || temp > 32)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is under 1 or over 32!");

                    yield break;
                }

                if (!Regex.IsMatch(parameters[2], @"^\s*slow\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    yield return("sendtochaterror A third parameter is only valid if it's 'slow'! Your parameter: '" + parameters[2] + "'.");

                    yield break;
                }

                for (int i = 0; i < temp; i++)
                {
                    Arrows[0].OnInteract();
                    yield return(new WaitForSecondsRealtime(1f));
                }
            }

            else if (parameters.Length > 3)
            {
                yield return("sendtochaterror Too many parameters!");
            }
        }

        if (Regex.IsMatch(parameters[0], @"^\s*right\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length == 1)
            {
                Arrows[1].OnInteract();
            }

            else if (parameters.Length == 2)
            {
                int  temp  = 0;
                bool check = int.TryParse(parameters[1], out temp);
                if (!check)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is not a number!");

                    yield break;
                }

                if (temp < 1 || temp > 32)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is under 1 or over 32!");

                    yield break;
                }

                for (int i = 0; i < temp; i++)
                {
                    Arrows[1].OnInteract();
                    yield return("trycancel Halted slow button presses due to a request to cancel!");

                    yield return(new WaitForSecondsRealtime(0.1f));
                }
            }

            else if (parameters.Length == 3)
            {
                int  temp  = 0;
                bool check = int.TryParse(parameters[1], out temp);
                if (!check)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is not a number!");

                    yield break;
                }

                if (temp < 1 || temp > 32)
                {
                    yield return("sendtochaterror The specified number of times to press the left button '" + parameters[1] + "' is under 1 or over 32!");

                    yield break;
                }

                if (!Regex.IsMatch(parameters[2], @"^\s*slow\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    yield return("sendtochaterror A third parameter is only valid if it's 'slow'! Your parameter: '" + parameters[2] + "'.");

                    yield break;
                }

                for (int i = 0; i < temp; i++)
                {
                    Arrows[1].OnInteract();
                    yield return("trycancel Halted slow button presses due to a request to cancel!");

                    yield return(new WaitForSecondsRealtime(1f));
                }
            }

            else if (parameters.Length > 3)
            {
                yield return("sendtochaterror Too many parameters!");
            }
        }
    }
예제 #16
0
#pragma warning restore IDE0044 // Add readonly modifier
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (!hasStarted)
        {
            yield return("sendtochaterror I'm not letting you interact with this module immediately. Wait for a bit until the module is ready.");

            yield break;
        }
        string commandLower = command.ToLower();

        if (commandLower.RegexMatch(@"^led\scycle\s\d+\s\d+$"))
        {
            if (isSubmitting)
            {
                yield return("sendtochaterror The module is in submission phase. Use \"!{1} led\" to reaccess the stages once specific conditions have been satsfied.");

                yield break;
            }
            string[] leftovers = commandLower.Split();
            int      leftValue;
            int      rightValue;
            if (int.TryParse(leftovers[leftovers.Length - 2], out leftValue) && int.TryParse(leftovers[leftovers.Length - 1], out rightValue))
            {
                if (leftValue <= rightValue)
                {
                    if (leftValue < 0 || leftValue >= displayedValues.Count || rightValue < 0 || rightValue >= displayedValues.Count)
                    {
                        yield return("sendtochaterror The cycle index for the following stage range " + leftValue + "," + rightValue + " do not contain all possible stages from the module.");

                        yield break;
                    }
                    int lastStage = curIdx;
                    yield return(null);

                    while (curIdx != leftValue)
                    {
                        yield return(new WaitForSeconds(0.1f));

                        LED.OnInteract();
                    }
                    for (int x = leftValue; x < rightValue + 1; x++)
                    {
                        yield return(new WaitForSeconds(TwitchShouldCancelCommand ? 0.1f : curCycleDelay));

                        LED.OnInteract();
                    }
                    while (curIdx != lastStage)
                    {
                        yield return(new WaitForSeconds(0.1f));

                        LED.OnInteract();
                    }
                }
                else
                {
                    yield return("sendtochaterror Your command is not valid for cycling. Do you mean \"!{1} led cycle " + rightValue + " " + leftValue + "\"?");

                    yield break;
                }
            }
            else
            {
                yield return("sendtochaterror The stage numbers given can't seem to work that well. Retry the command again with a different condition.");

                yield break;
            }
        }
        else if (commandLower.RegexMatch(@"^led(\s(cycle|\d))?$"))
        {
            string leftover = commandLower.Length > 4 ? commandLower.Substring(4) : "";
            if (isSubmitting && leftover.Length != 0)
            {
                yield return("sendtochaterror The module is in submission phase. Use \"!{1} led\" to reaccess the stages once specific conditions have been satsfied.");

                yield break;
            }
            switch (leftover)
            {
            case "cycle":
            {
                int lastStage = curIdx;
                yield return(null);

                while (curIdx != 0)
                {
                    yield return(new WaitForSeconds(0.1f));

                    LED.OnInteract();
                }
                for (int x = 0; x < displayedValues.Count; x++)
                {
                    yield return(new WaitForSeconds(TwitchShouldCancelCommand ? 0.1f : curCycleDelay));

                    LED.OnInteract();
                }
                while (curIdx != lastStage)
                {
                    yield return(new WaitForSeconds(0.1f));

                    LED.OnInteract();
                }
                break;
            }

            case "0":
            case "1":
            case "2":
            case "3":
            case "4":
            case "5":
            case "6":
            case "7":
            case "8":
            case "9":
            {
                string stagesAccessible = "0123456789".Substring(0, displayedValues.Count);
                int    specifiedStage   = stagesAccessible.IndexOf(leftover);
                if (specifiedStage == -1)
                {
                    yield return("sendtochaterror Sorry, but the specified stage \"" + leftover + "\" is not accessible.");

                    yield break;
                }
                else if (specifiedStage == curIdx)
                {
                    yield return("sendtochaterror Sorry, but the specified stage \"" + leftover + "\" is already being shown.");

                    yield break;
                }
                while (curIdx != specifiedStage)
                {
                    yield return(new WaitForSeconds(0.1f));

                    yield return(null);

                    LED.OnInteract();
                }
                break;
            }

            case "":
                yield return(null);

                LED.OnInteract();
                yield break;

            default:
                yield return("sendtochaterror You aren't supposed to get this error.");

                yield break;
            }
        }
        else if (commandLower.RegexMatch(@"^cycle\s?speed\s\d+$"))
        {
            yield return(null);

            string[] commandParts    = commandLower.Split();
            string   intereptedDigit = commandParts[commandParts.Length - 1];
            int      timePossible    = int.Parse(intereptedDigit);
            if (timePossible > 0 && timePossible < 10)
            {
                curCycleDelay = timePossible;
                yield return("sendtochat {0}, I have setted the cycle speed for 7 (Mod ID {1}) to " + intereptedDigit + " second(s).");
            }
            else
            {
                yield return("sendtochaterror {0}, I am not setting the cycle speed for 7 (Mod ID {1}) to " + intereptedDigit + " second(s).");
            }
        }
        else if (commandLower.RegexMatch(@"^colou?rblind$"))
        {
            yield return(null);

            colorblinddetected = !colorblinddetected;
            DisplayGivenValue(displayedValues[curIdx]);
        }
        else if (commandLower.RegexMatch(@"^segments$"))
        {
            for (int x = 0; x < segmentSelectables.Count(); x++)
            {
                yield return(new WaitForSeconds(0.1f));

                yield return(null);

                segmentSelectables[x].OnHighlight();
                yield return(new WaitForSeconds(TwitchShouldCancelCommand ? 0.1f : 3f));

                segmentSelectables[x].OnHighlightEnded();
            }
        }
        else if (commandLower.RegexMatch(@"^sub(mit)?$"))
        {
            yield return(null);

            stageDisplay.OnInteract();
            yield return("solve");
        }
        else
        {
            List <string> segmentString = new List <string>()
            {
                "1", "2", "3", "4", "5", "6", "7"
            };
            List <KMSelectable> pressables = new List <KMSelectable>();
            foreach (string commandPart in commandLower.Split())
            {
                int idxSegments = segmentString.IndexOf(commandPart);
                int idxColors   = colorList.ToLower().IndexOf(commandPart);
                if (commandPart.Length != 1 || (idxSegments == -1 && idxColors == -1))
                {
                    yield return("sendtochaterror Sorry, but what does \"" + commandPart + "\" represent again?");

                    yield break;
                }
                else if (idxColors != -1)
                {
                    pressables.Add(colorTriangleSelectables[idxColors]);
                }
                else if (idxSegments != -1)
                {
                    pressables.Add(segmentSelectables[idxSegments]);
                }
                else
                {
                    yield return("sendtochaterror Sorry but what is \"" + commandPart + "\" supposed to be?");

                    yield break;
                }
            }
            if (!isSubmitting)
            {
                yield return("sendtochaterror The module is not ready to submit yet. Use the \"submit\" command to make the module enter submission mode.");

                yield break;
            }
            yield return(null);

            yield return(pressables.ToArray());
        }
        yield break;
    }
#pragma warning restore 414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        command = command.ToLowerInvariant().Trim();
        switch (currentState)
        {
        case State.ReadyToStart:
            if (command.EqualsAny("start", "press start"))
            {
                yield return(null);

                startButton.OnInteract();
                yield break;
            }
            yield break;

        case State.Showing:
            if (command.EqualsAny("mii", "press mii"))
            {
                yield return(null);

                screen.OnInteract();
                yield break;
            }
            yield break;

        case State.Submitting:
            if (command.StartsWith("submit"))
            {
                var parsedCommand = command.Split(' ');
                if (parsedCommand.Length != 2)
                {
                    yield return("sendtochaterror Invalid number of parameters!");

                    yield break;
                }

                yield return(null);

                var nameToSubmit = parsedCommand[1];
                if (nameToSubmit.Any(x => !"abcdefghijklmnopqrstuvwxyz".Contains(x)))
                {
                    yield return("sendtochaterror There is an invalid character in the name!");

                    yield break;
                }
                backbutton.OnInteract();
                yield return(new WaitForSeconds(.1f));

                foreach (var letter in nameToSubmit)
                {
                    keyboard["abcdefghijklmnopqrstuvwxyz".IndexOf(letter)].OnInteract();
                    yield return(new WaitForSeconds(.1f));
                }
                enterbutton.OnInteract();
                yield break;
            }
            yield return("sendtochaterror Every command in this state must start with submit!");

            yield break;
        }
    }
예제 #18
0
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (Regex.IsMatch(command, @"^(?:colorblind)$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            colorblindMode = true;
            if (redLight == true)
            {
                ColorblindText.text = "RED";
            }

            else
            {
                ColorblindText.text = "BLUE";
            }
        }
        else if (Regex.IsMatch(command, @"^(?:reset|clear)$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            while (enteredText != "")
            {
                if (!InputMode)
                {
                    ViewButton.OnInteract();
                }
                DeleteKey.OnInteract();
                yield return(new WaitForSeconds(0.1f));
            }
            ViewButton.OnInteract();
        }
        else
        {
            Match m = Regex.Match(command, @"^(?:submit (.+))$", RegexOptions.IgnoreCase);
            if (m.Success)
            {
                command = m.Groups[1].ToString().Replace(" ", "");
                if (command.Length != 20)
                {
                    yield return("sendtochaterror The input length is invalid.");

                    yield break;
                }
                else
                {
                    char[] inputs = command.ToCharArray();
                    List <KMSelectable> keysToPress = new List <KMSelectable>();

                    foreach (char input in inputs)
                    {
                        if (!keysDict.ContainsKey(input.ToString()))
                        {
                            yield return(null);

                            yield return("sendtochaterror The input contains a key that is not pressable on the module.");

                            yield break;
                        }
                        keysToPress.Add(keysDict[input.ToString()]);
                    }
                    keysToPress.Add(SubmitButton);
                    if (!InputMode)
                    {
                        ViewButton.OnInteract();
                    }
                    while (enteredText != "")
                    {
                        yield return(null);

                        DeleteKey.OnInteract();
                        yield return(new WaitForSeconds(0.1f));
                    }
                    yield return(null);

                    yield return(keysToPress.ToArray());
                };
            }
            else
            {
                yield return("sendtochaterror Invalid command.");

                yield break;
            }
        }
    }
예제 #19
0
    #pragma warning restore 414

    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (!Playable)
        {
            yield return("sendtochaterror You can not interact with the module currently. The command was not processed.");

            yield break;
        }

        if (Regex.IsMatch(command, @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (ShowTime.text == "REWIND")
            {
                yield return("sendtochaterror You are currently on rewind. The command was not processed.");

                yield break;
            }
            yield return("solve");

            yield return("strike");

            Showtime.OnInteract();
            yield return(new WaitForSecondsRealtime(0.1f));

            Showtime.OnInteractEnded();
        }

        if (Regex.IsMatch(command, @"^\s*rewind\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (!Striked)
            {
                yield return("sendtochaterror You are unable to rewind currently. The command was not processed.");

                yield break;
            }

            if (ShowTime.text == "REWIND")
            {
                yield return("sendtochaterror You are currently on rewind. The command was not processed.");

                yield break;
            }
            Showtime.OnInteract();
            yield return(new WaitForSecondsRealtime(2.5f));

            Showtime.OnInteractEnded();
        }

        if (Regex.IsMatch(command, @"^\s*advance\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (ShowTime.text != "REWIND")
            {
                yield return("sendtochaterror You are currently not on rewind. The command was not processed.");

                yield break;
            }
            Showtime.OnInteract();
            yield return(new WaitForSecondsRealtime(0.1f));

            Showtime.OnInteractEnded();
        }

        if (Regex.IsMatch(parameters[0], @"^\s*tile\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length < 2)
            {
                yield return("sendtochaterror Parameter length invalid. The command was not processed.");

                yield break;
            }

            for (int x = 1; x < parameters.Length; x++)
            {
                yield return("trycancel The command to perform the action was cancelled due to a cancel request.");

                if (ShowTime.text == "REWIND")
                {
                    yield return("sendtochaterror You are currently on rewind. The command was halted.");

                    yield break;
                }

                int Ham;
                if (!Int32.TryParse(parameters[x], out Ham))
                {
                    yield return("sendtochaterror Tile position being sent contains is invalid. The command was halted.");

                    yield break;
                }

                if (Int32.Parse(parameters[x]) < 1 || Int32.Parse(parameters[x]) > 100)
                {
                    yield return("sendtochaterror Tile position being is not between [1-100]. The command was halted.");

                    yield break;
                }
                Lighting[Int32.Parse(parameters[x]) - 1].OnInteract();
                yield return(new WaitForSecondsRealtime(0.05f));
            }
        }
    }
예제 #20
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*cycle\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 1)
            {
                yield return(null);

                yield return(new WaitForSeconds(0.5f));

                cycleButton.OnInteract();
                for (int i = 0; i < 3; i++)
                {
                    yield return("trycancel Word cycling cancelled due to a cancel request.");

                    yield return(new WaitForSeconds(2f));

                    cycleButton.OnInteract();
                }
            }
            yield break;
        }
        if (Regex.IsMatch(parameters[0], @"^\s*set\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 6)
            {
                if (Regex.IsMatch(parameters[1], @"^\s*all\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    if (setsAlright(parameters[2], parameters[3], parameters[4], parameters[5]))
                    {
                        yield return(null);

                        while (!buttonTextMesh[0].text.Equals(parameters[2]))
                        {
                            yield return(new WaitForSeconds(0.1f)); numbersUp[0].OnInteract();
                        }
                        while (!buttonTextMesh[1].text.Equals(parameters[3]))
                        {
                            yield return(new WaitForSeconds(0.1f)); numbersUp[1].OnInteract();
                        }
                        while (!buttonTextMesh[2].text.Equals(parameters[4]))
                        {
                            yield return(new WaitForSeconds(0.1f)); numbersUp[2].OnInteract();
                        }
                        while (!buttonTextMesh[3].text.Equals(parameters[5]))
                        {
                            yield return(new WaitForSeconds(0.1f)); numbersUp[3].OnInteract();
                        }
                    }
                }
            }
            else if (parameters.Length == 3)
            {
                if (pressAlright(parameters[1], "1", "1", "1") && setsAlright(parameters[2], "0", "0", "0"))
                {
                    yield return(null);

                    int button = 0;
                    int.TryParse(parameters[1], out button);
                    button -= 1;
                    while (!buttonTextMesh[button].text.Equals(parameters[2]))
                    {
                        yield return(new WaitForSeconds(0.1f)); numbersUp[button].OnInteract();
                    }
                }
            }
            yield break;
        }
        if (Regex.IsMatch(parameters[0], @"^\s*press\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 5)
            {
                if (pressAlright(parameters[1], parameters[2], parameters[3], parameters[4]))
                {
                    yield return(null);

                    for (int i = 1; i < 5; i++)
                    {
                        if (parameters[i].Equals("1"))
                        {
                            mainButtons[0].OnInteract();
                        }
                        else if (parameters[i].Equals("2"))
                        {
                            mainButtons[1].OnInteract();
                        }
                        else if (parameters[i].Equals("3"))
                        {
                            mainButtons[2].OnInteract();
                        }
                        else if (parameters[i].Equals("4"))
                        {
                            mainButtons[3].OnInteract();
                        }
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
            }
            else if (parameters.Length == 4)
            {
                if (pressAlright(parameters[1], parameters[2], parameters[3], "1"))
                {
                    yield return(null);

                    for (int i = 1; i < 4; i++)
                    {
                        if (parameters[i].Equals("1"))
                        {
                            mainButtons[0].OnInteract();
                        }
                        else if (parameters[i].Equals("2"))
                        {
                            mainButtons[1].OnInteract();
                        }
                        else if (parameters[i].Equals("3"))
                        {
                            mainButtons[2].OnInteract();
                        }
                        else if (parameters[i].Equals("4"))
                        {
                            mainButtons[3].OnInteract();
                        }
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
            }
            else if (parameters.Length == 3)
            {
                if (pressAlright(parameters[1], parameters[2], "1", "1"))
                {
                    yield return(null);

                    for (int i = 1; i < 3; i++)
                    {
                        if (parameters[i].Equals("1"))
                        {
                            mainButtons[0].OnInteract();
                        }
                        else if (parameters[i].Equals("2"))
                        {
                            mainButtons[1].OnInteract();
                        }
                        else if (parameters[i].Equals("3"))
                        {
                            mainButtons[2].OnInteract();
                        }
                        else if (parameters[i].Equals("4"))
                        {
                            mainButtons[3].OnInteract();
                        }
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
            }
            else if (parameters.Length == 2)
            {
                if (pressAlright(parameters[1], "1", "1", "1"))
                {
                    yield return(null);

                    for (int i = 1; i < 2; i++)
                    {
                        if (parameters[i].Equals("1"))
                        {
                            mainButtons[0].OnInteract();
                        }
                        else if (parameters[i].Equals("2"))
                        {
                            mainButtons[1].OnInteract();
                        }
                        else if (parameters[i].Equals("3"))
                        {
                            mainButtons[2].OnInteract();
                        }
                        else if (parameters[i].Equals("4"))
                        {
                            mainButtons[3].OnInteract();
                        }
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
            }
            yield break;
        }
    }
예제 #21
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*press\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length > 3)
            {
                yield return("sendtochaterror Too many parameters!");
            }
            else if (parameters.Length == 3)
            {
                if (parameters[1].EqualsIgnoreCase("center"))
                {
                    int temp = 0;
                    if (int.TryParse(parameters[2], out temp))
                    {
                        if (temp < 1 || temp > 10)
                        {
                            yield return("sendtochaterror The specified number of times to press the center button '" + parameters[2] + "' is out of range 1-10!");

                            yield break;
                        }
                        for (int i = 0; i < temp; i++)
                        {
                            soundButton.OnInteract();
                            yield return(new WaitForSeconds(0.5f));
                        }
                    }
                    else
                    {
                        yield return("sendtochaterror The specified number of times to press the center button '" + parameters[2] + "' is invalid!");
                    }
                }
                else if (parameters[1].EqualsIgnoreCase("left") || parameters[1].EqualsIgnoreCase("right"))
                {
                    yield return("sendtochaterror Cannot press the '" + parameters[1] + "' button a certain number of times!");
                }
                else
                {
                    yield return("sendtochaterror Cannot press the '" + parameters[1] + "' button as it is invalid!");
                }
            }
            else if (parameters.Length == 2)
            {
                if (parameters[1].EqualsIgnoreCase("center"))
                {
                    soundButton.OnInteract();
                }
                else if (parameters[1].EqualsIgnoreCase("left"))
                {
                    buttons[0].OnInteract();
                }
                else if (parameters[1].EqualsIgnoreCase("right"))
                {
                    buttons[1].OnInteract();
                }
                else
                {
                    yield return("sendtochaterror Cannot press the '" + parameters[1] + "' button as it is invalid!");
                }
            }
            yield break;
        }
    }
예제 #22
0
#pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        command.ToLower();
        string[] parameters = command.Split(' ');
        if (parameters.Length < 2 && (parameters[0] != "submit" || parameters[0] != "Submit") && (parameters[0] != "display" || parameters[0] != "Display"))
        {
            yield return(null);

            yield return("sendtochaterror Please specify a correct command.");

            yield break;
        }
        else if (parameters.Length > 2)
        {
            yield return(null);

            yield return("sendtochaterror There are too many parameters.");

            yield break;
        }
        if (stage == 1 && (parameters[0] == "left" || parameters[0] == "l"))
        {
            yield return(null);

            for (int i = 0; i < int.Parse(parameters[1]); i++)
            {
                arrows[0].OnInteract();
                yield return(new WaitForSeconds(0.1f));
            }
        }
        else if (stage == 1 && (parameters[0] == "right" || parameters[0] == "r"))
        {
            yield return(null);

            for (int i = 0; i < int.Parse(parameters[1]); i++)
            {
                arrows[1].OnInteract();
                yield return(new WaitForSeconds(0.1f));
            }
        }
        else if (stage == 3 && (parameters[0] == "up" || parameters[0] == "u"))
        {
            yield return(null);

            for (int i = 0; i < int.Parse(parameters[1]); i++)
            {
                NumberButtons[0].OnInteract();
                yield return(new WaitForSeconds(0.1f));
            }
        }
        else if (stage == 1 && (parameters[0] == "down" || parameters[0] == "d"))
        {
            yield return(null);

            for (int i = 0; i < int.Parse(parameters[1]); i++)
            {
                NumberButtons[1].OnInteract();
                yield return(new WaitForSeconds(0.1f));
            }
        }
        else if (stage == 2 && (parameters[0] == "ball" || parameters[1] == "Ball"))
        {
            yield return(null);

            balls[int.Parse(parameters[1])].OnInteract();
        }
        else if (stage == 1 && (parameters[0] == "display" || parameters[0] == "Display"))
        {
            yield return(null);

            clubSelect.OnInteract();
        }
        else if (stage == 3 && (parameters[0] == "submit" || parameters[0] == "Submit"))
        {
            yield return(null);

            NumberSubmit.OnInteract();
        }
        else
        {
            yield return(null);

            yield return("sendtochaterror This command is invalid.");

            yield break;
        }
    }
    public IEnumerator ProcessTwitchCommand(string command)
    {
        if (Waiting)
        {
            yield return("sendtochaterror Cannot interact with the module while it is resetting.");

            yield break;
        }
        string tpcommand = command.ToUpper();

        if (tpcommand.StartsWith("PEN ") && tpcommand.Split(' ').Length == 3)
        {
            string[] TwitchCommands = tpcommand.Substring(4).Split(' ');
            int      Seconds        = -1;
            if (!int.TryParse(TwitchCommands[0], out Seconds) || TwitchCommands[0].Length != 2)
            {
                yield return("sendtochaterror The seconds digits '" + command.Split(' ')[1] + "' are invalid!");

                yield break;
            }
            if (Seconds < 0 || Seconds > 59)
            {
                yield return("sendtochaterror The seconds digits '" + command.Split(' ')[1] + "' are invalid!");

                yield break;
            }
            int Times = -1;
            if (!int.TryParse(TwitchCommands[1], out Times))
            {
                yield return("sendtochaterror The number of times '" + command.Split(' ')[2] + "' is invalid!");

                yield break;
            }
            if (Times < 1 || Times > 10)
            {
                yield return("sendtochaterror The number of times '" + command.Split(' ')[2] + "' is invalid!");

                yield break;
            }
            while (Mathf.FloorToInt(Info.GetTime()) % 60 != Seconds)
            {
                yield return("trycancel The pen wasn't pressed due to a request to cancel.");
            }
            for (int i = 0; i < Times; i++)
            {
                if (Mathf.FloorToInt(Info.GetTime()) % 60 != Seconds)
                {
                    yield return("sendtochat Halted pressing the pen due to a change in the seconds digits of the bomb timer. Successfully pressed the pen " + i + " times before halting.");

                    yield break;
                }
                Pen.OnInteract();
                yield return(new WaitForSeconds(0.1f));
            }
        }

        if (tpcommand.Equals("SUBMIT"))
        {
            yield return(null);

            Submit.OnInteract();
        }

        if (tpcommand.Equals("COLORBLIND") || tpcommand.Equals("COLOURBLIND"))
        {
            yield return(null);

            if (ColorBlindEnabled == true)
            {
                ColorBlindEnabled      = false;
                ColorblindText[0].text = "";
                ColorblindText[1].text = "";
            }
            else
            {
                ColorBlindEnabled = true;
                ColorblindOn();
            }
        }
    }
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            if (parameters.Length == 2)
            {
                if (timeIsValid(parameters[1]))
                {
                    yield return(null);

                    if (parameters[1].Length == 2)
                    {
                        parameters[1] = "00:" + parameters[1];
                    }
                    else if (parameters[1].Length == 4)
                    {
                        parameters[1] = "0" + parameters[1];
                    }
                    else if (parameters[1].Length == 7)
                    {
                        int temp  = 0;
                        int temp2 = 0;
                        int.TryParse(parameters[1].Substring(0, 1), out temp);
                        temp *= 60;
                        int.TryParse(parameters[1].Substring(2, 2), out temp2);
                        temp += temp2;
                        string tem = "";
                        if (temp < 10)
                        {
                            tem = "0" + temp;
                        }
                        else
                        {
                            tem = "" + temp;
                        }
                        tem          += parameters[1].Substring(4, 3);
                        parameters[1] = tem;
                    }

                    Debug.LogFormat("[Timing is Everything #{0}] {1}", moduleId, parameters[1]);
                    yield return("sendtochat Submit time set for '" + parameters[1] + "'");

                    while (true)
                    {
                        String time             = Bomb.GetFormattedTime();
                        int    millisecondindex = time.IndexOf('.');
                        if (millisecondindex != -1)
                        {
                            time = "00:" + time.Substring(0, millisecondindex);
                        }
                        if (!time.Equals(parameters[1]))
                        {
                            yield return("trycancel The submit button's press was cancelled due to a cancel request.");
                        }
                        else
                        {
                            break;
                        }
                    }
                    Button.OnInteract();
                    if (tpCorrect)
                    {
                        yield return("awardpoints 1");

                        tpCorrect = false;
                    }
                }
            }
            yield break;
        }
    }
예제 #25
0
    public IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*highlight\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) && parameters.Length == 1)
        {
            yield return(null);

            //This may not work in testharness. Halting the command in Unity Editor.
            if (Application.isEditor)
            {
                yield break;
            }

            //Using Reflections to have game display the highlight.
            MethodInfo highlightMethod = null;
            object     enumValue       = null;

            var highlights = Module.Children.Where(km => km != Button).Select(km => km.Highlight.GetComponent("Highlightable")).ToArray();

            if (highlights.Length == 0)
            {
                yield break;
            }

            if (highlightMethod == null)
            {
                var e = highlights[0].GetType().GetNestedType("HighlightTypeEnum", BindingFlags.Public);
                highlightMethod = highlights[0].GetType().GetMethod("On", BindingFlags.NonPublic | BindingFlags.Instance, null, new[] { typeof(bool), e }, null);
                enumValue       = Enum.ToObject(e, 1);
            }

            foreach (var o in highlights)
            {
                highlightMethod.Invoke(o, new[] { true, enumValue });
            }

            yield return(new WaitForSeconds(1f));

            foreach (var o in highlights)
            {
                highlightMethod.Invoke(o, new[] { false, enumValue });
            }
        }
        else if (Regex.IsMatch(parameters[0], @"^\s*switch\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) && parameters.Length == 1)
        {
            yield return(null);

            Button.OnInteract();
            yield return(new WaitForSeconds(0.1f));
        }
        else if (Regex.IsMatch(parameters[0], @"^\s*press\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            for (int i = 1; i < parameters.Length; i++)
            {
                if (Regex.IsMatch(parameters[i], @"^\s*[a-e][1-6]\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    parameters[i] = parameters[i].Trim();
                    parameters[i] = parameters[i].ToLowerInvariant();
                }
                else
                {
                    yield return("sendtochaterror Coordinates must be in the format [Alphabet][Digit] where Alphabet is English alphabet from A - E and Digit is a single number 1 - 6.");

                    yield break;
                }
            }
            var position = new int[parameters.Length - 1];

            for (int i = 1; i < parameters.Length; i++)
            {
                position[i - 1] = (parameters[i][0] - 'a') + (5 * (5 - (parameters[i][1] - '1')));
            }

            yield return(null);

            for (int i = 0; i < position.Length; i++)
            {
                if (Module.Children.Any(selectable => selectable == _squares[position[i]]))
                {
                    _squares[position[i]].OnInteract();
                    yield return(new WaitForSeconds(0.1f));
                }
            }
        }
        else
        {
            yield return("sendtochaterror The command must be started with \"switch\" or \"press\". \"switch\" must not be followed by any other letter or number.");

            yield break;
        }
        yield break;
    }
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*type\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Intro == true)
            {
                yield return("sendtochaterror The introduction music is still playing. Command was ignored");

                yield break;
            }

            if (ActiveBorder == true)
            {
                yield return("sendtochaterror The module is still showing the seed packet. Command was ignored");

                yield break;
            }

            if (Animating1 == true)
            {
                yield return("sendtochaterror The module is performing an animation. Command was ignored");

                yield break;
            }

            if (Enterable == false)
            {
                yield return("sendtochaterror The keys are not yet pressable. Command was ignored");

                yield break;
            }

            for (int x = 0; x < parameters.Length - 1; x++)
            {
                foreach (char c in parameters[x + 1])
                {
                    if (!c.ToString().EqualsAny(ChangedText[0]) && !c.ToString().EqualsAny(ChangedText[1]))
                    {
                        yield return("sendtochaterror The command being submitted contains a character that is not typable in the given keyboard");

                        yield break;
                    }
                }
            }

            for (int y = 0; y < parameters.Length - 1; y++)
            {
                yield return("trycancel The command to type the text given was halted due to a cancel request");

                foreach (char c in parameters[y + 1])
                {
                    yield return("trycancel The command to type the text given was halted due to a cancel request");

                    Current = TextBox.text;
                    if (!c.ToString().EqualsAny(ChangedText[StartingNumber]))
                    {
                        ShiftButtons[0].OnInteract();
                        yield return(new WaitForSeconds(0.05f));
                    }

                    for (int z = 0; z < ChangedText[StartingNumber].Count(); z++)
                    {
                        if (c.ToString() == ChangedText[StartingNumber][z])
                        {
                            TypableText[z].OnInteract();
                            yield return(new WaitForSeconds(0.05f));

                            break;
                        }
                    }

                    if (Current == TextBox.text)
                    {
                        yield return("sendtochaterror The command was stopped due to the text box not able to recieve more characters");

                        yield break;
                    }
                }

                if (y != parameters.Length - 2)
                {
                    SpaceBar.OnInteract();
                    yield return(new WaitForSeconds(0.05f));
                }

                if (Current == TextBox.text)
                {
                    yield return("sendtochaterror The command was stopped due to the text box not able to recieve more characters");

                    yield break;
                }
            }
        }

        else if (Regex.IsMatch(command, @"^\s*clear\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Intro == true)
            {
                yield return("sendtochaterror The introduction music is still playing. Command was ignored");

                yield break;
            }

            if (ActiveBorder == true)
            {
                yield return("sendtochaterror The module is still showing the seed packet. Command was ignored");

                yield break;
            }

            if (Animating1 == true)
            {
                yield return("sendtochaterror The module is performing an animation. Command was ignored");

                yield break;
            }

            if (Enterable == false)
            {
                yield return("sendtochaterror The key is not yet pressable. Command was ignored");

                yield break;
            }

            while (TextBox.text.Length != 0)
            {
                yield return("trycancel The command to clear text in the text box was halted due to a cancel request");

                Backspace.OnInteract();
                yield return(new WaitForSeconds(0.05f));
            }
        }

        else if (Regex.IsMatch(command, @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Intro == true)
            {
                yield return("sendtochaterror The introduction music is still playing. Command was ignored");

                yield break;
            }

            if (ActiveBorder == true)
            {
                yield return("sendtochaterror The module is still showing the seed packet. Command was ignored");

                yield break;
            }

            if (Animating1 == true)
            {
                yield return("sendtochaterror The module is performing an animation. Command was ignored");

                yield break;
            }

            if (Enterable == false)
            {
                yield return("sendtochaterror The key is not yet pressable. Command was ignored");

                yield break;
            }
            yield return("solve");

            yield return("strike");

            Enter.OnInteract();
        }

        else if (Regex.IsMatch(command, @"^\s*play\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Intro == true)
            {
                yield return("sendtochaterror The introduction music is still playing. Command was ignored.");

                yield break;
            }

            if (ActiveBorder == true)
            {
                yield return("sendtochaterror The module is still showing the seed packet. Command was ignored");

                yield break;
            }

            if (Animating1 == true)
            {
                yield return("sendtochaterror The module is performing an animation. Command was ignored");

                yield break;
            }

            if (Enterable == true)
            {
                yield return("sendtochaterror You are not able to press the border again. Command was ignored");

                yield break;
            }

            Border.OnInteract();
        }

        else if (Regex.IsMatch(command, @"^\s*playfocus\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Intro == true)
            {
                yield return("sendtochaterror The introduction music is still playing. Command was ignored");

                yield break;
            }

            if (ActiveBorder == true)
            {
                yield return("sendtochaterror The module is still showing the seed packet. Command was ignored");

                yield break;
            }

            if (Animating1 == true)
            {
                yield return("sendtochaterror The module is performing an animation. Command was ignored");

                yield break;
            }

            if (Enterable == true)
            {
                yield return("sendtochaterror You are not able to press the border again. Command was ignored");

                yield break;
            }

            Border.OnInteract();
            while (Playable == false)
            {
                yield return(new WaitForSeconds(0.02f));
            }
        }

        else if (Regex.IsMatch(command, @"^\s*fastclear\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (Intro == true)
            {
                yield return("sendtochaterror The introduction music is still playing. Command was ignored.");

                yield break;
            }

            if (ActiveBorder == true)
            {
                yield return("sendtochaterror The module is still showing the seed packet. Command was ignored");

                yield break;
            }

            if (Animating1 == true)
            {
                yield return("sendtochaterror The module is performing an animation. Command was ignored");

                yield break;
            }

            if (Enterable == false)
            {
                yield return("sendtochaterror The key is not yet pressable. Command was ignored");

                yield break;
            }

            while (TextBox.text.Length != 0)
            {
                Backspace.OnInteract();
            }
        }
    }
예제 #27
0
    IEnumerator ProcessTwitchCommand(string command)
    {
        var actions = new List <Func <object> >();

        foreach (var piece in Regex.Replace(command.ToLowerInvariant(), " +", " ").Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
        {
            switch (piece.Trim())
            {
            case "o":
            case "0":
            case "press o":
            case "press 0":
                actions.Add(() =>
                {
                    ButtonO.OnInteract();
                    return(.1f);
                });
                break;

            case "i":
            case "1":
            case "press i":
            case "press 1":
                actions.Add(() =>
                {
                    ButtonI.OnInteract();
                    return(.1f);
                });
                break;

            case "screw":
            case "screw in":
            case "screw it in":
            case "screwin":
            case "screwitin":
                actions.Add(() =>
                {
                    if (!_isBulbUnscrewed)
                    {
                        return(null);
                    }
                    Bulb.OnInteract();
                    if (_stage == 0)
                    {
                        return("solve");
                    }
                    return("");
                });
                break;

            case "unscrew":
                actions.Add(() =>
                {
                    if (_isBulbUnscrewed)
                    {
                        return(null);
                    }
                    Bulb.OnInteract();
                    return("");
                });
                break;

            default:
                yield break;
            }
        }

        foreach (var action in actions)
        {
            var result = action();
            if (result == null)
            {
                yield break;
            }
            else if (result is float)
            {
                yield return(new WaitForSeconds((float)result));
            }
            else if (result is string)
            {
                if (!result.Equals(""))
                {
                    yield return(result);
                }
                while (_isScrewing)
                {
                    yield return("trycancel");

                    yield return(new WaitForSeconds(.1f));
                }
            }
        }
    }
예제 #28
0
    public IEnumerator ProcessTwitchCommand(string command)
    {
        string[] split = command.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

        if (split.Length == 1)
        {
            if (split[0] == "clear")
            {
                yield return(null);

                Clear.OnInteract();
            }
            else if (EqualsAny(split[0], "items", "cycle"))
            {
                yield return(null);

                int initialPosition = DisplayPos;
                for (int i = 0; i < initialPosition; i++)
                {
                    MoveLeft.OnInteract();
                    yield return(new WaitForSeconds(0.05f));
                }

                for (int i = 0; i < 5; i++)
                {
                    yield return(new WaitForSeconds(1.5f));

                    MoveRight.OnInteract();
                }

                yield return(new WaitForSeconds(1.5f));

                for (int i = 0; i < (5 - initialPosition); i++)
                {
                    MoveLeft.OnInteract();
                    yield return(new WaitForSeconds(0.1f));
                }
            }
            else if (EqualsAny(split[0], "submit", "slap"))
            {
                yield return(null);

                Submit.OnInteract();
            }
        }
        else if (split.Length == 2)
        {
            if (split[0] == "submit")
            {
                decimal price;
                if (decimal.TryParse(split[1], out price) && decimal.Round(price, 2) == price && price < 200)
                {
                    yield return(null);

                    Clear.OnInteract();

                    foreach (GameObject button in Amounts.Reverse())
                    {
                        decimal amount = decimal.Parse("0" + GetTextMesh(button).text);
                        while (price >= amount)
                        {
                            button.GetComponent <KMSelectable>().OnInteract();
                            price -= amount;
                            yield return(new WaitForSeconds(0.1f));
                        }
                    }

                    if (Change == Paid - Total)
                    {
                        yield return("solve");
                    }
                    else
                    {
                        yield return("strike");
                    }

                    Submit.OnInteract();
                }
            }
            else if (EqualsAny(split[0], "set", "item"))
            {
                int position;
                if (int.TryParse(split[1], out position) && position >= 1 && position <= 6)
                {
                    int diff = DisplayPos - (position - 1);
                    for (int i = 0; i < Math.Abs(diff); i++)
                    {
                        (diff > 0 ? MoveLeft : MoveRight).OnInteract();
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
            }
        }
    }
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*hold\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (ButtonModel[0].enabled == false)
            {
                yield return("sendtochaterror The button is already being held!");

                yield break;
            }
            if (parameters.Length == 1)
            {
                Button.OnInteract();
            }
            else if (parameters.Length == 2)
            {
                if (timeIsShort(parameters[1]))
                {
                    int temp = 0;
                    int.TryParse(parameters[1], out temp);
                    yield return("sendtochat Holding the button at \"##:#" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 10) != temp)
                    {
                        yield return("trycancel Waiting to hold the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (timeIsNotAsShort(parameters[1]))
                {
                    int temp = 0;
                    int.TryParse(parameters[1], out temp);
                    yield return("sendtochat Holding the button at \"##:" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 60) != temp)
                    {
                        yield return("trycancel Waiting to hold the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (timeIsLonger(parameters[1]))
                {
                    int temp  = 0;
                    int temp2 = 0;
                    int.TryParse(parameters[1].Substring(0, 1), out temp);
                    int.TryParse(parameters[1].Substring(2), out temp2);
                    yield return("sendtochat Holding the button at \"#" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 600) != (temp2 + (temp * 60)))
                    {
                        yield return("trycancel Waiting to hold the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (timeIsLongest(parameters[1]))
                {
                    int temp  = 0;
                    int temp2 = 0;
                    int.TryParse(parameters[1].Substring(0, 2), out temp);
                    int.TryParse(parameters[1].Substring(3), out temp2);
                    yield return("sendtochat Holding the button at \"" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 3600) != (temp2 + (temp * 60)))
                    {
                        yield return("trycancel Waiting to hold the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else
                {
                    yield return("sendtochaterror The specified time to hold the button at \"" + parameters[1] + "\" is invalid!");

                    yield break;
                }
                Button.OnInteract();
            }
            else
            {
                yield return("sendtochaterror Too many parameters!");
            }
            yield break;
        }
        if (Regex.IsMatch(parameters[0], @"^\s*release\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (ButtonModel[0].enabled == true)
            {
                yield return("sendtochaterror The button is not being held!");

                yield break;
            }
            if (parameters.Length == 1)
            {
                Button.OnInteractEnded();
            }
            else if (parameters.Length == 2)
            {
                if (timeIsShort(parameters[1]))
                {
                    int temp = 0;
                    int.TryParse(parameters[1], out temp);
                    yield return("sendtochat Releasing the button at \"##:#" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 10) != temp)
                    {
                        yield return("trycancel Waiting to release the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (timeIsNotAsShort(parameters[1]))
                {
                    int temp = 0;
                    int.TryParse(parameters[1], out temp);
                    yield return("sendtochat Releasing the button at \"##:" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 60) != temp)
                    {
                        yield return("trycancel Waiting to release the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (timeIsLonger(parameters[1]))
                {
                    int temp  = 0;
                    int temp2 = 0;
                    int.TryParse(parameters[1].Substring(0, 1), out temp);
                    int.TryParse(parameters[1].Substring(2), out temp2);
                    yield return("sendtochat Releasing the button at \"#" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 600) != (temp2 + (temp * 60)))
                    {
                        yield return("trycancel Waiting to release the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (timeIsLongest(parameters[1]))
                {
                    int temp  = 0;
                    int temp2 = 0;
                    int.TryParse(parameters[1].Substring(0, 2), out temp);
                    int.TryParse(parameters[1].Substring(3), out temp2);
                    yield return("sendtochat Releasing the button at \"" + parameters[1] + "\"!");

                    while (((int)Bomb.GetTime() % 3600) != (temp2 + (temp * 60)))
                    {
                        yield return("trycancel Waiting to release the button has been halted due to a request to cancel!");

                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else
                {
                    yield return("sendtochaterror The specified time to release the button at \"" + parameters[1] + "\" is invalid!");

                    yield break;
                }
                Button.OnInteractEnded();
            }
            else
            {
                yield return("sendtochaterror Too many parameters!");
            }
            yield break;
        }
    }
예제 #30
0
#pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        Match m;

        if (moduleSolved)
        {
            yield return("sendtochaterror The module is already solved.");

            yield break;
        }
        else if ((m = Regex.Match(command, @"^\s*([ABCDEF123456 ]+)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            yield return(null);

            var cell = m.Groups[0].Value.Split(' ');
            for (int i = 0; i < cell.Length; i++)
            {
                if (Regex.IsMatch(cell[i], @"^\s*[ABCDEF][123456]\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    continue;
                }
                else
                {
                    yield return("sendtochaterror Incorrect syntax.");

                    yield break;
                }
            }
            for (int i = 0; i < cell.Length; i++)
            {
                var row = int.Parse(cell[i].Substring(1, 1));
                var col = cell[i].ToUpperInvariant()[0] - 'A' + 1;
                Grid[6 * row - 1 + col - 6].OnInteract();
                yield return(new WaitForSeconds(.05f));
            }
            yield break;
        }
        else if ((m = Regex.Match(command, @"^\s*set\s*([ABCDEF123456 ]+)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)).Success)
        {
            yield return(null);

            var cell = m.Groups[1].Value.Split(' ').ToArray();
            for (int i = 0; i < cell.Length; i++)
            {
                if (Regex.IsMatch(cell[i], @"^\s*[ABCDEF][123456]\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
                {
                    continue;
                }
                else
                {
                    yield return("sendtochaterror Incorrect syntax.");

                    yield break;
                }
            }
            for (int i = 0; i < cell.Length; i++)
            {
                var row = int.Parse(cell[i].Substring(1, 1));
                var col = cell[i].ToUpperInvariant()[0] - 'A' + 1;
                if (Cells[6 * row - 1 + col - 6].O)
                {
                    continue;
                }
                else if (Cells[(6 * row - 1 + col) - 6].X)
                {
                    Grid[6 * row + col - 6].OnInteract();
                }
                else
                {
                    Grid[6 * row - 1 + col - 6].OnInteract();
                    yield return(new WaitForSeconds(.05f));

                    Grid[6 * row - 1 + col - 6].OnInteract();
                }
                yield return(new WaitForSeconds(.05f));
            }
            yield break;
        }
        else if (Regex.IsMatch(command, @"^\s*reset\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            Reset.OnInteract();
            yield break;
        }
        else
        {
            yield return("sendtochaterror Invalid Command");

            yield break;
        }
    }