コード例 #1
0
    private void ButtonSinglePressed()
    {
        // If the module contains the word The 
        List<string> theModules = Bomb.GetSolvableModuleNames()
            .FindAll(module => module.ToLower().Contains(" the ") 
                               || module.ToLower().StartsWith("the "));
        // If the module starts with a vowel
        List<string> vowelModules = Bomb.GetSolvableModuleNames()
            .FindAll(module => "aeiou".IndexOf(module.ToLower()[0]) >= 0);
        // If the module contains "P" or "R"
        List<string> prContainsModules = Bomb.GetSolvableModuleNames()
            .FindAll(module => module.ContainsIgnoreCase("p") || module.ContainsIgnoreCase("r"));
        theModules = RemoveIgnoredModules(theModules);
        vowelModules = RemoveIgnoredModules(vowelModules);
        prContainsModules = RemoveIgnoredModules(prContainsModules);
        foreach (string module in Bomb.GetSolvedModuleNames())
        {
            theModules.Remove(module);
            vowelModules.Remove(module);
            prContainsModules.Remove(module);
        }

        bool theModulePassed = theModules.Count <= 0;
        bool singleAuthorsPassed = vowelModules.Count <= 0;
        bool beforeModulePassed = prContainsModules.Count <= 0;

        if (theModulePassed && singleAuthorsPassed && beforeModulePassed)
        {
            Module.HandlePass();
        }
        else
        {
            Module.HandleStrike();
        }
    }
コード例 #2
0
    void KeepPress()
    {
        if (correctOffer == offerCount || !isActivated)         // This means module is passed
        {
            return;
        }

        if (deck[lowestCardInDeck].value < offer.value)
        {
            PrintDebug("Wrong! Deck card #" + (lowestCardInDeck + 1) + " had lower value than the offer.");
            Module.HandleStrike();
        }
        else
        {
            PrintDebug("Keeping your cards was the correct decision!");
            correctOffer++;
        }
        if (correctOffer == offerCount)
        {
            //TURNOFF INTERACTIONS
            // SHOW CARDBACK
            Module.HandlePass();
            ShowCardBacks();
            return;
        }
        currentOffer++;
        ResetOffer();
        CalculateLowestCardInDeck();
        //PrintOutDeck();
        UpdateCardVisuals();
    }
コード例 #3
0
    protected bool HandlePressN()
    {
        KMAudio.HandlePlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
        North.AddInteractionPunch(0.5f);

        if (SOLVED)
        {
            if (CurrentP.Contains("N"))
            {
                {
                    BombModule.HandlePass();
                    SOLVED = false;
                    DebugLog("The module has been defused.");
                }
            }
            else
            {
                if (CurrentP.Contains("U"))
                {
                    BombModule.HandleStrike();
                }
                else
                {
                    CurY--;
                    DebugLog("X = {0}, Y = {1}", CurX + 1, CurY + 1);
                }
            }
        }
        return(false);
    }
コード例 #4
0
    private void PressButton(Func <Direction, Direction> turn)
    {
        if (_solved)
        {
            return;
        }

        GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
        GetComponent <KMSelectable>().AddInteractionPunch();

        // Turn
        _direction = turn(_direction);

        // Check if you can move forward
        if (!_direction.IsWallForward(_location))
        {
            // If so, move forward
            _location = _direction.MoveForward(_location);
        }
        else
        {
            // Else, give a strike
            Debug.LogFormat("[3D Tunnels #{0}] There’s a wall in front of you at location {1}, orientation {2}. Strike!", _moduleId, _symbolNames[_location], _direction);
            Module.HandleStrike();
        }

        UpdateDisplay();
    }
コード例 #5
0
    void HandlePress(int button)
    {
        Audio.PlaySoundAtTransform("tick", this.transform);

        switch (button)
        {
        case -1:
            RotateFlavours(-1);
            LeftButton.AddInteractionPunch();
            break;

        case 1:
            RotateFlavours(1);
            RightButton.AddInteractionPunch();
            break;

        case 0:
            Submit();
            SellButton.AddInteractionPunch();
            break;

        default:
            BombModule.HandleStrike();
            break;
        }
    }
コード例 #6
0
    void PressNumberButton(KMSelectable button)
    {
        button.AddInteractionPunch(.5f);
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        if (moduleSolved || thermometerAnimating || stage2)
        {
            return;
        }
        var ix = Array.IndexOf(numberButtons, button);

        Debug.LogFormat("[Devilish Eggs #{0}] You pressed the button with the label {1}.", moduleId, numberButtonLabels[ix]);
        if (numberButtonLabels[ix] != stage1Solution[enteringStage])
        {
            Debug.LogFormat("[Devilish Eggs #{0}] That was incorrect. Strike!", moduleId);
            module.HandleStrike();
        }
        else
        {
            StartCoroutine(TemperatureChange(temperatures[enteringStage]));
            Debug.LogFormat("[Devilish Eggs #{0}] That was correct. The temperature went to the position of {1}, which has the label {2}.", moduleId, (temperatures[enteringStage] + 1) * 5, (temperatureLabels[temperatures[enteringStage]] + 1) * 5);
            stage1LEDs[enteringStage].material = ledGreen;
            enteringStage++;
        }
        if (enteringStage == 8)
        {
            StageTwo();
        }
    }
