Exemple #1
0
    IEnumerator ProcessTwitchCommand(string command)
    {
        command = command.ToLowerInvariant().Trim();
        Regex rx = new Regex(@"^hold\s+\d+$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

        if (!rx.IsMatch(command))
        {
            yield break;
        }
        Regex rxd       = new Regex(@"\d+", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
        int   userInput = int.Parse(rxd.Match(command).Value);

        Button.OnInteract();
        var time = (int)Info.GetTime();

        while (time - userInput != (int)Info.GetTime() && time + userInput != (int)Info.GetTime())
        {
            if (TwitchShouldCancelCommand)
            {
                Button.OnInteractEnded();
                yield return("cancelled");
            }
            yield return(new WaitForSeconds(0.1f));
        }
        Button.OnInteractEnded();
        yield return(null);
    }
        #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        Match m;

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

            var input = m.Groups[1].Value;
            for (int i = 0; i < m.Length; i++)
            {
                switch (m.Groups[1].Value[i])
                {
                case '[': Button.OnInteract(); break;

                case ']': Button.OnInteractEnded(); break;

                case 'p': yield return(new WaitForSeconds(1.05f)); break;

                case ' ': break;

                default: break;
                }
            }
        }
        else
        {
            yield return("sendtochaterror Incorrect Syntax. Must use characters [, ], and p.");

            yield break;
        }
    }
    public IEnumerator ProcessTwitchCommand(string command)
    {
        string[] chainedCommands = command.Split(new[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries);
        if (chainedCommands.Length > 1)
        {
            var commandRoutines = chainedCommands.Select(ProcessTwitchCommand).ToArray();
            var invalidCommand  = Array.Find(commandRoutines, routine => !routine.MoveNext());
            if (invalidCommand != null)
            {
                yield return("sendtochaterror The command \"" + chainedCommands[Array.IndexOf(commandRoutines, invalidCommand)] + "\" is invalid.");

                yield break;
            }

            yield return(null);

            foreach (IEnumerator routine in commandRoutines)
            {
                yield return(routine);

                yield return("trycancel The chained command was not continued due to a request to cancel.");
            }

            yield break;
        }

        string[] split = command.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (split.Length == 2)
        {
            int   tapDigit;
            float holdTime;
            if ((split[0] == "tap" || split[0] == "t") && int.TryParse(split[1], out tapDigit))
            {
                yield return(null);

                while (Mathf.FloorToInt(Bomb.GetTime()) % 10 != tapDigit)
                {
                    yield return("trycancel The sphere was not tapped due to a request to cancel.");
                }

                sphere.OnInteract();
                sphere.OnInteractEnded();
                yield return(new WaitForSeconds(0.1f));
            }
            else if ((split[0] == "hold" || split[0] == "h") && float.TryParse(split[1], out holdTime))
            {
                yield return(null);

                sphere.OnInteract();
                while (Mathf.RoundToInt(Mathf.Abs(timeOfPress - Bomb.GetTime()) % 60) != holdTime)
                {
                    yield return(true);                    // Return true which will get returned by the force solve.
                }
                sphere.OnInteractEnded();
                yield return(new WaitForSeconds(0.1f));
            }
        }
    }
Exemple #4
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (Regex.IsMatch(parameters[0], @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length > 2)
            {
                yield return("sendtochaterror Too many parameters!");
            }
            else if (parameters.Length == 2)
            {
                int index = -1;
                for (int i = 0; i < displayWords.Length; i++)
                {
                    if (displayWords[i].EqualsIgnoreCase(parameters[1]))
                    {
                        index = i;
                    }
                }
                if (index == -1)
                {
                    yield return("sendtochaterror The specified word '" + parameters[1] + "' is not an option!");

                    yield break;
                }
                if (correctWord.EqualsIgnoreCase(parameters[1]))
                {
                    yield return("solve");
                }
                else
                {
                    yield return("strike");
                }
                speed = true;
                StartCoroutine(cancelSpeed());
                if (cycle == null)
                {
                    button.OnInteract();
                }
                while (!parameters[1].EqualsIgnoreCase(screenTexts[1].text))
                {
                    yield return("trycancel Word submission halted due to a request to cancel!");

                    yield return(new WaitForSeconds(0.1f));
                }
                speed = false;
                button.OnInteractEnded();
            }
            else
            {
                yield return("sendtochaterror Please include a word to submit!");
            }
            yield break;
        }
    }
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (Regex.IsMatch(command, @"^\s*hold\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) || Regex.IsMatch(command, @"^\s*h\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            center.OnInteract();
            yield return(new WaitForSeconds(1f));

            center.OnInteractEnded();
            yield break;
        }

        string[] valids = { "u", "l", "d", "r", "c", "f", "useless", "b" };
        command = command.Replace(" ", "");
        command = command.ToLower();
        for (int i = 0; i < command.Length; i++)
        {
            if (!valids.Contains(command.ElementAt(i) + ""))
            {
                yield return("sendtochaterror The specified position '" + command.ElementAt(i) + "' for a button is not valid!");

                yield break;
            }
        }
        for (int i = 0; i < command.Length; i++)
        {
            if (command.ElementAt(i) == 'c')
            {
                yield return(null);

                yield return("trycancel The command is cancelled during move #" + (i + 1) + ".");

                if (command.Length > 1)
                {
                    yield return("strikemessage input #" + (i + 1));
                }
                center.OnInteract();
                center.OnInteractEnded();
                yield return(new WaitForSeconds(0.2f));
            }
            else
            {
                yield return(null);

                yield return("trycancel The command is cancelled during move #" + (i + 1) + ".");

                if (command.Length > 1)
                {
                    yield return("strikemessage input #" + (i + 1));
                }
                moves[Array.IndexOf(valids, command.ElementAt(i) + "") % 5].OnInteract();
                yield return(new WaitForSeconds(0.2f));
            }
        }
        yield break;
    }
