Exemple #1
0
    private void WaitForSol()
    {
        canPress = false;
        var r = UnityEngine.Random.Range(0, 2);
        var k = new[] { Hot, Cold };

        coroutine = Spinning(k[r]);
        StartCoroutine(coroutine);
        if (c == 1)
        {
            DebugLog("Debug: Rotation error, reverse the inputs to disable.");
            curKnob         = 0;
            Hot.OnInteract  = delegate() { Required(true); return(false); };
            Cold.OnInteract = delegate() { Required(false); return(false); };
        }
        if (c == 2)
        {
            if (!processingInput)
            {
                DebugLog("Button not responding, please hold the button still to reorientate the button.");
            }
            else
            {
                Debug.LogFormat("<Faulty Sink #{0}> Rotation Rule 2 applied, but ignored by Twitch Plays.", moduleID);
            }
            wait                 = true;
            HotHandler           = Hot.OnInteract;
            ColdHandler          = Cold.OnInteract;
            coroutine2           = Timer();
            k[r].OnInteract      = delegate() { h = true; StartCoroutine(coroutine2); return(false); };
            k[r].OnInteractEnded = WaitForSelect();
        }
        if (c == 3)
        {
            DebugLog("Invalid button selected, please select a valid button.");
            HotHandler                = Hot.OnInteract;
            ColdHandler               = Cold.OnInteract;
            k[r].OnInteract           = delegate() { Module.HandleStrike(); processingInput = false; return(false); };
            k[(r + 1) % 2].OnInteract = delegate() { Fix(k[r]); return(false); };
        }
    }
Exemple #2
0
    private IEnumerable <object> ProcessBlockbusters(KMBombModule module)
    {
        var    comp          = GetComponent(module, "blockbustersScript");
        var    fldSolved     = GetField <bool>(comp, "moduleSolved");
        var    legalLetters  = GetListField <string>(comp, "legalLetters", isPublic: true).Get();
        var    tiles         = GetField <Array>(comp, "tiles", isPublic: true).Get(arr => arr.Cast <object>().Any(v => v == null) ? "contains null" : null);
        var    selectables   = new KMSelectable[tiles.Length];
        var    prevInteracts = new KMSelectable.OnInteractHandler[tiles.Length];
        string lastPress     = null;

        for (int i = 0; i < tiles.Length; i++)
        {
            var selectable   = selectables[i] = GetField <KMSelectable>(tiles.GetValue(i), "selectable", isPublic: true).Get();
            var prevInteract = prevInteracts[i] = selectable.OnInteract;
            var letter       = GetField <TextMesh>(tiles.GetValue(i), "containedLetter", isPublic: true).Get();
            selectable.OnInteract = delegate
            {
                lastPress = letter.text;
                return(prevInteract());
            };
        }

        while (!fldSolved.Get())
        {
            yield return(new WaitForSeconds(.1f));
        }
        _modulesSolved.IncSafe(_Blockbusters);

        for (int i = 0; i < tiles.Length; i++)
        {
            selectables[i].OnInteract = prevInteracts[i];
        }

        if (lastPress == null)
        {
            throw new AbandonModuleException("No pressed letter was retrieved.");
        }

        addQuestion(module, Question.BlockbustersLastLetter, correctAnswers: new[] { lastPress }, preferredWrongAnswers: legalLetters.ToArray());
    }
