private void PressPlay()
 {
     if (scare == 0)
     {
         if (Activated <= 1)
         {
             Needy.HandlePass();
             _isSolved = true;
             GetComponent <KMSelectable>().AddInteractionPunch();
             emojiSprite = 0;
             EmojiShow.GetComponent <MeshRenderer>().material = Emoji[emojiSprite];
         }
         else
         {
             GetComponent <KMSelectable>().AddInteractionPunch();
         }
     }
     else
     {
         emojiSprite = 2;
         EmojiShow.GetComponent <MeshRenderer>().material = Emoji[emojiSprite];
         Needy.HandlePass();
         _isSolved = true;
         GetComponent <KMSelectable>().AddInteractionPunch();
     }
 }
 private IEnumerator ButtonPress(int pos)
 {
     Audio.PlaySoundAtTransform("press", Keys[pos].transform);
     Keys[pos].AddInteractionPunch();
     for (int i = 0; i < 3; i++)
     {
         Keys[pos].transform.localPosition -= new Vector3(0, 0.0025f, 0);
         yield return(new WaitForSeconds(0.01f));
     }
     if (!Deactivated)
     {
         if (pos == SelectedLyric)
         {
             Module.HandlePass();
         }
         else
         {
             Module.HandleStrike();
             Module.HandlePass();
         }
         Text.text   = "";
         Deactivated = true;
     }
     for (int i = 0; i < 3; i++)
     {
         Keys[pos].transform.localPosition += new Vector3(0, 0.0025f, 0);
         yield return(new WaitForSeconds(0.01f));
     }
 }
    public static void DeactivateNeedyModule(TwitchComponentHandle handle)
    {
        handle.ircConnection.SendMessage(TwitchPlaySettings.data.UnsupportedNeedyWarning);
        KMNeedyModule needyModule = handle.bombComponent.GetComponent <KMNeedyModule>();

        needyModule.OnNeedyActivation   = () => { needyModule.StartCoroutine(KeepUnsupportedNeedySilent(needyModule)); };
        needyModule.OnNeedyDeactivation = () => { needyModule.StopAllCoroutines(); needyModule.HandlePass(); };
        needyModule.OnTimerExpired      = () => { needyModule.StopAllCoroutines(); needyModule.HandlePass(); };
        needyModule.WarnAtFiveSeconds   = false;
    }
    // Use this for initialization
    void Start()
    {
        moduleId = moduleIdCounter++;

        textDisplay.text      = "";
        needySelf.OnActivate += delegate { hasStarted = true; };

        needySelf.OnNeedyActivation += delegate {
            if (forceDisable)
            {
                needySelf.HandlePass();
            }
            else
            {
                AssignValue();
            }
        };

        needySelf.OnTimerExpired += delegate {
            QuickLog("Letting the needy timer run out is not a good idea after all.");
            currentStreak = 0;
            needySelf.SetResetDelayTime(15 + 5 * currentStreak, 45 + 10 * currentStreak); // Modify reactivation time based on the streak the module is on.
            needySelf.HandleStrike();
            isActive = false;
        };

        for (int x = 0; x < arrowButtons.Length; x++)
        {
            int y = x;
            arrowButtons[x].OnInteract += delegate {
                if (isActive && !isanimating)
                {
                    MAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, arrowButtons[y].transform);
                    arrowButtons[y].AddInteractionPunch();
                    CheckAnswer(y);
                }
                return(false);
            };
        }

        needySelf.OnNeedyDeactivation += delegate
        {
            StartCoroutine(victory());
            hasStarted = false;
        };

        bombInfo.OnBombSolved += delegate {
            StartCoroutine(victory());
            hasStarted = false;
        };

        StartCoroutine(DelayRotation());
    }