#pragma warning restore 414
    private IEnumerator ProcessTwitchCommand(string command)
    {
        command = command.ToLowerInvariant().Trim();
        if (command == "reset")
        {
            yield return(null);

            PacManButton.OnInteract();
            yield return(new WaitForSeconds(.7f));

            PacManButton.OnInteractEnded();
            yield break;
        }

        if (command.StartsWith("submit"))
        {
            var parsedCommand = command.Split(' ');
            if (parsedCommand.Length != 5)
            {
                yield return("sendtochaterror Invalid length of command!");

                yield break;
            }

            var instructions = parsedCommand.TakeLast(4).ToArray();
            if (!instructions.All(x => new[] { "u", "d", "l", "r" }.Contains(x)))
            {
                yield return("sendtochaterror There is an invalid character in the command, you can only use U,D,L,R!");

                yield break;
            }

            var selectables = new List <KMSelectable>();
            for (var i = 0; i < 4; ++i)
            {
                var instructionIndex = Array.IndexOf(new[] { "u", "l", "d", "r" }, instructions[i]);
                if (GetCurrentDir(i) == instructionIndex)
                {
                    continue;
                }
                selectables.AddRange(Enumerable.Repeat(GhostButtons[i], Mod(instructionIndex - GetCurrentDir(i))));
            }

            yield return(null);

            foreach (var selectable in selectables)
            {
                selectable.OnInteract();
                yield return(new WaitForSeconds(.1f));
            }
            PacManButton.OnInteract();
            yield return(new WaitForSeconds(.01f));

            PacManButton.OnInteractEnded();
        }
    }
Exemple #7
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (Regex.IsMatch(command, @"^\s*push\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            Button.OnInteract();
            yield return(new WaitForSeconds(0.1f));

            Button.OnInteractEnded();
            yield break;
        }
    }
Exemple #8
0
#pragma warning restore 414

    IEnumerator ProcessTwitchCommand(string command)
    {
        string validcmdsinitial        = "0123456789";
        string validcmdsstage1andafter = "12345";

        if (command.Length != 1)
        {
            yield return("sendtochaterror Invalid command.");

            yield break;
        }
        if (Stage == 0)
        {
            if (!validcmdsinitial.Contains(command))
            {
                yield return("sendtochaterror Invalid command.");

                yield break;
            }
            while (command != (((int)Bomb.GetTime() % 60) % 10).ToString())
            {
                yield return("trycancel Button press cancelled (Tell Me Why).");
            }
            yield return(null);

            Button.OnInteract();
        }
        else
        {
            if (!validcmdsstage1andafter.Contains(command))
            {
                yield return("sendtochaterror Invalid command.");

                yield break;
            }
            while (command != (CurrentNum + 1).ToString())
            {
                yield return("trycancel Button press cancelled (Tell Me Why).");
            }
            yield return(null);

            if (Stage % 2 == 0)
            {
                Button.OnInteract();
            }
            else
            {
                Button.OnInteractEnded();
            }
        }
    }
 private void FixedUpdate()
 {
     if (isSolved)
     {
         colorCycle();
     }
     else if (holdWait == -1 && releaseWait == -1 && tpActive)
     {
     }
     else if (isHeld)
     {
         colorCycle();
         if (Math.Floor(Bomb.GetTime()) % 10 == releaseWait)
         {
             button.OnInteractEnded();
             holdWait    = -1;
             releaseWait = -1;
         }
     }
     else
     {
         if (Math.Floor(Bomb.GetTime()) % 10 == holdWait)
         {
             button.OnInteract();
             holdWait = -1;
         }
     }
 }
Exemple #10
0
    // Handle Twitch Plays
    IEnumerator HandleForcedSolve()
    {
        disarmButton.OnInteract();
        yield return(new WaitForSeconds(0.2f));

        disarmButton.OnInteractEnded();
    }