コード例 #7
0
    private IEnumerator Watch()
    {
        yield return(null);

        if (TwitchPlaysActive)
        {
            Debug.LogFormat("[SUSadmin #{0}] Reflectors are disabled because TP is active", moduleId);
            yield break;
        }
        int modulesCount = transform.parent.childCount;
        IEnumerable <KMBombModule> modules = Enumerable.Range(0, modulesCount).Select(i => transform.parent.GetChild(i).GetComponent <KMBombModule>()).Where(m => m != null);

        reflectors = new HashSet <SusadminReflector>(modules.Select(m => SusadminReflector.CreateReflector(m)).Where(m => m != null));
        while (!solved)
        {
            HashSet <SusadminReflector> reflectorsWithStrike = new HashSet <SusadminReflector>(reflectors.Where(r => r.ShouldStrike()));
            int expectedExternalStrikesCount = reflectorsWithStrike.Count();
            foreach (SusadminReflector r in reflectorsWithStrike)
            {
                reflectors.Remove(r);
            }
            for (int i = externalStrikesCount; i < expectedExternalStrikesCount; i++)
            {
                Debug.LogFormat("[SUSadmin #{0}] Strike from external action", moduleId);
                Module.HandleStrike();
            }
            externalStrikesCount = expectedExternalStrikesCount;
            if (reflectors.Count == 0 && watchingCoroutine != null)
            {
                StopCoroutine(watchingCoroutine);
            }
            yield return(new WaitForSeconds(WATCH_INTERVAL));
        }
    }
コード例 #8
0
    /// <summary>
    /// On pressing SUBMIT.
    /// </summary>
    /// <param name="btn">Just for sound support</param>
    private void PressSubmit(int btn)
    {
        if (currentIndex == 0 && submission[0] == "" && !solutionExists) // No solutions is correct answer, mosule solved
        {
            Debug.LogFormat("[Diophantine Equations #{0}]: Player pressed SUBMIT, implying there are no solutions.", moduleId);
            Debug.LogFormat("[Diophantine Equations #{0}]: It worked, module solved!", moduleId);

            StartCoroutine(AnimateScreenPass());
            solved = true;

            Module.HandlePass();
            Audio.PlaySoundAtTransform("solve", Buttons[btn].transform);
        }
        else if (currentIndex == 0 && submission[0] == "" && solutionExists) // No solutions is wrong answer, module striked
        {
            Debug.LogFormat("[Diophantine Equations #{0}]: Player pressed SUBMIT, implying there are no solutions.", moduleId);
            Debug.LogFormat("[Diophantine Equations #{0}]: That didn't work well, strike!", moduleId);

            StartCoroutine(AnimateScreenStrike());
            Module.HandleStrike();
            Audio.PlaySoundAtTransform("strike", Buttons[btn].transform);
        }
        else if (submission[currentIndex] != "")                             // Submitting an answer
        {
            if (int.Parse(submission[currentIndex]) == answer[currentIndex]) // Answer is correct
            {
                Debug.LogFormat("[Diophantine Equations #{0}]: Player's submission for {1} is {2}. That was correct!", moduleId, VarNames[currentIndex], submission[currentIndex]);
                // Iterating index
                currentIndex++;

                if (currentIndex < 4) // Displaying next submission prompt
                {
                    ScreenText.text = VarNames[currentIndex] + " = " + submission[currentIndex];
                }
                else // All answers were correct, module solved
                {
                    Debug.LogFormat("[Diophantine Equations #{0}]: All answers were correct, module solved!", moduleId);

                    StartCoroutine(AnimateScreenPass());
                    solved = true;

                    Module.HandlePass();
                    Audio.PlaySoundAtTransform("solve", Buttons[btn].transform);
                }
            }
            else // Answer is incorrect, submission reset
            {
                Debug.LogFormat("[Diophantine Equations #{0}]: Player's submission for {1} is {2}. The correct answer is {3}. Strike! Submission reset.", moduleId, VarNames[currentIndex], submission[currentIndex], answer[currentIndex]);

                StartCoroutine(AnimateScreenStrike());
                Module.HandleStrike();
                Audio.PlaySoundAtTransform("strike", Buttons[btn].transform);

                submission = new string[4] {
                    "", "", "", ""
                };
                currentIndex = 0;
            }
        }
    }