示例#5
0
 // Use this for initialization
 void Start()
 {
     needyModule.OnTimerExpired += delegate() {
         if (canRun)
         {
             localstrike = true;
             Debug.LogFormat("[Time Accumulation #{0}]: Don't let this run out of time! Strike incurred.", localModID);
             needyModule.HandleStrike();
         }
     };
     selectDisable.OnInteract += delegate() {
         int curneedTime = Mathf.RoundToInt(needyModule.GetNeedyTimeRemaining());
         if (curneedTime >= 0)
         {
             value += curneedTime;
             needyModule.HandlePass();
             Debug.LogFormat("[Time Accumulation #{0}]: Adding {1} onto the counter. Counter currently at {2}.", localModID, curneedTime, value);
         }
         audioKTANE.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonPress, transform);
         forwardsAnim = true;
         return(false);
     };
     needyModule.OnNeedyActivation += delegate()
     {
         if (!canRun)
         {
             needyModule.HandlePass();
         }
     };
     needyModule.OnActivate += delegate() {
         isInTimeMode    = TimeModeActive;
         canRun          = true;
         isLightsFirstOn = true;
         if (isInTimeMode)
         {
             Debug.LogFormat("[Time Accumulation #{0}]: Module detected in Time Mode, disabling strike count for this module...", localModID);
         }
     };
     selectDisable.OnInteractEnded += delegate()
     {
         forwardsAnim = false;
         audioKTANE.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.BigButtonRelease, transform);
     };
     bombInfo.OnBombExploded += delegate()
     {
         canRun = false;
     };
     bombInfo.OnBombSolved += delegate()
     {
         canRun = false;
     };
 }
示例#6
0
    IEnumerator HandleNeedyCleanup(bool timedOut)
    {
        bombModule.HandlePass();
        isLive = false;

        mainScreen.text = "";
        if (!timedOut)         // Delayed sound effect start
        {
            yield return(new WaitForSeconds(1f));
        }

        bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.WireSequenceMechanism, bombModule.transform);
        yield break;
    }
 private void Hatt()
 {
     if (Activated <= 1)
     {
         Needy.HandlePass();
         _isSolved = true;
         GetComponent <KMSelectable>().AddInteractionPunch();
         Activated = 54;
         Invoke("OnNeedyDeactivation", 0.7f);
     }
     else
     {
         GetComponent <KMSelectable>().AddInteractionPunch();
     }
 }
示例#8
0
 private void PressPlay()
 {
     if (Activated <= 1)
     {
         Needy.HandlePass();
         _isSolved = true;
         GetComponent <KMSelectable>().AddInteractionPunch();
         audio.PlaySoundAtTransform("insult", transform);
         Activated = 54;
         Invoke("Play", 1.7f);
     }
     else
     {
         GetComponent <KMSelectable>().AddInteractionPunch();
     }
 }
    private bool HandleButtons(int arg1)
    {
        Buttons[arg1].Button(Audio, Buttons[arg1].transform, 0.8f, gameSound: KMSoundOverride.SoundEffect.ButtonPress);

        if (!IsNeedyActive)
        {
            return(false);
        }

        IsNeedyActive = false;

        if ((TextColor)arg1 == solution)
        {
            this.Log("Pressed the {0} button. Needy disarmed.".Form((TextColor)arg1));
            Needy.HandlePass();
        }
        else
        {
            this.Log("Pressed the {0} button. Strike.".Form((TextColor)arg1));
            Needy.HandleStrike();
        }

        OnNeedyDeactivation().Invoke();

        return(false);
    }
    void ApplyTetromino()
    {
        if (tetr != null)
        {
            List <IntPair> list = tetr.GetTileCoordinates();
            if (tetr.isValid())
            {
                foreach (IntPair p in list)
                {
                    GameBoard.set(p.x, p.y, 1);
                }

                List <int> rows = GameBoard.getCompletedRows();
                if (rows.Count > 0)
                {
                    GameBoard.deleteRows(rows);
                }

                piecesLeft--;
                if (piecesLeft > 0)
                {
                    tetr = new Tetromino(G_WIDTH, GameBoard);
                }
                else
                {
                    NeedyModule.HandlePass();
                    tetr = null;
                }
                UpdateGrid();
            }
        }
    }
