예제 #1
0
    private void ReactivateInterruptedModule()
    {
        if (errorData.ModuleName == null)
        {
            return;
        }

        InterruptableModule module = interruptableModules[interrupted];

        onSelected = null;

        // Enables interrupted module.
        module.Selectable.OnInteract = interruptedInteractHandler;
        Transform parent     = module.PassLight.transform.parent;
        int       childCount = parent.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform child = parent.GetChild(i);
            if (child.name == "Component_LED_OFF")
            {
                child.gameObject.SetActive(true);
            }
            else
            {
                child.gameObject.SetActive(false);
            }
        }
    }
예제 #2
0
    private void StartParametersSelection()
    {
        ShowOptions(TechSupportData.Parameters, selectParametersMessage);

        onSelected = delegate
        {
            ConfirmSelection();

            int correctParameter = CorrectParameter(errorData);

            TechSupportLog.LogFormat("Parameter: Selected option: {0}; Correct option {1}.",
                                     TechSupportData.Parameters[selectedOption],
                                     TechSupportData.Parameters[correctParameter]);

            if (selectedOption == correctParameter || forceParametersCorrect)
            {
                ReactivateInterruptedModule();
                moduleResolved = true;
                console.Show(correctSelectionMessage);

                if (errorData.ModuleName == null)
                {
                    console.Show(exceptionWithoutModuleResolvedMessage);
                }
                else
                {
                    InterruptableModule module = interruptableModules[interrupted];
                    string message             = string.Format(moduleReleasedFormat, module.BombModule.ModuleDisplayName);
                    console.Show(message);
                }
            }
            else
            {
                TechSupportLog.Log("STRIKE: Wrong parameters.");
                needyModule.HandleStrike();
                console.Show(incorrectSelectionMessage);
                StartParametersSelection();
            }
        };
    }
예제 #3
0
    private IEnumerator DelayedStart()
    {
        TechSupportService mysteryKeyService = GetComponent <TechSupportService>();

        while (!mysteryKeyService.SettingsLoaded)
        {
            yield return(null);
        }

        KMBossModule bossModule = GetComponent <KMBossModule>();

        string[] ignoredModules = bossModule.GetIgnoredModules(needyModule.ModuleDisplayName);

        if (ignoredModules == null || ignoredModules.Length == 0)
        {
            TechSupportLog.Log("Using backup ignorelist.");
            ignoredModules = backUpIgnoreList.text.Split('\n');
        }

        KMBombModule[] bombModules = FindObjectsOfType <KMBombModule>();

        foreach (KMBombModule bombModule in bombModules)
        {
            try
            {
                bool mustNotBeHidden = mysteryKeyService.MustNotBeHidden(bombModule.ModuleType);
                bool isIgnored       = ignoredModules.Contains(bombModule.ModuleDisplayName);

                // Ignored modules are ignored.
                if (mustNotBeHidden || isIgnored)
                {
                    TechSupportLog.LogFormat("Ignored module {0} - Must Not Be Hidden: {1}; Is Ignored {2}",
                                             bombModule.ModuleDisplayName,
                                             mustNotBeHidden,
                                             isIgnored);
                    continue;
                }

                // Collects the module's KMSelectable.
                KMSelectable selectable = bombModule.GetComponent <KMSelectable>();

                GameObject passLight   = TransformUtilities.FindChildIn(bombModule.transform, "Component_LED_PASS").gameObject;
                Transform  statusLight = passLight.transform.parent;
                GameObject strikeLight = TransformUtilities.FindChildIn(statusLight, "Component_LED_STRIKE").gameObject;
                GameObject errorLight  = Instantiate(
                    errorLightPrefab,
                    statusLight.position,
                    statusLight.rotation,
                    statusLight.transform);
                errorLight.SetActive(false);

                // Stores the acquired data.
                InterruptableModule interruptableModule = new InterruptableModule(bombModule, selectable, passLight, strikeLight, errorLight);

                interruptableModules.Add(interruptableModule);
            }
            catch (Exception exception)
            {
                TechSupportLog.LogFormat
                    ("Set-Up Interruptable ({0}) failed with message ({1}), at ({2}).",
                    bombModule.ModuleDisplayName,
                    exception.Message,
                    exception.StackTrace);
            }
        }

        TechSupportLog.LogFormat("Loaded total of {0} interruptable modules", interruptableModules.Count);
    }
예제 #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();
    }