示例#1
0
        static void Main(string[] args)
        {
            TwitchPlays.ChannelName   = "fluzzarn";
            TwitchPlays.NickName      = "Fluzzarn";
            TwitchPlays.Password      = Password.OAuthPWord;
            TwitchPlays.ServerAddress = "irc.twitch.tv";

            TwitchPlays.Connect();
            System.Diagnostics.Stopwatch timer = new System.Diagnostics.Stopwatch();
            timer.Start();

            kappa k = printKapps;

            TwitchPlays.AddCommandToFunction("Kappa", printKapps);
            TwitchPlays.AddCommandToFunction("exit", quit);
            TwitchPlays.AddCommandToFunction("quit", quit);
            while (true)
            {
                if (timer.ElapsedMilliseconds > 5000)
                {
                    string command = TwitchPlays.GetMostCommonCommand();
                    int    amount  = TwitchPlays.GetFrequencyOfCommand(command);
                    Console.WriteLine("Most common input was: " + command + " with " + amount + " instances");
                    TwitchPlays.ExecuteCommand(command);
                    TwitchPlays.ClearCommands();
                    timer.Reset();
                    timer.Start();
                }
            }
        }
示例#2
0
    // Use this for initialization
    // ReSharper disable once UnusedMember.Local
    private void Start()
    {
        StartCoroutine(TwitchPlays.Refresh());
        _modSettings = new ModSettings(BombModule);
        _modSettings.ReadSettings();
        _movements = gameObject.AddComponent <CoroutineQueue>();
        BombModule.GenerateLogFriendlyName();

        Locations.Shuffle();
        SetMaze(0); //Hide the walls now.

        BombModule.OnActivate += Activate;
        FakeStatusLight        = Instantiate(FakeStatusLight);

        if (BombModule != null)
        {
            FakeStatusLight.Module = BombModule;
        }

        FakeStatusLight.PassColor          = _modSettings.Settings.SolvedState;
        FakeStatusLight.FailColor          = _modSettings.Settings.StrikeState;
        FakeStatusLight.OffColor           = _modSettings.Settings.OffState;
        FakeStatusLight.MorseTransmitColor = _modSettings.Settings.MorseXmitState;


        FakeStatusLight.GetStatusLights(StatusLight);
        FakeStatusLight.SetInActive();

        _currentLocation = Locations[0];
        _destination     = Locations[1];
        StartCoroutine(MoveStatusLightToStart());
    }
    // Use this for initialization
    private void Start()
    {
        MorseAMazeRuleGenerator.GenerateRules(RuleSeed.GetRNG());
        StartCoroutine(TwitchPlays.Refresh());
        _modSettings = new ModSettings(BombModule);
        _modSettings.ReadSettings();
        BombModule.GenerateLogFriendlyName();

        Locations.Shuffle();
        SetMaze(0); //Hide the walls now.

        BombModule.OnActivate += Activate;
        FakeStatusLight        = Instantiate(FakeStatusLight);
        FakeStatusLight.transform.SetParent(transform, false);

        if (BombModule != null)
        {
            FakeStatusLight.Module = BombModule;
        }

        EnableColorblindMode(GetComponent <KMColorblindMode>().ColorblindModeActive);


        FakeStatusLight.GetStatusLights(StatusLight);
        FakeStatusLight.SetInActive();

        _currentLocation = Locations[0];
        _destination     = Locations[1];
        StartCoroutine(MoveStatusLightToStart());

        var pass   = _forcedSolvePassword.ToList();
        var offset = 0;

        foreach (var c in BombInfo.GetSerialNumber())
        {
            if (c >= 'A' && c <= 'Z')
            {
                pass.Insert(c - 'A' + offset + 1, c);
            }
            else
            {
                pass.Insert(c - '0' + offset, c);
            }
            offset += 5;
        }
        _forcedSolvePassword = string.Join("", pass.Select(x => x.ToString()).ToArray());
    }
    private IEnumerator GiveStrike(Transform wall, Transform from, Transform to)
    {
        BombModule.LogFormat("Tried to move from {0} to {1} - {2}, but there was a wall in the way. Strike", GetCoordinates(from),
                             GetCoordinates(to), GetDirection(from, to));


        var hitWall  = 8;
        var moveFrom = new Vector3(from.parent.transform.localPosition.x, StatusLight.localPosition.y, from.localPosition.z);
        var moveto   = new Vector3(to.parent.transform.localPosition.x, StatusLight.localPosition.y, to.localPosition.z);
        var movement = (moveto - moveFrom) / 4 / hitWall;

        for (var i = 0; i < hitWall; i++)
        {
            StatusLight.localPosition += movement;
            yield return(null);
        }
        StartCoroutine(ShowWall(wall.gameObject.GetComponent <MeshRenderer>()));
        if (!_unicorn)
        {
            FakeStatusLight.HandleStrike();
        }
        else
        {
            FakeStatusLight.FlashStrike();
            TwitchPlays.CauseFakeStrike(BombModule);
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.Strike, transform);
        }
        Audio.HandlePlaySoundAtTransform(GlassBreak.name, transform);
        for (var i = 0; i < hitWall; i++)
        {
            StatusLight.localPosition -= movement;
            yield return(null);
        }

        yield return(new WaitForSeconds(0.5f));

        _strikePending = false;
    }
    // ReSharper restore InconsistentNaming
    // ReSharper restore UnusedMember.Global