示例#11
0
    // Use this for initialization
    void Start()
    {
        textnumber.text = "Not FizzBuzz.";

        needyModule.OnNeedyActivation += delegate()
        {
            if (forceDisable)
            {
                needyModule.HandlePass();
                return;
            }

            targetnumber    = Random.Range(0, int.MaxValue);
            textnumber.text = targetnumber.ToString();

            goalVal += targetnumber % 3 == 0 ? 1 : 0;
            goalVal += targetnumber % 5 == 0 ? 2 : 0;
        };

        needyModule.OnTimerExpired += delegate()
        {
            if (poslist[rotatePos % poslist.Length] != goalVal)
            {
                needyModule.HandleStrike();
                Debug.LogFormat("[BuzzFizz #{0}]: \"{2}\" was expected but \"{3}\" was set for {1}.", cmodID, targetnumber, conText[goalVal], conText[poslist[rotatePos % 4]]);
            }
            goalVal   = 0;
            iswarning = false;
        };
        needyModule.OnNeedyDeactivation += delegate()
        {
            textnumber.color = Color.white;
            iswarning        = false;
        };
        needyModule.OnActivate += delegate()
        {
            textnumber.text  = "Pending...";
            textnumber.color = Color.white;
        };
        dialSelect.OnInteract += delegate()
        {
            dial.transform.Rotate(new Vector3(0, 90, 0));
            rotatePos = (rotatePos + 1) % 4;
            return(false);
        };
    }
 void HandlePress(int button)
 {
     KMAudio.PlaySoundAtTransform("tick", this.transform);
     Buttons[button].AddInteractionPunch();
     if (!canPressButtons)
     {
     }
     else if (canPressButtons && button == Questions[CurrentQuestion].CorrectButton)
     {
         CurrentQuestion++;
         DisplayCorrect();
         if (CurrentQuestion >= MaxQuestions)
         {
             BombModule.HandlePass();
             Debug.LogFormat("[Edgework #{0}] Button {1} pressed correctly! Module Passed.", moduleId, button + 1);
             Invoke("ClearDisplays", 0.75f);
         }
         else
         {
             Debug.LogFormat("[Edgework #{0}] Button {1} pressed correctly!", moduleId, button + 1);
             Invoke("ResetDisplays", 0.75f);
         }
     }
     else if (canPressButtons && button == 1 && Questions[CurrentQuestion].Buttons[1] == "")
     {
     }
     else if (canPressButtons)
     {
         BombModule.HandleStrike();
         strikeOccurred = true;
         DisplayIncorrect();
         canPressButtons = false;
         Debug.LogFormat("[Edgework #{0}] Button {1} pressed incorrectly!", moduleId, button + 1);
         BombModule.HandlePass();
         Invoke("ClearDisplays", 1.25f);
     }
     else
     {
         Debug.LogFormat("[Edgework #{0}] ERROR!", moduleId, button + 1);
         BombModule.HandleStrike();
         strikeOccurred = true;
         BombModule.HandlePass();
     }
 }
示例#13
0
    private void StopEverything()
    {
        if (BombModule != null)
        {
            BombModule.HandlePass();
        }

        if (NeedyModule != null)
        {
            NeedyModule.HandlePass();
            NeedyModule.OnNeedyActivation   = null;
            NeedyModule.OnNeedyDeactivation = null;
            NeedyModule.OnTimerExpired      = null;
        }

        foreach (MonoBehaviour monoBehaviour in Module.GetComponentsInChildren <MonoBehaviour>(true))
        {
            monoBehaviour.StopAllCoroutines();
        }
    }
示例#14
0
 /// <summary>
 /// Handle the success or failure of the module
 /// </summary>
 /// <param name="index">The index of the button pressed</param>
 /// <param name="strike">Whether or not a strike should be given (true by default)</param>
 private void StrikeHandler(int index, bool strike = true)
 {
     if (strike)
     {
         needyModule.HandleStrike();
         Debug.LogFormat(@"[Triangle Buttons #{0}] {1} button has been pushed and is incorrect. Strike occurred, module deactivated.", moduleId, buttonLocations[index]);
     }
     else
     {
         Debug.LogFormat(@"[Triangle Buttons #{0}] {1} button has been pushed and is correct. Module deactivated.", moduleId, buttonLocations[index]);
     }
     needyModule.HandlePass();
 }
 void OnTimerExpired()
 {
     if (answer != 4)
     {
         needyModule.HandleStrike();
         texts[0].text = "Common Sense";
         texts[1].text = "-";
         texts[2].text = "-";
         theBack.GetComponent <MeshRenderer>().material = mats[0];
         texts[0].color = colors[6];
         Debug.LogFormat("[Common Sense #{0}] You didn't input your response in time.", moduleId);
         moduleSolved = true;
     }
     else
     {
         needyModule.HandlePass();
         Debug.LogFormat("[Common Sense #{0}] You selected the correct answer. Pass.", moduleId);
     }
 }
