Пример #1
0
    bool IsBobPresent()
    {
        var bobPresent = BombInfo.GetBatteryCount() == 5 && BombInfo.GetBatteryHolderCount() == 3 &&
                         BombInfo.IsIndicatorPresent(KMBombInfoExtensions.KnownIndicatorLabel.BOB);

        if (!bobPresent || _baseOffsetGenerated)
        {
            return(bobPresent);
        }
        _baseOffsetGenerated = true;
        BombModule.LogFormat("Bob, Our true lord and savior has come to save the Day.: Press any solution that would be valid for any characters present on the serial number at any time.");
        var serial = BombInfo.GetSerialNumber().ToUpperInvariant();

        if (_rotateCounterClockwise)
        {
            BombModule.Log("Circle is spinning counter-clockwise.");
        }
        else
        {
            BombModule.Log("Circle is spinning clockwise.");
        }
        for (var i = 0; i < serial.Length; i++)
        {
            var index      = serial.Substring(i, 1);
            var colorIndex = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".IndexOf(index, StringComparison.Ordinal);
            if (colorIndex < 0)
            {
                BombModule.LogFormat("Unrecognized Serial number character: {0} - Passing the module now", index);
                StartCoroutine(FadeCircle(_wedgeColors[(int)WedgeColors.Red]));
                return(false);
            }
            var lookup = new List <WedgeColors>(colorLookup[colorIndex / 3]);
            if (_rotateCounterClockwise)
            {
                lookup.Reverse();
            }

            if (ValidBOBColors.Any(x => x[0] == lookup[0] && x[1] == lookup[1] && x[2] == lookup[2]))
            {
                continue;
            }

            ValidBOBColors.Add(lookup.ToArray());
        }
        ValidBOBColors = ValidBOBColors.OrderBy(x => x[0].ToString()).ThenBy(x => x[1].ToString()).ToList();
        for (var i = 0; i < ValidBOBColors.Count; i++)
        {
            var lookup = ValidBOBColors[i];
            BombModule.LogFormat("Bob Solution #{3}: {0}, {1}, {2}", lookup[0], lookup[1], lookup[2], i + 1);
        }

        _currentSolution = new WedgeColors[3];
        return(true);
    }
Пример #2
0
    void HandleWedge(WedgeColors color)
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, BombModule.transform);

        if (_holdTime > 0.5f)
        {
            BombModule.LogFormat("Module Reset to zero buttons pressed.");
            TwitchShouldCancelCommand = true;
            StartCoroutine(RandomSpin(1));
            _currentState = 0;
            return;
        }

        try
        {
            if (!_activated)
            {
                BombModule.LogFormat("Pressed {0} before module has activated", color);
                BombModule.HandleStrike();
                return;
            }

            if (_solved)
            {
                return;
            }



            if (IsBobPresent())
            {
                bool     result = false;
                string[] validColors;
                if (_currentState == 0)
                {
                    validColors = ValidBOBColors.Select(x => x[0].ToString()).Distinct().ToArray();
                    result      = ValidBOBColors.Any(x => x[0] == color);
                }
                else if (_currentState == 1)
                {
                    validColors = ValidBOBColors.Where(x => x[0] == _currentSolution[0]).Select(x => x[1].ToString()).Distinct()
                                  .ToArray();
                    result = ValidBOBColors.Any(x => x[0] == _currentSolution[0] && x[1] == color);
                }
                else
                {
                    validColors = ValidBOBColors.Where(x => x[0] == _currentSolution[0] && x[1] == _currentSolution[1])
                                  .Select(x => x[2].ToString()).Distinct().ToArray();
                    result = ValidBOBColors.Any(x => x[0] == _currentSolution[0] && x[1] == _currentSolution[1] && x[2] == color);
                }

                BombModule.LogFormat("Stage {0}: Pressed {1}. Bob Expected {2}", _currentState + 1, color,
                                     string.Join(", ", validColors));
                if (result)
                {
                    _currentSolution[_currentState] = color;
                    BombModule.LogFormat("Stage {0} Correct.", _currentState + 1);
                    _currentState++;
                    if (_currentState != _currentSolution.Length)
                    {
                        return;
                    }
                    BombModule.LogFormat("Module Passed");
                    var bobColors = ValidBOBColors.SelectMany(x => x).ToArray();
                    StartCoroutine(FadeCircle(_wedgeColors[(int)bobColors[Rnd.Range(0, bobColors.Length)]]));
                }
                else
                {
                    BombModule.LogFormat("Stage {0} Incorrect. Strike", _currentState + 1);
                    _currentState = 0;

                    BombModule.HandleStrike();
                }

                return;
            }

            if (_currentSolution == null)
            {
                return;
            }


            BombModule.LogFormat("Stage {0}: Pressed {1}. I Expected {2}", _currentState + 1, color,
                                 _currentSolution[_currentState]);
            if (color == _currentSolution[_currentState])
            {
                BombModule.LogFormat("Stage {0} Correct.", _currentState + 1);
                _currentState++;
                if (_currentState != _currentSolution.Length)
                {
                    return;
                }
                BombModule.LogFormat("Module Passed");
                StartCoroutine(FadeCircle(new Color(160f / 255, 160f / 255, 160f / 255)));
            }
            else
            {
                BombModule.LogFormat("Stage {0} Incorrect. Strike", _currentState + 1);
                _currentState = 0;

                BombModule.HandleStrike();
            }
        }
        catch (Exception ex)
        {
            BombModule.LogFormat("Exception caused by {0}\n{1}", ex.Message, ex.StackTrace);
            ForceSolve("Module passed by exception");
        }
    }