コード例 #9
0
    IEnumerator SyncLights(Light light)
    {
        syncPause = true;

        ApplyToSpeed(light, l => l.StopFlashing());

        List <Action <float> > animations = new List <Action <float> >();
        var lightsToSync = Lights.Where(l => l.speed == SelectedLight.speed).OrderBy(l => l.syncIndex).Concat(Lights.OrderBy(l => l.syncIndex).Where(l => l.speed == light.speed)).ToArray();

        for (int i = 0; i < lightsToSync.Length - 1; i++)
        {
            animations.Add(SyncAnimation(lightsToSync[i], lightsToSync[i + 1]));
        }
        ApplyToSpeed(SelectedLight, l => l.selection.SetActive(false));

        float animStart = Time.time;
        float alpha     = 0;

        while (alpha < 1)
        {
            alpha = Math.Min(Time.time - animStart, 1);
            foreach (Action <float> animation in animations)
            {
                animation(alpha);
            }
            yield return(null);
        }

        bool valid = ValidateSync(SelectedLight, light);

        Log("{0} synced {1} while {2} and {3} while {4}.", valid ? "Successfully" : "Incorrectly", SelectedLight.speed, SelectedLight.State ? "on" : "off", light.speed, light.State ? "on" : "off");

        if (valid)
        {
            int startingIndex = Lights.Count(l => l.speed == SelectedLight.speed) + 1;
            ApplyToSpeed(light, l =>
            {
                l.StopFlashing();
                l.StartFlashing();
                l.syncIndex = startingIndex++;
            });

            ApplyToSpeed(SelectedLight, l =>
            {
                l.randomDelay = light.randomDelay;
                l.speed       = light.speed;
                l.StartFlashing();
            });
        }
        else
        {
            Module.HandleStrike();

            ApplyToSpeed(light, l => l.StartFlashing());
            ApplyToSpeed(SelectedLight, l => l.StartFlashing());
        }

        SelectedLight = null;
        syncPause     = false;
    }
コード例 #10
0
    private void checkEvents()
    {
        while (_events.Count >= 2 && _events[0] == "tick" && _events[1] == "tick")
        {
            _events.RemoveAt(0);
        }

        var input = _eventsPerDigit.IndexOf(list => list.SequenceEqual(_events));

        if (input != -1)
        {
            process(input);
        }
        else if (_events.Count(e => e == "up") >= _events.Count(e => e == "down"))
        {
            var validPrefix = _eventsPerDigit.IndexOf(list => list.Take(_events.Count).SequenceEqual(_events));
            if (validPrefix == -1)
            {
                Debug.LogFormat(@"[Black Hole #{0}] You entered {1}, which is not a valid digit.", _moduleId, _events.JoinString(", "));
                Module.HandleStrike();
                _events.Clear();
                _events.Add("tick");
            }
        }
    }
コード例 #11
0
 void onSubmit()
 {
     if (!moduleSolved)
     {
         submit.AddInteractionPunch();
         audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         if ((int)(bomb.GetTime() % 10) == submitTime)
         {
             bool flag = true;
             for (int aa = 0; aa < 3; aa++)
             {
                 if (DialPosAns[aa] != DialPos[aa])
                 {
                     flag = false;
                     break;
                 }
                 if (!(DialColAns[aa].Equals(dialColorNames[aa])))
                 {
                     flag = false;
                     break;
                 }
             }
             if (flag)
             {
                 audio.PlaySoundAtTransform(sounds[1].name, transform);
                 Debug.LogFormat("[Colorful Dials {0}] Module solved. Everybody boogie!", moduleId);
                 mainScreen[0].color = Color.white;
                 mainScreen[1].color = Color.white;
                 mainScreen[2].color = Color.white;
                 mainScreen[0].text  = "W";
                 mainScreen[1].text  = "I";
                 mainScreen[2].text  = "N";
                 for (int aa = 0; aa < 3; aa++)
                 {
                     while (DialPos[aa] != 0)
                     {
                         DialPos[aa] = (DialPos[aa] + 1) % 10;
                         dials[aa].transform.Rotate(Vector3.up, 36f);
                     }
                     dialColors[aa].material = colors[8];
                     dialScreens[aa].text    = "";
                 }
                 moduleSolved = true;
                 module.HandlePass();
             }
             else
             {
                 audio.PlaySoundAtTransform(sounds[0].name, transform);
                 module.HandleStrike();
                 Debug.LogFormat("[Colorful Dials {0}] Strike! You tried to submit {1} {2} {3} at {4} seconds", moduleId, dialColorNames[0][0] + "" + DialPos[0], dialColorNames[1][0] + "" + DialPos[1], dialColorNames[2][0] + "" + DialPos[2], (int)(bomb.GetTime() % 10));
             }
         }
         else
         {
             audio.PlaySoundAtTransform(sounds[0].name, transform);
             module.HandleStrike();
             Debug.LogFormat("[Colorful Dials {0}] Strike! You tried to submit {1} {2} {3} at {4} seconds", moduleId, dialColorNames[0][0] + "" + DialPos[0], dialColorNames[1][0] + "" + DialPos[1], dialColorNames[2][0] + "" + DialPos[2], (int)(bomb.GetTime() % 10));
         }
     }
 }
コード例 #12
0
    private void submitBtnUp()
    {
        if (_submitLongPressCoroutine != null)
        {
            StopCoroutine(_submitLongPressCoroutine);
            _submitLongPressCoroutine = null;
        }

        if (_submitLongPress)
        {
            return;
        }

        if (_currentPortions.SequenceEqual(_correctPortions))
        {
            Debug.LogFormat(@"[Lion’s Share #{0}] Module solved.", _moduleId);
            Module.HandlePass();
            Year.text     = "";
            _isSolved     = true;
            _selectedLion = -1;
            updatePie();
            Audio.PlaySoundAtTransform("Roar" + Rnd.Range(1, 5), transform);
        }
        else
        {
            Debug.LogFormat(@"[Lion’s Share #{0}] Incorrect solution submitted ({1}).", _moduleId, _lionNames.Select((l, ix) => string.Format(@"{0}={1}%", l, _currentPortions[ix])).JoinString(", "));
            Module.HandleStrike();
        }
    }