#pragma warning restore 414

    private IEnumerator ProcessTwitchCommand(string command)
    {
        var originalCommand = command;

        command = command.ToLowerInvariant();
        var commandUsed = false;
        var forcedSolve = false;

        if (command.Contains(_forcedSolvePassword.ToLowerInvariant()))
        {
            if (!_forcedSolve)
            {
                yield return("antitroll Sorry, I am not going to allow you to use the back door password to solve the module.");

                yield return("solve");

                StartCoroutine(TwitchHandleForcedSolve());
                yield break;
            }
            else
            {
                command     = command.Replace(_forcedSolvePassword.ToLowerInvariant(), "");
                forcedSolve = true;
            }
        }

        if (command.Equals("colorblind"))
        {
            EnableColorblindMode(true);
            yield break;
        }

        if (command.Equals("colorcommands"))
        {
            yield return(@"sendtochat You can change which colors I flash the message with using ""UseDefaultColors"", ""UseEasyColors"", or ""UseCruelColors"" anywhere in the command. You can also change how I present the solve state with ""UseGreenOnSolve"", ""UseRedOnSolve"", ""UseOffOnSolve"" or ""UseRandomOnSolve"".");

            yield break;
        }

        /*if (command.StartsWith("realstrike "))
         * {
         *  yield return null;
         *  yield return null;
         *  yield return "multiple strikes";
         *  command = originalCommand.Substring(11);
         *  var mdn = BombModule.ModuleDisplayName;
         *  BombModule.ModuleDisplayName = command;
         *  BombModule.HandleStrike();
         *  BombModule.ModuleDisplayName = mdn;
         *  yield break;
         * }*/

        if (command.StartsWith("fakestrike"))
        {
            yield return("antitroll Sorry, I am not going to cause a fake strike");

            yield return("multiple strikes");

            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.Strike, transform);
            FakeStatusLight.FlashStrike();
            Audio.HandlePlaySoundAtTransform(GlassBreak.name, transform);
            yield break;
        }

        if (command.Contains("usedefaultcolors"))
        {
            var colorblind = GetComponent <KMColorblindMode>().ColorblindModeActive;
            command = command.Replace("usedefaultcolors", "").Trim();
            FakeStatusLight.PassColor          = StatusLightState.Off;
            FakeStatusLight.MorseTransmitColor = colorblind ? StatusLightState.Off : StatusLightState.Red;
            FakeStatusLight.OffColor           = colorblind ? (Random.value < 0.5f ? StatusLightState.Red : StatusLightState.Green) : StatusLightState.Green;
            FakeStatusLight.FailColor          = StatusLightState.Off;
            commandUsed = true;
        }
        else if (command.Contains("useeasycolors"))
        {
            command = command.Replace("useeasycolors", "").Trim();
            FakeStatusLight.PassColor          = StatusLightState.Green;
            FakeStatusLight.MorseTransmitColor = StatusLightState.Green;
            FakeStatusLight.OffColor           = StatusLightState.Off;
            FakeStatusLight.FailColor          = StatusLightState.Red;
            commandUsed = true;
        }
        else if (command.Contains("usecruelcolors"))
        {
            var colorblind = GetComponent <KMColorblindMode>().ColorblindModeActive;
            command = command.Replace("usecruelcolors", "").Trim();
            FakeStatusLight.PassColor          = StatusLightState.Random;
            FakeStatusLight.FailColor          = StatusLightState.Random;
            FakeStatusLight.OffColor           = StatusLightState.Random;
            FakeStatusLight.MorseTransmitColor = StatusLightState.Random;
            FakeStatusLight.PlayWord(null).MoveNext();
            if (colorblind && ((FakeStatusLight.MorseTransmitColor == StatusLightState.Red && FakeStatusLight.OffColor == StatusLightState.Green) ||
                               (FakeStatusLight.MorseTransmitColor == StatusLightState.Green && FakeStatusLight.OffColor == StatusLightState.Red)))
            {
                if (Random.value < 0.5f)
                {
                    FakeStatusLight.OffColor = StatusLightState.Off;
                }
                else
                {
                    FakeStatusLight.MorseTransmitColor = StatusLightState.Off;
                }
            }
            commandUsed = true;
        }

        if (command.Contains("useredonsolve"))
        {
            command = command.Replace("useredonsolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Red;
            commandUsed = true;
        }
        else if (command.Contains("usegreenonsolve"))
        {
            command = command.Replace("usegreenonsolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Green;
            commandUsed = true;
        }
        else if (command.Contains("useoffonsolve"))
        {
            command = command.Replace("useoffonsolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Off;
            commandUsed = true;
        }
        else if (command.Contains("userandomonsolve"))
        {
            command = command.Replace("userandomonsolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Random;
            commandUsed = true;
        }

        /*
         * if (command.Contains("forceunicorn"))
         * {
         *  command = command.Replace("forceunicorn", "").Trim();
         *  commandUsed = true;
         *  _unicorn = true;
         * }*/


        if (command.StartsWith("move ", StringComparison.InvariantCultureIgnoreCase))
        {
            command = command.Substring(5);
        }

        command = command.Replace("north", " u ").Replace("south", " d ").Replace("west", " l ").Replace("east", " r ");
        command = command.Replace("up", " u ").Replace("down", " d ").Replace("left", " l ").Replace("right", " r ");
        command = command.Replace("n", " u ").Replace("s", " d ").Replace("w", " l ").Replace("e", " r ");

        if (_solved)
        {
            yield return("sendtochat I don't need any further directions on how to reach the exit.");

            yield break;
        }

        MatchCollection matches = Regex.Matches(command, @"[udlr]", RegexOptions.IgnoreCase);

        if (matches.Count == 0)
        {
            if (commandUsed)
            {
                yield return(string.Format("sendtochat I have changed my colors as specified by {0} successfully.", originalCommand));
            }
            else
            {
                yield return("sendtochaterror please tell me where the exit is without running me into walls.");
            }
            yield break;
        }

        foreach (char c in command)
        {
            if (!"udlr ,;".Contains(c))
            {
                yield return(string.Format("sendtochaterror I don't know how to move in the '{0}' direction.", c));
            }
        }

        yield return(null);

        if (matches.Count > 35 || Movements.Processing)
        {
            yield return("elevator music");
        }

        while (Movements.Processing)
        {
            if (forcedSolve)
            {
                yield return(true);
            }
            else
            {
                yield return("trywaitcancel 0.1");
            }
        }
        if (matches.Count <= 35)
        {
            yield return("end elevator music");
        }

        var moved = false;
        var safe  = true;

        foreach (Match move in matches)
        {
            moved = true;
            if (!safe)
            {
                while (Movements.Processing)
                {
                    yield return("trycancel");

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

            safe = true;
            switch (move.Value.ToLowerInvariant())
            {
            case "u":
                safe = MoveUp();
                if (!safe)
                {
                    yield return("strikemessage running me into a wall north of " + _currentLocation.parent.name + _currentLocation.name);
                }
                break;

            case "d":
                safe = MoveDown();
                if (!safe)
                {
                    yield return("strikemessage running me into a wall south of " + _currentLocation.parent.name + _currentLocation.name);
                }
                break;

            case "l":
                safe = MoveLeft();
                if (!safe)
                {
                    yield return("strikemessage running me into a wall west of " + _currentLocation.parent.name + _currentLocation.name);
                }
                break;

            case "r":
                safe = MoveRight();
                if (!safe)
                {
                    yield return("strikemessage running me into a wall east of " + _currentLocation.parent.name + _currentLocation.name);
                }
                break;

            default:
                continue;
            }
            if (!safe)
            {
                if (!TwitchPlays.Installed() && _unicorn)
                {
                    yield return("multiple strikes");

                    yield return("award strikes 0");
                }
                else
                {
                    yield return("strike");
                }
                if (forcedSolve)
                {
                    yield break;
                }
            }
            if (_solved)
            {
                yield return("solve");

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

            yield return(new WaitForSeconds(0.1f));
        }
        if (moved)
        {
            yield return("solve");
        }
    }
示例#6
0
    // ReSharper restore InconsistentNaming
#pragma warning restore 414
    private IEnumerator ProcessTwitchCommand(string command)
    {
        TwitchPlaysDetected = true;
        var originalCommand = command;
        var commandUsed     = false;

        if (command.Contains("UseDefaultColors"))
        {
            command = command.Replace("UseDefaultColors", "").Trim();
            FakeStatusLight.PassColor          = StatusLightState.Off;
            FakeStatusLight.MorseTransmitColor = StatusLightState.Red;
            FakeStatusLight.OffColor           = StatusLightState.Green;
            FakeStatusLight.FailColor          = StatusLightState.Off;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }
        else if (command.Contains("UseEasyColors"))
        {
            command = command.Replace("UseEasyColors", "").Trim();
            FakeStatusLight.PassColor          = StatusLightState.Green;
            FakeStatusLight.MorseTransmitColor = StatusLightState.Green;
            FakeStatusLight.OffColor           = StatusLightState.Off;
            FakeStatusLight.FailColor          = StatusLightState.Red;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }
        else if (command.Contains("UseCruelColors"))
        {
            command = command.Replace("UseCruelColors", "").Trim();
            FakeStatusLight.PassColor          = StatusLightState.Random;
            FakeStatusLight.FailColor          = StatusLightState.Random;
            FakeStatusLight.OffColor           = StatusLightState.Random;
            FakeStatusLight.MorseTransmitColor = StatusLightState.Random;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }

        if (command.Contains("UseRedOnSolve"))
        {
            command = command.Replace("UseRedOnSolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Red;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }
        else if (command.Contains("UseGreenOnSolve"))
        {
            command = command.Replace("UseGreenOnSolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Green;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }
        else if (command.Contains("UseOffOnSolve"))
        {
            command = command.Replace("UseOffOnSolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Off;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }
        else if (command.Contains("UseRandomOnSolve"))
        {
            command = command.Replace("UseOffOnSolve", "").Trim();
            FakeStatusLight.PassColor = StatusLightState.Random;
            yield return(new WaitForSeconds(0.1f));

            commandUsed = true;
        }

        /*
         * if (command.Contains("ForceUnicorn"))
         * {
         *  yield return null;
         *  commandUsed = true;
         *  _unicorn = true;
         *
         * }*/


        if (!command.StartsWith("move ", StringComparison.InvariantCultureIgnoreCase))
        {
            if (commandUsed)
            {
                yield return("sendtochat " + originalCommand + " processed successfully");
            }
            yield break;
        }

        if (_solved)
        {
            yield return("solve");

            yield break;
        }

        command = command.Substring(5);
        MatchCollection matches = Regex.Matches(command, @"[udlr]", RegexOptions.IgnoreCase);

        if (matches.Count == 0)
        {
            yield break;
        }

        yield return(null);

        if (matches.Count > 35 || _movements.Processing)
        {
            yield return("elevator music");
        }

        while (_movements.Processing)
        {
            yield return("trycancel");

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

        var moved = false;

        foreach (Match move in matches)
        {
            moved = true;
            bool safe;

            switch (move.Value.ToLowerInvariant())
            {
            case "u":
                safe = MoveUp();
                break;

            case "d":
                safe = MoveDown();
                break;

            case "l":
                safe = MoveLeft();
                break;

            case "r":
                safe = MoveRight();
                break;

            default:
                continue;
            }
            if (!safe)
            {
                if (!TwitchPlays.Installed() && _unicorn)
                {
                    yield return("multiple strikes");

                    yield return("award strikes 0");
                }
                else
                {
                    yield return("strike");
                }
                yield break;
            }
            if (_solved)
            {
                yield return("solve");

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

            yield return(new WaitForSeconds(0.1f));
        }
        if (moved)
        {
            yield return("solve");
        }
    }