Exemple #3
0
    protected void Start()
    {
        isFaulty  = ModuleType == Type.Faulty;
        ColKnobs  = UnityEngine.Random.Range(0, 3);
        ColFaucet = UnityEngine.Random.Range(0, 3);
        ColPipe   = UnityEngine.Random.Range(0, 3);

        Rules = new bool[6] {
            Info.GetOffIndicators().Contains("NSA"), Info.GetSerialNumberLetters().Any("AEIOU".Contains), (ColKnobs == 2), (ColFaucet == 1), (ColPipe == 0), Info.GetPorts().Contains("HDMI") || Info.GetPorts().Contains("RJ45")
        };

        if (!isFaulty)
        {
            moduleID = sink_moduleIDCounter++;
        }
        else
        {
            Module.ModuleDisplayName = "Faulty Sink";
            Module.ModuleType        = "Faulty Sink";
            moduleID    = fSink_moduleIDCounter++;
            HotHandler  = Hot.OnInteract;
            ColdHandler = Cold.OnInteract;
            coroutine3  = Spin();
            StartCoroutine(coroutine3);
            spin      = forceSpin + UnityEngine.Random.Range(0, 20);
            forceSpin = spin;
            if (spin > 10)
            {
                rotate = true;
            }
            faulty = UnityEngine.Random.Range(0, 5);
            switch (faulty)
            {
            case 0:
                PipeMesh.material.color = Color.black;
                Apply(new[] { 0, 1, 2 });
                for (int i = 3; i < 6; i++)
                {
                    Module.GetComponent <KMSelectable>().Children[i] = Basin;
                }
                Basin.OnInteract = delegate() { FaultyPVC(1); return(false); };
                Hot.OnInteract   = delegate() { FaultyPVC(0); return(false); };
                Cold.OnInteract  = delegate() { FaultyPVC(2); return(false); };
                UpdateChildren();
                DebugLog("Module status is unknown. Please submit [Hot] [Basin] to automatically disable the module.");
                goto start;

            case 1:
                ColPipe = 2;
                PipeMesh.material.color = new Color(0, 157 / 255f, 1);
                Rules[4] = false;
                Rules    = Rules.Select(x => !x).ToArray();
                DebugLog("Debug: PVC reported as blue.");
                break;

            case 2:
                var r = UnityEngine.Random.Range(0, 2);
                GetComponent <KMSelectable>().Children[1] = Faucet;
                GetComponent <KMSelectable>().Children[7] = Pipe;
                UpdateChildren();
                while (new[] { ColFaucet, ColPipe }.All(x => x == ColKnobs) || new[] { ColFaucet, ColPipe }.All(x => x != ColKnobs))
                {
                    ColFaucet = UnityEngine.Random.Range(0, 3);
                    ColPipe   = UnityEngine.Random.Range(0, 3);
                }
                Apply(new[] { 0, 1, 2 });
                PipeMesh.material.mainTexture = knobColors[ColPipe];
                if (r == 0)
                {
                    ColdMesh.material = null;
                }
                else
                {
                    HotMesh.material = null;
                }
                Faucet.OnInteract = ButtonHandler(Faucet, 1, r);
                Pipe.OnInteract   = ButtonHandler(Pipe, 1, r);
                Cold.OnInteract   = ButtonHandler(Cold, 1, r);
                Hot.OnInteract    = ButtonHandler(Hot, 1, r);
                Rules[3]          = ColFaucet.Equals(1);
                Rules[4]          = ColPipe.Equals(0);
                DebugLog("Debug: Cannot determine status of Button{0}. Please select one of the following textures:", r);
                DebugLog("Knobs: {0}", knobColors[ColKnobs].name);
                DebugLog("Faucet: {0}", FaucetMesh.material.mainTexture.name);
                DebugLog("Drain Pipe: {0}", PipeMesh.material.mainTexture.name);
                goto start;

            case 3:
                rotate = false;
                var s = UnityEngine.Random.Range(0, 2);
                Hot.OnInteract = delegate() { Module.HandleStrike(); DebugLog("Warning: Overheating"); processingInput = false; return(false); };
                hotHolder      = Hot;
                if (s == 0)
                {
                    Hot = Faucet;
                    Module.GetComponent <KMSelectable>().Children[1] = Faucet;
                }
                else
                {
                    Hot = Pipe;
                    Module.GetComponent <KMSelectable>().Children[7] = Pipe;
                }
                ColKnobs  = 0;
                ColKnobs  = 0;
                ColFaucet = 0;
                ColPipe   = 2;
                Rules[2]  = false;
                Rules[3]  = false;
                Rules[4]  = false;
                ColdMesh.material.color   = Color.black;
                HotMesh.material.color    = Color.black;
                FaucetMesh.material.color = Color.black;
                PipeMesh.material.color   = Color.black;
                Steps(false);
                goto start;

            case 4:
                transform.Rotate(0, 180, 0);
                Steps(true);
                Apply(new[] { 3, 2, 1, 0 });
                goto start;
            }
        }

        Apply(new[] { 0, 1, 2, 3 });
        Steps(false);

        start : Module.OnActivate += delegate {
            canPress = true;
        };
    }
Exemple #4
0
    private void Interrupt()
    {
        moduleResolved = false;

        // Selects module to interrupt.
        InterruptableModule selected = null;

        // The module can no longer reset when too little time is left.
        float bombTime = bombInfo.GetTime();

        if (bombTime >= needyModule.CountdownTime)
        {
            InterruptableModule[] potentials = new InterruptableModule[interruptableModules.Count];
            interruptableModules.CopyTo(potentials);
            potentials.Shuffle();

            foreach (InterruptableModule current in potentials)
            {
                // A module is only interrupted when the off light is on,
                // and it isn't currently used.
                TechSupportLog.Log(!current.PassLight.activeSelf
                                   + " " + !current.StrikeLight.activeSelf
                                   + " " + !current.ErrorLight.activeSelf
                                   + " " + !current.IsFocussed);

                if (!current.PassLight.activeSelf &&
                    !current.StrikeLight.activeSelf &&
                    !current.ErrorLight.activeSelf &&
                    !current.IsFocussed)
                {
                    selected = current;
                    break;
                }
            }

            interrupted = interruptableModules.IndexOf(selected);
        }
        else
        {
            TechSupportLog.Log("Not enough time left, forcing to interrupt without module.");
        }

        // Interrupts that module (if there is one).
        if (selected == null)
        {
            TechSupportLog.Log("Could not find interruptable module. Creating exception without one.");

            errorData = data.GenerateError(null);
            allErrors.Add(errorData);

            string message = exceptionWithoutModuleMessages[Random.Range(0, exceptionWithoutModuleMessages.Length)];
            message = string.Format(message, errorData.Error, errorData.SourceFile, errorData.LineIndex, errorData.ColumnIndex);
            console.Show(message);
        }
        else
        {
            TechSupportLog.LogFormat("Interrupting: {0}", selected.BombModule.ModuleDisplayName);

            // All other lights are disabled, and the error light is enabled.
            Transform parent     = selected.PassLight.transform.parent;
            int       childCount = parent.childCount;
            for (int i = 0; i < childCount; i++)
            {
                parent.GetChild(i).gameObject.SetActive(false);
            }

            selected.ErrorLight.SetActive(true);

            // Disabling all interaction with the module.
            interruptedInteractHandler     = selected.Selectable.OnInteract;
            selected.Selectable.OnInteract = new KMSelectable.OnInteractHandler(delegate
            {
                bombAudio.PlayGameSoundAtTransform(KMSoundOverride.SoundEffect.NeedyActivated, selected.BombModule.transform);
                return(false);
            });

            // Generating error and Updating the console.
            errorData = data.GenerateError(selected.BombModule.ModuleDisplayName);
            allErrors.Add(errorData);

            string message = string.Format(errorFormat, selected.BombModule.ModuleDisplayName, errorData.Error, errorData.SourceFile, errorData.LineIndex, errorData.ColumnIndex);
            console.Show(message);
        }

        StartVersionSelection();
    }