コード例 #13
0
 private KMSelectable.OnInteractHandler stage2Select(KMSelectable button, House house)
 {
     return(delegate
     {
         if (_isSolved)
         {
             return false;
         }
         button.AddInteractionPunch();
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
         var maxScore = _points.Max(kvp => kvp.Value);
         if (_points[house] == maxScore)
         {
             Debug.LogFormat(@"[Hogwarts #{0}] Pressed {1}. Module solved.", _moduleId, house);
             Module.HandlePass();
             Audio.PlaySoundAtTransform(house + " wins", transform);
             _isSolved = true;
         }
         else
         {
             Debug.LogFormat(@"[Hogwarts #{0}] Pressed {1}. Strike.", _moduleId, house);
             Module.HandleStrike();
         }
         return false;
     });
 }
コード例 #14
0
    void Submit()
    {
        if (tseriesSubs >= pewdiepieSubs)
        {
            if (numbers[0] == 0 && numbers[1] == 0 && numbers[2] == 0 && numbers[3] == 0 && numbers[4] == 0)
            {
                StartCoroutine(Solve());
            }

            else
            {
                taps = 0;
                Module.HandleStrike();
            }
        }

        else
        {
            int gap = (pewdiepieSubs - tseriesSubs) % 100000;
            if (numbers[4] == gap % 10 && numbers[3] == gap / 10 % 10 && numbers[2] == gap / 100 % 10 && numbers[1] == gap / 1000 % 10 && numbers[0] == gap / 10000)
            {
                StartCoroutine(Solve());
            }

            else
            {
                taps = 0;
                Module.HandleStrike();
            }
        }
    }
コード例 #15
0
 void FixedUpdate()
 {
     if (!_modSolved)
     {
         if (_bomb.GetSolvedModuleNames().Count != _curSolved)
         {
             _curSolved = _bomb.GetSolvedModuleNames().Count();
             if (_immediately)
             {
                 _module.HandleStrike();
                 Debug.LogFormat("[Burnout #{0}]: Struck due to the module wanting to be solved immediately.", _modID);
                 return;
             }
             if (_halfBomb)
             {
                 if (_curSolved >= _halfModules)
                 {
                     _halfComplete = true;
                 }
             }
             if (_fullBomb)
             {
                 if (_curSolved == _ignoredTotal)
                 {
                     _fullComplete = true;
                 }
             }
         }
     }
 }
コード例 #16
0
 void ProcessInput(bool pressedEven)
 {
     if (totalOverall % 2 == 0 == !isRedText == pressedEven)
     {
         correctPresses++;
         if (correctPresses >= requiredPresses)
         {
             LogModule(string.Format("Enough correct presses have been made to disarm the module."));
             StopCoroutine(countDownCoroutine);
             mAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
             modSelf.HandlePass();
             interactable = false;
             StartCoroutine(HandleSolveAnim());
         }
         else
         {
             StartCoroutine(HandleFlickerChangeAnim());
             interactable = false;
             if (TwitchPlaysActive)
             {
                 timeLeft = 30;
             }
         }
     }
     else
     {
         LogModule(string.Format("Strike! The {0} button was pressed for the display {1} in {3} (press no. {2})", pressedEven ? "even" : "odd",
                                 displayNo, correctPresses + 1, isRedText ? "red" : "green"));
         LogModule(string.Format("For reference, all digits shown before this strike were {0}", allDigits.Join(", ")));
         modSelf.HandleStrike();
         ResetModule();
         LogModule("Tap the display to restart the module.");
     }
 }
コード例 #17
0
    private KMSelectable.OnInteractHandler GetFiteButtonPressHandler(int btn)
    {
        return(delegate
        {
            Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, fitebuttons[btn].transform);
            switch (btn)
            {
            case 0:
                StageTwoDisplayInt = StageTwoDisplayInt - 1;
                if (StageTwoDisplayInt < 0)
                {
                    StageTwoDisplayInt = StageTwoDisplayInt + 5;
                }
                break;

            case 1:
                StageTwoDisplayInt = (StageTwoDisplayInt + 1) % 5;
                break;

            case 2:
                if (_AttackStrategies[StageTwoDisplayInt].publicName != "Hide")
                {
                    if (_AttackStrategies[StageTwoDisplayInt].condition)
                    {
                        LogMessage("Correct strategy selected, advancing to stage three");
                        HandleStageThree();
                    }
                    else
                    {
                        Module.HandleStrike();
                        Audio.PlaySoundAtTransform("StrikeEffect", transform);
                        Starter();
                    }
                }
                else
                {
                    if (_AttackStrategies[StageTwoDisplayInt].condition)
                    {
                        LogMessage("You hid from the enemy, assigning new enemy.");
                        generateNewOk();
                        HandleStageTwo();
                    }
                    else
                    {
                        LogMessage("Wrong strategy selected, you were ko'd, Strike given, returning to stage 0");
                        Module.HandleStrike();
                        Audio.PlaySoundAtTransform("StrikeEffect", transform);
                        Starter();
                    }
                }
                break;

            default:
                break;
            }
            ;
            Stage2AttacStrategy.text = _AttackStrategies[StageTwoDisplayInt].publicName;
            return false;
        });
    }