示例#16
0
 void buttonPress(KMSelectable button)
 {
     if (moduleSolved == false)
     {
         if ((button == buttons[0]) && (selectedphoto < 10))
         {
             Needy.HandlePass();
         }
         else if ((button == buttons[1]) && (selectedphoto > 9 && selectedphoto < 20))
         {
             Needy.HandlePass();
         }
         else if ((button == buttons[2]) && (selectedphoto > 19))
         {
             Needy.HandlePass();
         }
         else
         {
             Needy.HandleStrike();
             Needy.HandlePass();
         }
     }
 }
示例#17
0
    void OnTimerExpired()
    {
        Button_enabler.SetActive(false);
        if (Flower_Color == Flower_Answer)
        {
            Needy.HandlePass();
        }
        else
        {
            Needy.HandleStrike();

            Debug.LogFormat("You submitted the wrong color, it was {0} but you submitted {1}", LogRelatedThingy[Flower_Answer], LogRelatedThingy[Flower_Color]);
        }
    }
示例#18
0
 private IEnumerator ButtonPress()
 {
     Button.AddInteractionPunch();
     for (int i = 0; i < 3; i++)
     {
         Button.transform.localPosition -= new Vector3(0, 0.005f, 0);
         yield return(new WaitForSeconds(0.01f));
     }
     Audio.PlaySoundAtTransform("press", Button.transform);
     Module.HandlePass();
     for (int i = 0; i < 3; i++)
     {
         Button.transform.localPosition += new Vector3(0, 0.005f, 0);
         yield return(new WaitForSeconds(0.01f));
     }
 }
示例#19
0
 private void Outtatime()
 {
     active = false;
     if (state.SequenceEqual(target))
     {
         needy.HandlePass();
     }
     else
     {
         needy.HandleStrike();
     }
     foreach (Renderer t in tilerends)
     {
         t.material = mats[0];
     }
 }
 private void TimerExpired()
 {
     if (_bomb.HoldState == FloatingHoldable.HoldStateEnum.Held)
     {
         _module.HandleStrike();
         Debug.LogFormat("[Hot Potato #{0}] Bomb not dropped in time, strike!", _moduleId);
     }
     else
     {
         _module.HandlePass();
         Debug.LogFormat("[Hot Potato #{0}] Bomb dropped in time.", _moduleId);
     }
     if (TwitchPlaysActive)
     {
         StopCoroutine(_TextU);
     }
     _textMesh.text = string.Empty;
 }
 private KMSelectable.OnInteractHandler Press(int pos)
 {
     return(delegate
     {
         if (active)
         {
             Buttons[pos].AddInteractionPunch();
             if (solution == pos)
             {
                 Audio.PlaySoundAtTransform("Poggers", Module.transform);
                 solved = true;
             }
             OnNeedyDeactivation();
             Module.HandlePass();
         }
         return false;
     });
 }
 private void Heard(PhraseRecognizedEventArgs speech)
 {
     Debug.LogFormat("<Crazy Speak #{0}> Heard \"{1}\".", _id, speech.text);
     if (actions.Select(x => speech.text.ToLowerInvariant().RegexMatch(x.Key) ? x.Value.i : 0).Where(x => x == lookingFor).FirstOrDefault() != 0)
     {
         Module.HandlePass();
         Audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
         if (state)
         {
             micOn--;
             if (micOn == 0)
             {
                 mic.Stop();
             }
             state = false;
         }
         Text.text = "";
         Debug.LogFormat("[Crazy Speak #{0}] Needy solved.", _id);
     }
 }
示例#23
0
    void ButtonPress(KMSelectable button)
    {
        button.AddInteractionPunch(.5f);
        audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, button.transform);
        if (!active)
        {
            return;
        }
        var ix = Array.IndexOf(buttons, button);

        Debug.LogFormat("[Llama, Llama, Alpaca #{0}] Selected: {1}", moduleId, button.GetComponentInChildren <TextMesh>().text);
        if (ix != solution)
        {
            Debug.LogFormat("[Llama, Llama, Alpaca #{0}] That was not correct. Strike!", moduleId);
            module.HandleStrike();
        }
        else
        {
            Debug.LogFormat("[Llama, Llama, Alpaca #{0}] That was correct. Module passed.", moduleId);
            module.HandlePass();
        }
        OnNeedyDeactivation();
    }
 void keyPressed(KMSelectable pressedKey)
 {
     if (active)
     {
         Debug.Log("pressedKey");
         audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, transform);
         if (pressedKey.GetComponentInChildren <TextMesh>().text == letters[currentInt])
         {
             currentInt++;
         }
         else
         {
             OnTimerExpired();
             currentInt = 0;
             audio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.Strike, transform);
         }
         if (currentInt == 4)
         {
             currentInt = 0;
             needy.HandlePass();
         }
     }
 }