Exemple #11
0
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split();
        if (Regex.IsMatch(parameters[0], @"^\s*release\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (parameters.Length != 2)
            {
                yield return("sendtochaterror Invalid parameter length. Command was ignored");

                yield break;
            }

            if (!parameters[1].EqualsAny(ValidPercentage))
            {
                yield return("sendtochaterror Percentage being submitted is not valid. Command was ignored");

                yield break;
            }
            Component.OnInteract();
            while (PercentLevel.text != parameters[1])
            {
                yield return(null);
            }
            Component.OnInteractEnded();
        }
    }
 protected void DoInteractionEnd(KMSelectable interactable)
 {
     if (interactable.OnInteractEnded != null)
     {
         interactable.OnInteractEnded();
     }
 }
 public void InteractEnded()
 {
     if (ModSelectable.OnInteractEnded != null)
     {
         ModSelectable.OnInteractEnded();
     }
 }
 public IEnumerator Interact(KMSelectable selectable, float holdTime = 0)
 {
     selectable.OnInteract();
     if (holdTime > 0)
     {
         yield return(new WaitForSeconds(holdTime));
     }
     if (selectable.OnInteractEnded != null)
     {
         selectable.OnInteractEnded();
     }
     yield return(new WaitForSeconds(0.1f));
 }
#pragma warning restore 0414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        if (command.Trim().ToLowerInvariant() == "reset")
        {
            yield return(null);

            CentralSelectable.OnInteract();
            yield return(new WaitForSeconds(.6f));

            CentralSelectable.OnInteractEnded();
        }

        var keys  = new List <KMSelectable>();
        var match = Regex.Match(command.Trim().ToUpperInvariant(),
                                "^(?:press |play |submit |sing |)((?:(?:left|right|l|r)[ ,;]?(?:C#?|D[b#]?|Eb?|F#?|G[b#]?|A[b#]?|Bb?)[ ,;]*)+)$",
                                RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

        if (!match.Success)
        {
            yield break;
        }

        var pieces = match.Groups[1].Value.Trim()
                     .Replace("DB", "C#").Replace("EB", "D#").Replace("GB", "F#").Replace("AB", "G#").Replace("BB", "A#")
                     .Split(new[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries);
        var left = false;

        foreach (var piece in pieces)
        {
            left |= piece.StartsWith("L");
            left &= !piece.StartsWith("R");

            for (var j = 0; j < _tpKeyNames.Length; j++)
            {
                if (piece.EndsWith(_tpKeyNames[j]))
                {
                    keys.Add(Keys[j + (left ? 0 : 12)]);
                }
            }
        }

        yield return(null);

        foreach (var key in keys)
        {
            key.OnInteract();
            yield return(new WaitForSeconds(.4f));
        }
    }
    // Handle Twitch Plays
    IEnumerator TwitchHandleForcedSolve()
    {
        Debug.LogFormat("[Sync Solve Tester #{0}]: A force solve has been issued viva TP Handler.", curmodID);
        while (!hasActivated)
        {
            yield return(true);
        }
        while (!hasDisarmed)
        {
            disarmButton.OnInteract();
            yield return(new WaitForSeconds(0.2f));

            disarmButton.OnInteractEnded();
        }
    }
Exemple #17
0
    // Handle Twitch Plays
    IEnumerator HandleForcedSolve()
    {
        while (frameSwitch < animLength)
        {
            if (hasDisarmed)
            {
                yield break;
            }
            yield return(new WaitForSeconds(0));
        }
        disarmButton.OnInteract();
        yield return(new WaitForSeconds(0.2f));

        disarmButton.OnInteractEnded();
    }
 IEnumerator HoldButton(IEnumerator coroutine, bool hold)
 {
     while (coroutine.MoveNext())
     {
         var obj = coroutine.Current;
         if (obj is KMSelectable && hold)
         {
             button.OnInteract();
         }
         else if (obj is KMSelectable)
         {
             button.OnInteractEnded();
         }
         yield return(obj);
     }
 }
Exemple #19
0
#pragma warning restore 414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        var m = Regex.Match(command, "^(?:(?<L>listen|play)|(?:tap |submit |press |)(?<D>([1-5][ ,;]*){10}))$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

        if (!m.Success)
        {
            yield break;
        }
        yield return(null);

        if (m.Groups["L"].Success)
        {
            Sel.OnInteract();
            yield return(new WaitForSeconds(0.7f));

            Sel.OnInteractEnded();
            yield return(new WaitForSeconds(0.1f));

            yield break;
        }

        foreach (char tap in m.Groups["D"].Value)
        {
            yield return("trycancel");

            int taps;
            if (!int.TryParse(tap.ToString(), out taps))
            {
                continue;
            }
            for (int i = 0; i < taps; i++)
            {
                Sel.OnInteract();
                yield return(new WaitForSeconds(0.05f));

                Sel.OnInteractEnded();
                yield return(new WaitForSeconds(0.05f));

                yield return("trycancel");
            }
            while (_tapCodeActive)
            {
                yield return("trycancel");
            }
            yield return(new WaitForSeconds(0.1f));
        }
        yield return(new WaitForSeconds(0.05f));

        Sel.OnInteract();
        yield return(new WaitForSeconds(0.05f));

        Sel.OnInteractEnded();
        yield return(new WaitForSeconds(0.05f));
    }
 private IEnumerator Solver()
 {
     foreach (int i in Morsify(Answer))
     {
         ButtonTransmit.OnInteract();
         if (i == 1)
         {
             yield return(new WaitForSeconds(0.6f));
         }
         else
         {
             yield return(new WaitForSeconds(0.2f));
         }
         ButtonTransmit.OnInteractEnded();
         yield return(new WaitForSeconds(0.2f));
     }
 }