コード例 #18
0
 private void SubmitPressed(int buttonNum)
 {
     if (randomSequenceTop.Count() == 0)
     {
         DebugLog("...you haven't generated a sequence yet!");
         module.HandleStrike();
         StopPlaying();
         GenerateColor();
         UpdateText();
         return;
     }
     if (currentState[0].ToString() == randomSequenceTop[amountCorrect] && currentState[1].ToString() == randomSequenceBottom[amountCorrect])
     {
         amountCorrect++;
         UpdateText();
         StartCoroutine(PlayCorrectSound());
         DebugLog("You submitted [{0} {1}]. That's correct!", currentState[0], currentState[1]);
     }
     else
     {
         module.HandleStrike();
         StopPlaying();
         GenerateColor();
         UpdateText();
         amountCorrect = 0;
         DebugLog("You submitted [{0} {1}]. Thats wrong...", currentState[0], currentState[1]);
     }
     if (amountCorrect == GoalNumber)
     {
         StartCoroutine(ModuleSolve());
     }
 }
コード例 #19
0
    private void SetRowHandler(Transform obj, int row)
    {
        var sel = obj.GetComponent <KMSelectable>();

        _rows[row] = obj.GetComponent <TextMesh>();

        sel.OnInteract = delegate
        {
            sel.AddInteractionPunch(.25f);
            if (_safeLocations == null || _isSolved || Enumerable.Range(0, 5).All(c => _revealed[c][row]))
            {
                return(false);
            }

            if (Enumerable.Range(0, 5).Any(c => !_revealed[c][row] && _solution[c][row] == true))
            {
                var col = Enumerable.Range(0, 5).First(c => !_revealed[c][row] && _solution[c][row] == true);
                Debug.LogFormat("[Battleship #{2}] Used Water on Row {1}, but there is an unrevealed ship piece at {0}{1}.", (char)('A' + col), (char)('1' + row), _moduleId);
                Module.HandleStrike();
            }
            else
            {
                for (int col = 0; col < 5; col++)
                {
                    _revealed[col][row] = true;
                }
                UpdateRevealedGraphics();
                Audio.PlaySoundAtTransform("Splash" + Rnd.Range(1, 9), MainSelectable.transform);
            }

            CheckSolved();
            return(false);
        };
    }
コード例 #20
0
    bool OnDotPress()
    {
        if (!activated)
        {
            BombModule.HandleStrike();
            return(false);
        }

        if (solved)
        {
            Audio.PlaySoundAtTransform("dot", transform);
        }
        else if (correctResponseMorse[currentResponseIndex] == 0)
        {
            Audio.PlaySoundAtTransform("dot", transform);
            currentResponseIndex++;
            if (currentResponseIndex >= correctResponseMorse.Length)
            {
                DebugLog("Correct response entered, module defused.");
                SolveModule();
            }
        }
        else
        {
            DebugLog("Entered dot(.) as symbol #" + (currentResponseIndex + 1) + ", correct symbol is dash(-). Strike.");
            currentResponseIndex = 0;
            BombModule.HandleStrike();
        }

        return(false);
    }
コード例 #21
0
    private void OnPinInteract(int pinIndex)
    {
        _audio.PlaySoundAtTransform(TapSound.name, transform);

        if (_previouslySelectedConnections.Count >= RequiredInputCount)
        {
            return;
        }

        TangramGridConnectionPoint contactPoint = _tangram.Grid.ExternalConnections[pinIndex];

        if (_selectedConnection.PointA == null)
        {
            OnInteractInputContactPoint(contactPoint);
        }
        else if (_selectedConnection.PointB == null)
        {
            OnInteractOutputContactPoint(contactPoint);
        }
        else
        {
            _bombModule.LogFormat("Trying to select contact point {0}, but module is busy trying to overload the circuit. Strike.", _tangram.GetExternalConnectionIndex(contactPoint) + 1);
            _bombModule.HandleStrike();
        }
    }
    private bool HandleKey(string[] modulesBefore, string[] modulesAfter, FieldInfo keyTurned, FieldInfo otherKeyTurned, FieldInfo beforeKeyField, MethodInfo onKeyTurn)
    {
        if (!GetValue(_activatedField) || GetValue(keyTurned))
        {
            return(false);
        }
        KMBombInfo   bombInfo   = BombComponent.GetComponent <KMBombInfo>();
        KMBombModule bombModule = BombComponent.GetComponent <KMBombModule>();

        if (TwitchPlaySettings.data.EnforceSolveAllBeforeTurningKeys &&
            modulesAfter.Any(x => bombInfo.GetSolvedModuleNames().Count(x.Equals) != bombInfo.GetSolvableModuleNames().Count(x.Equals)))
        {
            bombModule.HandleStrike();
            return(false);
        }

        beforeKeyField.SetValue(null, TwitchPlaySettings.data.DisableTurnTheKeysSoftLock ? new string[0] : modulesBefore);
        onKeyTurn.Invoke(BombComponent.GetComponent(_componentType), null);
        if (GetValue(keyTurned))
        {
            //Check to see if any forbidden modules for this key were solved.
            if (TwitchPlaySettings.data.DisableTurnTheKeysSoftLock && bombInfo.GetSolvedModuleNames().Any(modulesBefore.Contains))
            {
                bombModule.HandleStrike();  //If so, Award a strike for it.
            }
            if (GetValue(otherKeyTurned))
            {
                int modules = bombInfo.GetSolvedModuleNames().Count(x => RightAfterA.Contains(x) || LeftAfterA.Contains(x));
                TwitchPlaySettings.AddRewardBonus(2 * modules);
                IRCConnection.SendMessage("Reward increased by {0} for defusing module !{1} ({2}).", modules * 2, Code, bombModule.ModuleDisplayName);
            }
        }
        return(false);
    }