示例#25
0
    private bool HandleButtons(int arg1)
    {
        Buttons[arg1].Button(Audio, Buttons[arg1].transform, 0.8f, gameSound: KMSoundOverride.SoundEffect.ButtonPress);

        if (!IsNeedyActive)
        {
            return(false);
        }

        IsNeedyActive = false;

        if ((TextColor)arg1 == _solution)
        {
            Needy.HandlePass();
        }
        else
        {
            Needy.HandleStrike();
        }

        OnNeedyDeactivation().Invoke();

        return(false);
    }
示例#26
0
 private void passNeedy()
 {
     module.HandlePass();
     isActivated = false;
 }
示例#27
0
    // Use this for initialization
    void Start()
    {
        modID = modIdCounter++;
        needySelf.OnNeedyActivation += delegate
        {
            if (!permDeactivate)
            {
                isActive    = true;
                blockLifter = HandleHeightManagment();
                timeManager = ModifyNeedyTimer();
                StartCoroutine(blockLifter);
                StartCoroutine(timeManager);
                interactable = true;
            }
            else
            {
                needySelf.HandlePass();
            }
        };
        allSelectablesDefault         = new List <KMSelectable>(); // Mainly for compacting lines, required for usage otherwise.
        allSelectablesDuringAnimation = new List <KMSelectable>();
        for (int i = 0; i < rowRenderersWithSelectables.Length; i++)
        {
            RowRendererPlus rowRenderer = rowRenderersWithSelectables[i];
            allSelectablesDefault.AddRange(rowRenderer.rowSelectables);
            if (i != 14)
            {
                allSelectablesDuringAnimation.AddRange(rowRenderer.rowSelectables);
            }
            startRowCoords.Add(rowRenderer.transform.localPosition);

            for (int x = 0; x < rowRenderer.rowSelectables.Length; x++)
            {
                int tRow = x, tCol = i;
                rowRenderer.rowSelectables[x].OnInteract += delegate {
                    rowRenderer.rowSelectables[tRow].AddInteractionPunch(0.1f);
                    mAudio.PlaySoundAtTransform("tick", rowRenderer.rowSelectables[tRow].transform);
                    if (isActive && interactable)
                    {
                        ProcessTile(tRow, tCol);
                    }
                    return(false);
                };
            }
        }
        bombInfo.OnBombExploded += delegate {
            if (!permDeactivate)
            {
                QuickLog("Board upon detonation: ");
                LogBoard();
            }
        };

        modSelfSelectable.Children = allSelectablesDefault.ToArray();
        modSelfSelectable.UpdateChildren(); // Required for gamepad usage and updating.
        StartCoroutine(delayRotation());
        needySelf.OnNeedyDeactivation += delegate {
            isActive = false;
            if (!permDeactivate)
            {
                QuickLog("Board upon deactivation: ");
                LogBoard();
            }
        };
        UpdateGrid();
        rowRenderersNextSet.transform.localPosition = new Vector3(0, 0, -6.5f);
        rowRenderersNextSet.transform.localScale    = new Vector3(1, 1, 0);
        rowRenderersNextSet.gameObject.SetActive(false);
        colorIdxSet.Shuffle();
    }
    // Use this for initialization
    void Start()
    {
        needyModule.OnNeedyActivation += delegate
        {
            if (forceDisable)
            {
                needyModule.HandlePass();
                return;
            }
            isActive = true;
            List <int> tempSegmentsID = segmentIDs.ToList();
            curSegmentPos.Clear();
            while (tempSegmentsID.Count > 0)
            {
                int valueToAdd = tempSegmentsID[Random.Range(0, tempSegmentsID.Count)];
                curSegmentPos.Add(valueToAdd);
                tempSegmentsID.Remove(valueToAdd);
            }
            UpdateSegments();
            Debug.LogFormat("[Faulty Seven Segment Display #{0}]: The set of the seven segments scrambled for {1} needy activation(s) are:", curModID, activationCount);
            LogSegments(curSegmentPos.ToArray());
            TPDetected = TwitchPlaysActive;
            if (TPDetected)
            {
                needyModule.SetNeedyTimeRemaining(needyModule.GetNeedyTimeRemaining() * 2);
            }
        };
        needyModule.OnNeedyDeactivation += delegate
        {
            isActive = false;
        };
        needyModule.OnTimerExpired += delegate
        {
            isActive = false;
            Debug.LogFormat("[Faulty Seven Segment Display #{0}]: The current set of the seven segments when the time ran out for {1} needy activation(s):", curModID, activationCount++);
            LogSegments(curSegmentPos.ToArray());
            if (!curSegmentPos.SequenceEqual(segmentIDs.ToList()))
            {
                needyModule.HandleStrike();
                needyModule.SetResetDelayTime(15f, 40f);
            }
            else
            {
                needyModule.SetResetDelayTime(60f, 160f);
            }
        };
        foreach (GameObject objCom in segmentObjects)
        {
            localPosSeg.Add(objCom.transform.localPosition);
            localRotSeg.Add(objCom.transform.localEulerAngles);
        }
        for (int x = 0; x < segmentSelectables.Length; x++)
        {
            int temp = x;
            segmentSelectables[x].OnInteract += delegate
            {
                segmentSelectables[temp].AddInteractionPunch();
                audioSelf.PlaySoundAtTransform("tick", transform);
                if (curSegmentPos.Count > 0)
                {
                    bool isSelected  = false;
                    int  idxSelected = -1;
                    for (int u = 0; u < segmentSelectables.Length; u++)
                    {
                        var selectable = segmentSelectables[u];
                        if (selectable.Highlight.GetComponent <MeshRenderer>().enabled)
                        {
                            isSelected  = true;
                            idxSelected = u;
                        }
                    }
                    if (!isSelected)
                    {
                        segmentSelectables[temp].Highlight.GetComponent <MeshRenderer>().enabled = true;
                    }
                    else
                    {
                        SwapSegments(temp, idxSelected);
                        foreach (KMSelectable selectable in segmentSelectables)
                        {
                            selectable.Highlight.GetComponent <MeshRenderer>().enabled = false;
                        }
                    }
                }
                return(false);
            };
        }

        curModID = modID++;
        Debug.LogFormat("[Faulty Seven Segment Display #{0}]: The correct set of the seven segments are logged as the following:", curModID);
        LogSegments();
    }
    void Awake()
    {
        needySelf.OnActivate += delegate()
        {
            mustInvert = bombInfo.GetSerialNumberNumbers().ToList().Count > 0 ? bombInfo.GetSerialNumberNumbers().Last() % 2 != 0 : false;
            // If there is at least 1 number in the serial number, grab the last one and check if it's odd or even. Otherwise set it to false by default.
        };
        needySelf.OnNeedyActivation += delegate()
        {// Generate board with goal presses and mix up interactable board with lit/unilt tiles
            if (forceDisable)
            {
                needySelf.HandlePass();
                return;
            }
            hasActivated = true;
            bool[] choices = new bool[] { true, false };
            for (int pos = 0; pos < lightstate.Count(); pos++)
            {
                lightstate[pos] = choices[UnityEngine.Random.Range(0, choices.Count())];
            }

            for (int pos = 0; pos < goallights.Count(); pos++)
            {
                goallights[pos] = choices[UnityEngine.Random.Range(0, choices.Count())];
            }
        };
        needySelf.OnNeedyDeactivation += delegate() // If the module is force-deactivated
        {
            hasActivated = false;
            for (int x = 0; x < buttonColors.Count(); x++)
            {
                buttonColors[x].material = buttonDeactivated;
                lightKeys[x].enabled     = false;
            }
        };

        needySelf.OnTimerExpired += delegate()
        {
            StopCoroutine(FlashGoalOnWarning());
            isWarning = false;
            if (IsCorrect(lightstate))
            {
                sound.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.CorrectChime, transform);
                StartCoroutine(PlayCorrectAnim());
            }
            else
            {
                needySelf.HandleStrike();
                StartCoroutine(PlayStrikeAnim());
            }
            hasActivated = false;
        };
        for (int x = 0; x < buttons.Count(); x++)
        {
            int pos = x;
            buttonSelectables[pos].OnInteract += delegate()
            {
                if (!hasActivated)
                {
                    return(false);
                }
                buttonSelectables[pos].AddInteractionPunch(0.5f);
                sound.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease, transform);
                lightstate[pos] = !lightstate[pos];
                return(false);
            };
        }
    }
    // Use this for initialization
    void Start()
    {
        _moduleId++;

        _startmin = int.Parse(BombInfo.GetFormattedTime().Split(':').First());
        _startsec = int.Parse(BombInfo.GetFormattedTime().Split(':').Last());

        LogTheFile(string.Format("The bomb's starting time was {0} minutes and {1} seconds.", _startmin, _startsec));

        _questions = new List <ReversedEdgeworkQuestion>
        {
            new ReversedEdgeworkQuestion("# of INDs", BombInfo.GetIndicators().Count()),
            new ReversedEdgeworkQuestion("# of lit INDs", BombInfo.GetOnIndicators().Count()),
            new ReversedEdgeworkQuestion("# of off INDs", BombInfo.GetOffIndicators().Count()),
            new ReversedEdgeworkQuestion("# of ports", BombInfo.GetPortCount()),
            new ReversedEdgeworkQuestion("# of port p.s", BombInfo.GetPortPlateCount()),
            new ReversedEdgeworkQuestion("# of batts", BombInfo.GetBatteryCount()),
            new ReversedEdgeworkQuestion("# of D batts", BombInfo.GetBatteryCount(Battery.D)),
            new ReversedEdgeworkQuestion("# of AA batts", BombInfo.GetBatteryCount(Battery.AA)),
            new ReversedEdgeworkQuestion("# of batt hds", BombInfo.GetBatteryHolderCount()),
            new ReversedEdgeworkQuestion("First # of SN", BombInfo.GetSerialNumberNumbers().First()),
            new ReversedEdgeworkQuestion("Last # of SN", BombInfo.GetSerialNumberNumbers().Last()),
            new ReversedEdgeworkQuestion("# of mod", BombInfo.GetModuleNames().Count),
            new ReversedEdgeworkQuestion("# of r. mod", BombInfo.GetSolvableModuleNames().Count),
            new ReversedEdgeworkQuestion("# of n. mod",
                                         BombInfo.GetModuleNames().Count - BombInfo.GetSolvableModuleNames().Count),
            new ReversedEdgeworkQuestion("b. st. min", _startmin),
            new ReversedEdgeworkQuestion("b. st. sec", _startsec)
        };
        for (var i = 0; i < 4; ++i)
        {
            int index = i;
            Buttons[index].OnInteract += delegate
            {
                Buttons[index].AddInteractionPunch();
                ModuleAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonPress, Buttons[index].transform);
                if (!_active)
                {
                    return(false);
                }

                if (_mainQuestion.Answer != _assignedQuestions[index].Answer)
                {
                    _active = false;
                    foreach (var text in texts)
                    {
                        text.text = "";
                    }

                    screenText.text = "";
                    LogTheFile(string.Format("You pressed {0}({1}), which was wrong. Handling Strike and going to sleep.",
                                             _assignedQuestions[index].Question, _assignedQuestions[index].Answer.ToString()));
                    Module.HandleStrike();
                    Module.HandlePass();
                }
                else
                {
                    _active = false;
                    foreach (var text in texts)
                    {
                        text.text = "";
                    }

                    screenText.text = "";
                    Module.HandlePass();
                    LogTheFile("Correct button pressed, going to sleep.");
                }

                return(false);
            };
            Buttons[index].OnInteractEnded += delegate
            {
                ModuleAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.ButtonRelease,
                                                     Buttons[index].transform);
            };
        }

        Module.OnNeedyActivation   += GenerateQuestion;
        Module.OnNeedyDeactivation += delegate
        {
            _active = false;
            foreach (var text in texts)
            {
                text.text = "";
            }
            screenText.text = "";
        };
        Module.OnTimerExpired += delegate
        {
            foreach (var text in texts)
            {
                text.text = "";
            }

            screenText.text = "";
            LogTheFile("Timer expired, handling Strike");
            Module.HandleStrike();
        };
    }