Exemple #21
0
    #pragma warning restore 0414

    public IEnumerator TwitchHandleForcedSolve()
    {
        if (!isHeld)
        {
            module.OnInteract();
            yield return(new WaitForSeconds(0.1f));
        }
        while (!releaseTimes.Contains((int)info.GetTime() % 10))
        {
            yield return(true);
        }
        module.OnInteractEnded();

        /**isHeld = false;
         * int sprite = UnityEngine.Random.Range(0, 14);
         * sprite += (sprite < deathSprite) ? 0 : 1;
         * moduleSprite.sprite = itemSprites[sprite];
         * Debug.LogFormat("[Question Mark #{0}] Module forcibly solved.", _moduleId);
         * GetComponent<KMBombModule>().HandlePass();*/
    }
    // Handle Twitch Plays
    IEnumerator TwitchHandleForcedSolve()
    {
        Debug.LogFormat("[Singularity Button #{0}]: A force solve has been issued viva TP Handler. ALL Singularity Buttons will be set to a solve state because of it.", curmodID);
        if (!isSolved)
        {
            singularityButtonInfo.DisarmAll();             // Call the protected method, if the module is not solved yet.
        }
        while (frameSwitch < animLength)
        {
            if (hasDisarmed)
            {
                yield return(true);
            }
            yield return(true);
        }
        disarmButton.OnInteract();
        yield return(new WaitForSeconds(0.2f));

        disarmButton.OnInteractEnded();
        textDisarm.text = "FORCE\nSOLVED";
        yield return(true);
    }
Exemple #23
0
  #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string ohgodno)
    {
        ohgodno = ohgodno.ToUpperInvariant().Trim();
        Match meth = Regex.Match(ohgodno, @"^(?:MOVE ([UDRL]+)|CIRCLE)$");

        if (meth.Groups[1].Success)
        {
            char[] crabcrab             = meth.Groups[1].Value.ToCharArray();
            Dictionary <char, int> help = new Dictionary <char, int>()
            {
                { 'R', 0 },
                { 'L', 1 },
                { 'U', 2 },
                { 'D', 3 }
            };
            yield return(null);

            for (int i = 0; i < crabcrab.Length; i++)
            {
                Buttons[help[crabcrab[i]]].OnInteract();
                yield return(new WaitForSeconds(.1f));
            }
        }
        else if (meth.Success)
        {
            yield return(null);

            Submit.OnInteract();
            yield return(new WaitForSeconds(.1f));

            Submit.OnInteractEnded();
        }
        else
        {
            yield return("sendtochaterror Valid commands are move and circle. Use !{1} help to see the full commands.");
        }
        yield break;
    }
#pragma warning restore 0414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        var match = Regex.Match(command, @"^\s*(?:press |submit |send |transmit |tx |)([kbgcrmyw1-8 ,;]+)\s*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);

        if (match.Success)
        {
            yield return(null);

            foreach (var btn in match.Groups[1].Value.Where(ch => "kbgcrmywKBGCRMYW12345678".Contains(ch)).Select(ch => Buttons["kbgcrmywKBGCRMYW12345678".IndexOf(ch) % 8]))
            {
                btn.OnInteract();
                yield return(new WaitForSeconds(.4f));
            }
            yield break;
        }

        match = Regex.Match(command, @"^\s*(?:set ?)?(?:speed |rate |frequency )(\d*\.?\d+)\s*$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
        if (match.Success)
        {
            double target;
            if (!double.TryParse(match.Groups[1].Value, out target) || target < 0 || target > 1)
            {
                yield return("sendtochaterror The speed must be between 0 and 1 (for example, 0.1 or 0.75).");

                yield break;
            }
            yield return(null);

            var started = Time.time;
            Knob.OnInteract();
            while (Math.Abs(_knobPosition - target) > .025 && Time.time - started < 2)
            {
                yield return(null);
            }
            Knob.OnInteractEnded();
            yield break;
        }
    }