コード例 #23
0
 void HandleScreenPressLabeled(int idx)
 {
     if (idx < 0 || idx >= 4)
     {
         return;
     }
     if (!currentButtonPressOrder.Contains(idx))
     {
         currentButtonPressOrder.Add(idx);
         displayedMeshes[idx].text = (currentButtonPressOrder.IndexOf(idx) + 1).ToString();
     }
     if (currentButtonPressOrder.Count >= correctButtonPressOrder.Count)
     {
         QuickLog(string.Format("Attempting to submit the screen presses in this order from top to bottom: {0}", currentButtonPressOrder.Select(a => (4 - a).ToString()).Join()));
         if (currentButtonPressOrder.SequenceEqual(correctButtonPressOrder))
         {
             QuickLog(string.Format("That seems right. Module disarmed."));
             mAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
             modSolved = true;
             modSelf.HandlePass();
             StartCoroutine(HandleDisarmAnim());
             interactable = false;
         }
         else
         {
             QuickLog(string.Format("That doesn't seems right. Strike incurred."));
             modSelf.HandleStrike();
             StartCoroutine(HandleStrikeAnimLabeled());
         }
     }
 }
コード例 #24
0
    void OnPress(int buttonID)
    {
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, buttons[buttonID].transform);
        buttons[buttonID].AddInteractionPunch();

        if (!isActivated)
        {
            Debug.LogFormat("[MonsplodeFight #{0}] Pressed button before module has been activated!", _moduleId);
            return;
        }
        Debug.LogFormat("[MonsplodeFight #{0}] Opponent: {1}, using Move {2}: {3}", _moduleId, CD.names[crID], buttonID, MD.names[moveIDs[buttonID]].Replace('\n', ' '));

        if (MD.specials[moveIDs[buttonID]] == "BOOM" && CD.specials[crID] != "DOC")
        {
            while (!exploded)
            {
                Module.HandleStrike();
                strikesToExplosion++;
            }
            //BOOM!
            Debug.LogFormat("[MonsplodeFight #{0}] Pressed BOOM!", _moduleId);
        }

        float      mxdmg   = -100;
        List <int> winners = new List <int>();

        for (int i = 0; i < 4; i++)
        {
            //buttons [i].GetComponentInChildren<TextMesh>().text=MD.names[moveIDs[i]];
            float dmg = CalcDmg(moveIDs[i], crID, i);

            if (CD.specials[crID] == "LOWEST")
            {
                Debug.LogFormat("[MonsplodeFight #{0}] Negate the calculated number for Cutie Pie calculation.", _moduleId);
                dmg = -dmg;
            }
            if (dmg > mxdmg)
            {
                mxdmg = dmg;
                winners.Clear();
                winners.Add(i);
            }
            else if (dmg == mxdmg)
            {
                winners.Add(i);
            }
            Debug.LogFormat("[MonsplodeFight #{0}] Move name({1}): {2} | Calculated damage: {3}", _moduleId, i, MD.names[moveIDs[i]].Replace('\n', ' '), dmg);
        }

        if (winners.Contains(buttonID))
        {
            GetComponent <KMAudio>().PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, buttons[buttonID].transform);
            Correct();
        }
        else
        {
            Wrong();
        }
    }
コード例 #25
0
    private bool HolePress()
    {
        if (_isSolved)
        {
            return(false);
        }
        if (_info.UnlinkedModules.Contains(this))
        {
            var cont = Instantiate(ContainerTemplate);
            cont.transform.parent     = SwirlContainer.parent;
            cont.transform.localScale = new Vector3(_planetSize, _planetSize, _planetSize);
            cont.gameObject.SetActive(true);

            var tm = Instantiate(TextTemplate);
            tm.text                    = _info.SolutionCode[_info.DigitsEntered].ToString();
            tm.color                   = _colors[_digitsEntered];
            tm.transform.parent        = cont.transform;
            tm.transform.localPosition = new Vector3(0, 0, 0);
            tm.transform.localRotation = Quaternion.identity;
            tm.transform.localScale    = new Vector3(.07f / _planetSize, .125f / _planetSize, .125f / _planetSize);
            tm.gameObject.SetActive(true);

            cont.transform.parent           = Selectable.transform;
            cont.transform.localPosition    = new Vector3(0f, 0f, 0f);
            cont.transform.localEulerAngles = new Vector3(0f, 0f, Rnd.Range(0f, 360f));

            Debug.LogFormat("[White Hole #{0}] Obtained a number: {1}", _moduleId, _info.SolutionCode[_info.DigitsEntered]);
            _info.LastDigitEntered = this;

            StartCoroutine(NumberOut(cont, false));
            _info.DigitsEntered++;
            _digitsEntered++;
            if (_digitsEntered >= _digitsExpected)
            {
                Debug.LogFormat("[White Hole #{0}] Module solved!", _moduleId);
                _isSolved = true;
                Module.HandlePass();
            }
        }
        else
        {
            if (_digitsEntered + 1 > _digitsExpected)
            {
                Debug.LogFormat("[White Hole {0}] Module solved! Inputs now disabled.", _moduleId);
                _isSolved = true;
                Module.HandlePass();
            }
            else
            {
                Debug.LogFormat("[White Hole {0}] I struck, as not enough directions have been entered.", _moduleId);
                if (!_SuppressStrikes)
                {
                    Module.HandleStrike();
                }
            }
        }
        return(false);
    }
コード例 #26
0
    void ButtonPress(int Press)
    {
        Audio.PlaySoundAtTransform(SFX[0].name, transform);
        Buttons[Press].GetComponent <KMSelectable>().AddInteractionPunch(0.2f);
        if (!ModuleSolved && Interactable)
        {
            if (Press == 0 && !Maze[StartingPoint[0]][StartingPoint[1]].Contains('N'))
            {
                StartingPoint[0]--;
                Debug.LogFormat("[Saimoe Maze #{0}] You moved up. Your current position is: {1}-{2}", moduleId, (StartingPoint[0] + 1).ToString(), (StartingPoint[1] + 1).ToString());
            }

            else if (Press == 1 && !Maze[StartingPoint[0]][StartingPoint[1]].Contains('E'))
            {
                StartingPoint[1]++;
                Debug.LogFormat("[Saimoe Maze #{0}] You moved right. Your current position is: {1}-{2}", moduleId, (StartingPoint[0] + 1).ToString(), (StartingPoint[1] + 1).ToString());
            }

            else if (Press == 2 && !Maze[StartingPoint[0]][StartingPoint[1]].Contains('S'))
            {
                StartingPoint[0]++;
                Debug.LogFormat("[Saimoe Maze #{0}] You moved down. Your current position is: {1}-{2}", moduleId, (StartingPoint[0] + 1).ToString(), (StartingPoint[1] + 1).ToString());
            }

            else if (Press == 3 && !Maze[StartingPoint[0]][StartingPoint[1]].Contains('W'))
            {
                StartingPoint[1]--;
                Debug.LogFormat("[Saimoe Maze #{0}] You moved left. Your current position is: {1}-{2}", moduleId, (StartingPoint[0] + 1).ToString(), (StartingPoint[1] + 1).ToString());
            }

            else
            {
                Module.HandleStrike();
                switch (Press)
                {
                case 0:
                    Debug.LogFormat("[Saimoe Maze #{0}] You tried to move up. Your were unable to do that. Module striked.", moduleId);
                    break;

                case 1:
                    Debug.LogFormat("[Saimoe Maze #{0}] You tried to move right. Your were unable to do that. Module striked.", moduleId);
                    break;

                case 2:
                    Debug.LogFormat("[Saimoe Maze #{0}] You tried to move down. Your were unable to do that. Module striked.", moduleId);
                    break;

                case 3:
                    Debug.LogFormat("[Saimoe Maze #{0}] You tried to move left. Your were unable to do that. Module striked.", moduleId);
                    break;

                default:
                    break;
                }
            }
        }
    }
    private void OnSubmitButtonPressed()
    {
        if (solved || !activated)
        {
            return;
        }
        Unselect();
        Debug.LogFormat("[Starmap Reconstruction #{0}] Submit pressed", moduleId);
        Starmap map = new Starmap(stars.Length);

        foreach (StarComponent star in stars)
        {
            int expectedAdjacentsCount = StarmapReconstructionData.GetAdjacentStarsCount(star.Race, star.Regime, BombInfo);
            int actualAdjacentsCount   = star.connectedStars.Count;
            if (expectedAdjacentsCount != actualAdjacentsCount)
            {
                Debug.LogFormat("[Starmap Reconstruction #{0}] STRIKE: Star {1} has {2} connected stars. Expected: {3}", moduleId, star.Name, actualAdjacentsCount,
                                expectedAdjacentsCount);
                Module.HandleStrike();
                return;
            }
            foreach (StarComponent other in star.connectedStars)
            {
                map.Add(star.Id, other.Id);
            }
        }
        Debug.LogFormat("[Starmap Reconstruction #{0}] Submitted map: {1}", moduleId, map.ToShortString());
        foreach (StarComponent star in stars)
        {
            KeyValuePair <string, int>?requiredDistance = StarmapReconstructionData.GetRequiredDistanceFrom(star.Name);
            if (requiredDistance == null)
            {
                continue;
            }
            string to = requiredDistance.Value.Key;
            int    expectedDistance = requiredDistance.Value.Value;
            int    otherIndex       = stars.IndexOf(s => s.Name == to);
            if (otherIndex < 0)
            {
                continue;
            }
            StarComponent other          = stars[otherIndex];
            int           actualDistance = map.GetDistance(star.Id, other.Id);
            if (expectedDistance != actualDistance)
            {
                Debug.LogFormat("[Starmap Reconstruction #{0}] STRIKE: Distance from {1} to {2} is {3}. Expected: {4}", moduleId, star.Name, other.Name, actualDistance,
                                expectedDistance);
                Module.HandleStrike();
                return;
            }
        }
        Debug.LogFormat("[Starmap Reconstruction #{0}] Module solved", moduleId);
        solved = true;
        Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
        Module.HandlePass();
    }