#pragma warning restore 0414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        Match m;

        m = Regex.Match(command, @"^\s*(?:set)\s+([\.#]{36})\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
        if (m.Success)
        {
            if (!_submissionPhase)
            {
                yield return("sendtochaterror You are not in submission phase. You may not press any cells.");

                yield break;
            }
            yield return(null);

            var arr = m.Groups[1].Value.Select(i => i == '#' ? true : false).ToArray();
            for (int i = 0; i < 36; i++)
            {
                if (_inputSquares[i] != arr[i])
                {
                    SquareSels[i].OnInteract();
                    yield return(new WaitForSeconds(0.05f));
                }
            }
            yield break;
        }
        m = Regex.Match(command, @"^\s*submit\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
        if (m.Success)
        {
            if (_stageRecovery)
            {
                yield return("sendtochaterror You are currently in stage recovery!");

                yield break;
            }
            if (_currentStage != _stageCount)
            {
                yield return("sendtochaterror Not all stages have been shown yet?");

                yield break;
            }
            yield return(null);

            yield return("strike");

            yield return("solve");

            ShowTimeSel.OnInteract();
            yield return(new WaitForSeconds(0.1f));

            ShowTimeSel.OnInteractEnded();
            yield return(new WaitForSeconds(0.1f));
        }
        m = Regex.Match(command, @"^\s*rewind\s*", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
        if (m.Success)
        {
            if (!_hasStruck)
            {
                yield return("sendtochaterror You have not struck yet, and cannot rewind to enter stage recovery!");

                yield break;
            }
            if (_stageRecovery)
            {
                yield return("sendtochaterror You are already in stage recovery!");

                yield break;
            }
            yield return(null);

            ShowTimeSel.OnInteract();
            yield return(new WaitForSeconds(2.5f));

            ShowTimeSel.OnInteractEnded();
            yield return(new WaitForSeconds(0.1f));

            yield break;
        }
        m = Regex.Match(command, @"^\s*advance\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
        if (m.Success)
        {
            if (!_stageRecovery)
            {
                yield return("sendtochaterror You are not in stage recovery! You may not advance.");

                yield break;
            }
            yield return(null);

            yield return("strike");

            yield return("solve");

            ShowTimeSel.OnInteract();
            yield return(new WaitForSeconds(0.1f));

            ShowTimeSel.OnInteractEnded();
            yield return(new WaitForSeconds(0.1f));
        }
        m = Regex.Match(command, @"^\s*skip\s*", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
        if (m.Success)
        {
            if (!_stageRecovery)
            {
                yield return("sendtochaterror You are not in stage recovery! You may not skip to input.");

                yield break;
            }
            while (_currentStage != _stageCount && !_pseudoSubmissionPhase)
            {
                ShowTimeSel.OnInteract();
                yield return(new WaitForSeconds(0.05f));

                ShowTimeSel.OnInteractEnded();
                yield return(new WaitForSeconds(0.05f));
            }
        }
        yield break;
    }
Exemple #26
0
    #pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        string[] parameters = command.Split(' ');
        if (parameters.Length == 2)
        {
            if (Regex.IsMatch(parameters[0], @"^\s*listen\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) && Regex.IsMatch(parameters[1], @"^\s*slow\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
            {
                yield return(null);

                StopCoroutine(seqFlash);
                DisableLights();
                seqFlash = StartCoroutine(SeqFlashSlow());
                LstnBtn.OnInteract();
                yield return(new WaitForSeconds(3.0f));

                LstnBtn.OnInteractEnded();
                StopCoroutine(seqFlash);
                seqFlash = StartCoroutine(SeqFlash());
                yield break;
            }
            if (Regex.IsMatch(parameters[0], @"^\s*instrument\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) && (Regex.IsMatch(parameters[1], @"^\s*xylo\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) || Regex.IsMatch(parameters[1], @"^\s*piano\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) || Regex.IsMatch(parameters[1], @"^\s*music\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) || Regex.IsMatch(parameters[1], @"^\s*harp\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)))
            {
                yield return(null);

                int rando = Random.Range(0, 2);
                if (parameters[1].EqualsIgnoreCase("music"))
                {
                    while (currentModuleInstrument != 0)
                    {
                        InsCycBtns[rando].OnInteract();
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (parameters[1].EqualsIgnoreCase("piano"))
                {
                    while (currentModuleInstrument != 1)
                    {
                        InsCycBtns[rando].OnInteract();
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else if (parameters[1].EqualsIgnoreCase("xylo"))
                {
                    while (currentModuleInstrument != 2)
                    {
                        InsCycBtns[rando].OnInteract();
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                else
                {
                    while (currentModuleInstrument != 3)
                    {
                        InsCycBtns[rando].OnInteract();
                        yield return(new WaitForSeconds(0.1f));
                    }
                }
                yield break;
            }
            if (Regex.IsMatch(parameters[0], @"^\s*sound\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
            {
                if (inputIsValid(parameters[1]))
                {
                    yield return(null);

                    string[] nums = parameters[1].Split(',', ';');
                    foreach (string num in nums)
                    {
                        int temp = 0;
                        int.TryParse(num, out temp);
                        if (temp == 1)
                        {
                            SeqBtns[0].OnInteract();
                        }
                        else if (temp == 2)
                        {
                            SeqBtns[1].OnInteract();
                        }
                        else if (temp == 3)
                        {
                            SeqBtns[2].OnInteract();
                        }
                        else
                        {
                            SeqBtns[3].OnInteract();
                        }
                        yield return(new WaitForSeconds(0.2f));
                    }
                }
                yield break;
            }
        }
        if (Regex.IsMatch(command, @"^\s*listen\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            StopCoroutine(seqFlash);
            DisableLights();
            seqFlash = StartCoroutine(SeqFlash());
            LstnBtn.OnInteract();
            yield return(new WaitForSeconds(2.0f));

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

            correctNotes = 0;
            DisableLights();
            yield break;
        }
    }
Exemple #27
0
#pragma warning restore 414
    IEnumerator ProcessTwitchCommand(string command)
    {
        if (moduleSolved)
        {
            yield return("sendtochaterror The module is already solved.");

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

            if (leftButton.GetComponentInChildren <TextMesh>().text == "YES")
            {
                leftButton.OnInteract();
            }
            else
            {
                rightButton.OnInteract();
            }
            yield break;
        }
        else if (Regex.IsMatch(command, @"^\s*(no|N)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            if (leftButton.GetComponentInChildren <TextMesh>().text == "NO")
            {
                leftButton.OnInteract();
            }
            else
            {
                rightButton.OnInteract();
            }
            yield break;
        }
        else if (Regex.IsMatch(command, @"^\s*(left|L)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

            leftButton.OnInteract();
            yield break;
        }
        else if (Regex.IsMatch(command, @"^\s*(right|R)\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
        {
            yield return(null);

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

            resetButton.OnInteract();
            yield return(new WaitUntil(() => resetDone));

            resetButton.OnInteractEnded();
            yield break;
        }
        else
        {
            yield return("sendtochaterror Invalid Command.");

            yield break;
        }
    }
#pragma warning restore 414

    IEnumerator ProcessTwitchCommand(string command)
    {
        command = command.Trim();
        string[] parameters = command.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        if (parameters[0].ToLower() == "tap")
        {
            yield return(null);

            var count = 0;
            do
            {
                yield return("trycancel Cookie Clicking is Cancelled");

                CookieButton.OnInteract();
                count++;
                yield return(new WaitForSeconds(0.01f));
            } while (!(count >= int.Parse(parameters[1])));
        }
        if (parameters[0].ToLower() == "buildings")
        {
            yield return(null);

            Buildings.OnInteract();
        }
        if (parameters[0].ToLower() == "set")
        {
            if (parameters[1].ToLower() == "x1")
            {
                yield return(null);

                MultiplierButtons[0].OnInteract();
            }
            if (parameters[1].ToLower() == "x10")
            {
                yield return(null);

                MultiplierButtons[1].OnInteract();
            }
            if (parameters[1].ToLower() == "x100")
            {
                yield return(null);

                MultiplierButtons[2].OnInteract();
            }
            if (parameters[1].ToLower() == "x1000")
            {
                yield return(null);

                MultiplierButtons[3].OnInteract();
            }
        }
        if (parameters[0].ToLower() == "buy")
        {
            yield return(null);

            if (parameters.Length == 1)
            {
                holding = true;
                Buildings_Display.OnInteractEnded();
                holding = false;
                yield break;
            }
            switch (parameters[1].ToLower())
            {
            case "grandma":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Grandma"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "farm":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Farm"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "mine":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Mine"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "factory":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Factory"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "bank":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Bank"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "temple":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Temple"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "wizardtower":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Wizard Tower"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "shipment":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Shipment"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "alchemylab":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Alchemy Lab"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "portal":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Portal"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "timemachine":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Time Machine"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "antimattercondensor":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Antimatter\n Condensor"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            case "prism":
                Building_Counter = Array.IndexOf(Buildings_Names, Buildings_Text.text);
                while (Building_Counter != Array.IndexOf(Buildings_Names, "Prism"))
                {
                    Buildings_Display.OnInteractEnded();
                    yield return(null);
                }
                break;

            default:
                break;
            }
        }
        if (parameters[0].ToLower() == "rebirth")
        {
            yield return(null);

            Rebirth.OnInteract();
        }
        if (parameters[0].ToLower() == "return")
        {
            yield return(null);

            Return_Button.OnInteract();
        }
    }
Exemple #29
0
#pragma warning restore 414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        if (stageTiming < 45)
        {
            stageTiming = 45;
        }
        var    pieces   = command.ToLowerInvariant().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        string theError = "";

        yield return(null);

        if (pieces.Length == 1)
        {
            if (pieces[0] == "type" || pieces[0] == "t")
            {
                theError = "sendtochaterror Missing argument! You must type a 1 to 8 digit number after 'type'.";
                yield return(theError);
            }
            else if (pieces[0] == "typeenter" || pieces[0] == "te")
            {
                theError = "sendtochaterror Missing argument! You must type a 1 to 8 digit number after 'typeenter'.";
                yield return(theError);
            }

            else if (pieces[0] == "delete" || pieces[0] == "d" || pieces[0] == "del")
            {
                yield return(new WaitForSeconds(.1f));

                yield return(null);

                deleteButton.OnInteract();
            }
            else if (pieces[0] == "clear" || pieces[0] == "c" || pieces[0] == "clr")
            {
                yield return(new WaitForSeconds(.1f));

                yield return(null);

                clearButton.OnInteract();
            }
            else if (pieces[0] == "enter" || pieces[0] == "e" || pieces[0] == "s" || pieces[0] == "submit")
            {
                if (currentInput == "" || currentInput == null)
                {
                    theError = "sendtochaterror Nothing to enter, so enter not pressed!";
                    yield return(theError);
                }
                else
                {
                    yield return(new WaitForSeconds(.1f));

                    yield return(null);

                    enterButton.OnInteract();
                }
            }
            else
            {
                theError = "sendtochaterror Invalid command! " + pieces[0] + " is not a valid command, please use type, delete, clear, enter or typeenter.";
                yield return(theError);
            }
        }

        else if (pieces.Length > 1)
        {
            if (pieces[0] == "type" || pieces[0] == "t")
            {
                if (pieces[1].Length > 8)
                {
                    theError = "sendtochaterror Invalid length! You don't need any more than eight digits.";
                    yield return(theError);
                }
                for (int k = 0; k < pieces[1].Length; k++)
                {
                    Debug.Log(pieces[1].Substring(k, 1));
                    if (pieces[1].Substring(k, 1) != "0" && pieces[1].Substring(k, 1) != "1" && pieces[1].Substring(k, 1) != "2" && pieces[1].Substring(k, 1) != "3" &&
                        pieces[1].Substring(k, 1) != "4" && pieces[1].Substring(k, 1) != "5" && pieces[1].Substring(k, 1) != "6" && pieces[1].Substring(k, 1) != "7" &&
                        pieces[1].Substring(k, 1) != "8" && pieces[1].Substring(k, 1) != "9")
                    {
                        theError = "sendtochaterror Invalid character! " + pieces[1].Substring(k, 1) + " is not a digit.";
                        yield return(theError);
                    }
                }
                if (theError == "")
                {
                    for (int l = 0; l < pieces[1].Length; l++)
                    {
                        var curDigit = Int16.Parse(pieces[1].Substring(l, 1));
                        yield return(new WaitForSeconds(.1f));

                        yield return(null);

                        buttons[curDigit].OnInteract();
                    }
                }
            }
            else if (pieces[0] == "typeenter" || pieces[0] == "te")
            {
                if (pieces[1].Length > 8)
                {
                    theError = "sendtochaterror Invalid length! You don't need any more than eight digits.";
                    yield return(theError);
                }
                for (int k = 0; k < pieces[1].Length; k++)
                {
                    Debug.Log(pieces[1].Substring(k, 1));
                    if (pieces[1].Substring(k, 1) != "0" && pieces[1].Substring(k, 1) != "1" && pieces[1].Substring(k, 1) != "2" && pieces[1].Substring(k, 1) != "3" &&
                        pieces[1].Substring(k, 1) != "4" && pieces[1].Substring(k, 1) != "5" && pieces[1].Substring(k, 1) != "6" && pieces[1].Substring(k, 1) != "7" &&
                        pieces[1].Substring(k, 1) != "8" && pieces[1].Substring(k, 1) != "9")
                    {
                        theError = "sendtochaterror Invalid character! " + pieces[1].Substring(k, 1) + " is not a digit.";
                        yield return(theError);
                    }
                }
                if (theError == "")
                {
                    for (int l = 0; l < pieces[1].Length; l++)
                    {
                        var curDigit = Int16.Parse(pieces[1].Substring(l, 1));
                        yield return(new WaitForSeconds(.1f));

                        yield return(null);

                        buttons[curDigit].OnInteract();
                    }
                }
                yield return(new WaitForSeconds(.1f));

                yield return(null);

                enterButton.OnInteract();
                enterButton.OnInteractEnded();
            }
            else if (pieces[0] == "delete" || pieces[0] == "d" || pieces[0] == "del")
            {
                yield return(new WaitForSeconds(.1f));

                yield return(null);

                deleteButton.OnInteract();
            }
            else if (pieces[0] == "clear" || pieces[0] == "c" || pieces[0] == "clr")
            {
                yield return(new WaitForSeconds(.1f));

                yield return(null);

                clearButton.OnInteract();
            }
            else if (pieces[0] == "enter" || pieces[0] == "e" || pieces[0] == "s" || pieces[0] == "submit")
            {
                yield return(new WaitForSeconds(.1f));

                yield return(null);

                enterButton.OnInteract();
                enterButton.OnInteractEnded();
            }
            else
            {
                theError = "sendtochaterror Invalid command! " + pieces[0] + " is not a valid command, please use type, delete, clear, or enter.";
                yield return(theError);
            }
        }
        else
        {
            theError = "sendtochaterror No command entered! Please use type, delete, clear, or enter.";
            yield return(theError);
        }
    }
Exemple #30
0
 #pragma warning restore 414
 IEnumerator ProcessTwitchCommand(string command)
 {
     if (Regex.IsMatch(command, @"^\s*reset\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
     {
         yield return null;
         if (page == 7)
         {
             pButtons[0].OnInteract();
             yield return new WaitForSeconds(0.1f);
         }
         else if (page < 6)
         {
             while (page < 6)
             {
                 pButtons[1].OnInteract();
                 yield return new WaitForSeconds(0.1f);
             }
         }
         Query.OnInteract();
         yield return new WaitForSeconds(0.5f);
         Query.OnInteractEnded();
         yield break;
     }
     string[] parameters = command.Split(' ');
     if (Regex.IsMatch(parameters[0], @"^\s*query\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
     {
         yield return null;
         if (parameters.Length > 2)
         {
             yield return "sendtochaterror Too many parameters!";
         }
         else if (parameters.Length == 2)
         {
             int digit = 0;
             if (int.TryParse(parameters[1], out digit))
             {
                 if (digit < 0 || digit > 9999)
                 {
                     yield return "sendtochaterror The time(s) to press the query button '" + parameters[1].Join(", ") + "' is out of range 0-9999!";
                     yield break;
                 }
                 if (page == 7)
                 {
                     pButtons[0].OnInteract();
                     yield return new WaitForSeconds(0.1f);
                 }
                 else if (page < 6)
                 {
                     while (page < 6)
                     {
                         pButtons[1].OnInteract();
                         yield return new WaitForSeconds(0.1f);
                     }
                 }
                 for (int i = 0; i < parameters[1].Length; i++)
                 {
                     int dig = int.Parse(parameters[1].ElementAt(i)+"");
                     while ((int)Bomb.GetTime() % 10 != dig)
                     {
                         yield return "trycancel Halted pressing the query button due to a request to cancel!";
                         yield return new WaitForSeconds(0.1f);
                     }
                     Query.OnInteract();
                     Query.OnInteractEnded();
                     yield return new WaitForSeconds(0.1f);
                 }
                 if (submitted == 4)
                 {
                     if (inputs[0] == answer[0] && inputs[1] == answer[1] && inputs[2] == answer[2] && inputs[3] == answer[3])
                     {
                         yield return "solve";
                     }
                     else
                     {
                         yield return "strike";
                     }
                 }
             }
             else
             {
                 yield return "sendtochaterror The time(s) to press the query button '" + parameters[1].Join(", ") + "' is invalid!";
             }
         }
         else if (parameters.Length == 1)
         {
             yield return "sendtochaterror Please specify the time(s) to press the query button!";
         }
         yield break;
     }
     if (Regex.IsMatch(parameters[0], @"^\s*page\s*$", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant))
     {
         yield return null;
         if (parameters.Length > 2)
         {
             yield return "sendtochaterror Too many parameters!";
         }
         else if (parameters.Length == 2)
         {
             int digit = 0;
             if (int.TryParse(parameters[1], out digit))
             {
                 if (digit < 0 || digit > 7)
                 {
                     yield return "sendtochaterror The specified manual page to go to '" + parameters[1] + "' is out of range 0-7!";
                     yield break;
                 }
                 while (page > digit)
                 {
                     pButtons[0].OnInteract();
                     yield return new WaitForSeconds(0.1f);
                 }
                 while (page < digit)
                 {
                     pButtons[1].OnInteract();
                     yield return new WaitForSeconds(0.1f);
                 }
             }
             else
             {
                 yield return "sendtochaterror The specified manual page to go to '" + parameters[1] + "' is invalid!";
             }
         }
         else if (parameters.Length == 1)
         {
             yield return "sendtochaterror Please specify the manual page to go to!";
         }
         yield break;
     }
 }