コード例 #28
0
    private bool OnCellInteract(PaintingCell cell)
    {
        if (!_activeColor.HasValue)
        {
            _bombModule.LogFormat("Tried to paint {0} with no palette color!", cell.name);
            return(true);
        }

        if (!cell.FinalColorOption.HasValue)
        {
            if (_activeColor != cell.ColorOption)
            {
                cell.ColorOption      = _activeColor.Value;
                cell.FinalColorOption = cell.ColorOption;
                _bombModule.LogFormat("Painting {0} with {1}.", cell.name, _activeColor.Value);
            }
            else
            {
                _bombModule.LogFormat("Tried to paint {0}, but that cell is already complete.", cell.name);
                _bombModule.HandleStrike();
            }

            if (IsAllSolved())
            {
                _bombModule.Log("All cells are now at a final color.");
                _bombModule.HandlePass();
            }

            return(true);
        }

        if (cell.ColorOption == cell.FinalColorOption)
        {
            _bombModule.LogFormat("Tried to paint {0}, but that cell is already complete.", cell.name);
            _bombModule.HandleStrike();
            return(true);
        }

        if (_activeColor.Value != cell.FinalColorOption)
        {
            _bombModule.LogFormat("Tried to paint {0} with {1}, but that's not the correct final color; expected {2}.", cell.name, _activeColor.Value, cell.FinalColorOption);
            _bombModule.HandleStrike();
            return(true);
        }

        _bombModule.LogFormat("Painting {0} with {1}.", cell.name, _activeColor.Value);
        cell.ColorOption = _activeColor.Value;

        if (IsAllSolved())
        {
            _bombModule.Log("All cells are now at their final color.");
            _bombModule.HandlePass();
        }

        return(true);
    }
コード例 #29
0
 private KMSelectable.OnInteractHandler Round1Strike(int btnIx, int hierIx)
 {
     return(delegate
     {
         EgyptianHieroglyphButtons[btnIx].AddInteractionPunch(1f);
         Debug.LogFormat(@"[Only Connect #{0}] {1} was the wrong Egyptian hieroglyph. Strike.", _moduleId, _hieroglyphs[hierIx]);
         Module.HandleStrike();
         return false;
     });
 }
コード例 #30
0
 void ButtonPress()
 {
     if (!Solved)
     {
         if (FreeInteract)
         {
             FreeInteract = false;
         }
         else
         {
             if (Stage == 0)
             {
                 if (((int)Bomb.GetTime() % 60) % 10 == Bomb.GetSolvedModuleNames().Count() % 10)
                 {
                     Debug.LogFormat("[Tell Me Why #{0}] The button was held when the last digit of the bomb's timer was {1} while the bomb had {2} solved module(s), which was correct. Onto the first stage!", _moduleID, ((int)Bomb.GetTime() % 60) % 10, Bomb.GetSolvedModuleNames().Count());
                     Stage++;
                     GenSequence();
                 }
                 else
                 {
                     Debug.LogFormat("[Tell Me Why #{0}] The button was held when the last digit of the bomb's timer was {1} while the bomb had {2} solved module(s), which was incorrect. Strike!", _moduleID, ((int)Bomb.GetTime() % 60) % 10, Bomb.GetSolvedModuleNames().Count());
                     Module.HandleStrike();
                     Audio.PlaySoundAtTransform("buzzer", Button.transform);
                     FreeInteract = true;
                 }
             }
             else
             {
                 if (!Solved)
                 {
                     if (DigitalRoot(Sequence.Sum() + EdgeworkModifier) % 5 == CurrentNum)
                     {
                         Debug.LogFormat("[Tell Me Why #{0}] The button was held when the number in position {1} in the sequence was displayed, which was correct.", _moduleID, CurrentNum + 1);
                         Stage++;
                         GenSequence();
                     }
                     else
                     {
                         if (CurrentNum == 5)
                         {
                             Debug.LogFormat("[Tell Me Why #{0}] The button was held when the display was empty, which was (obviously) incorrect. Strike!", _moduleID, CurrentNum + 1);
                         }
                         else
                         {
                             Debug.LogFormat("[Tell Me Why #{0}] The button was held when the number in position {1} in the sequence was displayed, which was incorrect. Strike!", _moduleID, CurrentNum + 1);
                         }
                         Module.HandleStrike();
                         Audio.PlaySoundAtTransform("buzzer", Button.transform);
                         FreeInteract = true;
                     }
                 }
             }
         }
     }
 }