Esempio n. 1
0
 internal ModuleConfig(KMBombModule kmBombModule              = null,
                       KMBossModule kmBossModule              = null,
                       KMColorblindMode kmColorblindMode      = null,
                       KMNeedyModule kmNeedyModule            = null,
                       Tuple <Action, KMBombInfo>?onTimerTick = null)
 {
     KMBombModule     = kmBombModule;
     KMBossModule     = kmBossModule;
     KMColorblindMode = kmColorblindMode;
     KMNeedyModule    = kmNeedyModule;
     OnTimerTick      = onTimerTick;
 }
Esempio n. 2
0
        public void Start(ref KMBossModule Boss, ref bool colorblind, ref KMColorblindMode Colorblind, ref KMRuleSeedable Rule, ref int moduleId, ref Rule[][] rules, ref int maxStage, ref KMBombInfo BombInfo, ref List <byte> cylinder, ref List <byte> nixies, ref List <byte> gear, ref List <short> largeDisplay, ref List <int> calculatedValues, ref List <int> sineNumber, ref List <string> gearColor, ref List <string> ruleColor, ref TextMesh[] NixieTexts, ref KMAudio Audio, ref KMBombModule Module)
        {
            //boss module handler
            if (Boss.GetIgnoredModules(Module, Strings.Ignore) != null)
            {
                Strings.Ignore = Boss.GetIgnoredModules(Module, Strings.Ignore);
            }

            //enables colorblind mode if needed
            colorblind = Colorblind.ColorblindModeActive;

            //gets seed
            MonoRandom rnd = Rule.GetRNG();

            Debug.LogFormat("[Forget The Colors #{0}]: Using version {1} with rule seed: {2}.", moduleId, Strings.Version, rnd.Seed);

            if (rnd.Seed == 1)
            {
                rules = null;
            }

            else
            {
                //establishes new variable
                rules    = new Rule[2][];
                rules[0] = new Rule[21];
                rules[1] = new Rule[10];

                //applies rule seeding for cylinders
                for (byte i = 0; i < rules[0].Length; i++)
                {
                    rules[0][i] = new Rule {
                        Cylinder = (byte)rnd.Next(rules[0].Length), Operator = (byte)rnd.Next(5)
                    }
                }
                ;

                //applies rule seeding for edgework
                for (byte i = 0; i < rules[1].Length; i++)
                {
                    rules[1][i] = new Rule {
                        Edgework = (byte)rnd.Next(rules[1].Length), Operator = (byte)rnd.Next(5)
                    }
                }
                ;
            }

            //if on unity, max stage should equal the initial value assigned, otherwise set it to the proper value
            if (!Application.isEditor)
            {
                maxStage = BombInfo.GetSolvableModuleNames().Where(m => !Strings.Ignore.Contains(m)).Count();
            }

            //proper grammar!!
            if (maxStage != 1)
            {
                Debug.LogFormat("[Forget The Colors #{0}]: Welcome to FTC - This bomb will have {1} stages.", moduleId, maxStage);
            }

            else
            {
                Debug.LogFormat("[Forget The Colors #{0}]: Welcome to FTC - This bomb will have a single stage.", moduleId);
            }

            //initialization of previous stage variables
            for (ushort i = 0; i < maxStage; i++)
            {
                for (byte j = 0; j < 4; j++)
                {
                    cylinder.Add(0);
                }

                nixies.Add(0);
                nixies.Add(0);
                gear.Add(0);
                largeDisplay.Add(0);
                calculatedValues.Add(0);
                sineNumber.Add(0);
                gearColor.Add("Red");
                ruleColor.Add("Red");
            }

            //begin module
            NixieTexts[0].text = "0";
            NixieTexts[1].text = "0";
            Audio.PlaySoundAtTransform(Sounds.Ftc.Start, Module.transform);
        }
    }
}
Esempio n. 3
0
        /// <summary>
        /// Event initializer.
        /// </summary>
        private void Awake()
        {
            // This gives a unique value of each instantiation, since moduleIdCounter is static.
            moduleId = ++moduleIdCounter;

            /*
             * The following adds all appropriate parameters for each property you assign.
             * The first if statements are to ask whether it should try adding events.
             * The other if statements are to add the events if they exist.
             */

            if (KMBombInfo != null)
            {
                if (OnBombExploded != null)
                {
                    KMBombInfo.OnBombExploded += OnBombExploded;
                }
                if (OnBombSolved != null)
                {
                    KMBombInfo.OnBombSolved += OnBombSolved;
                }
            }
            else
            {
                LogErrorIfNotNull("KMBombInfo", OnBombExploded, OnBombSolved);
            }

            if (KMBombModule != null)
            {
                if (OnActivate != null)
                {
                    KMBombModule.OnActivate += (() => isActivate = true) + OnActivate;
                }

                if (KMBossModule != null)
                {
                    IgnoreList = KMBossModule.GetIgnoredModules(KMBombModule, IgnoreList);
                }
                else if (IgnoreList != null)
                {
                    LogErrorIfNotNull("KMBossModule", IgnoreList);
                }
            }
            else
            {
                LogErrorIfNotNull("KMBombModule", OnActivate);
            }

            if (KMColorblindMode != null)
            {
                isColorblind = KMColorblindMode.ColorblindModeActive;
            }

            if (KMGameInfo != null)
            {
                if (OnAlarmClockChange != null)
                {
                    KMGameInfo.OnAlarmClockChange += OnAlarmClockChange;
                }
                if (OnLightsChange != null)
                {
                    KMGameInfo.OnLightsChange += OnLightsChange;
                }
            }
            else
            {
                LogErrorIfNotNull("KMGameInfo", OnActivateNeedy, OnNeedyActivation, OnNeedyDeactivation, OnTimerExpired);
            }

            if (KMNeedyModule != null)
            {
                if (OnActivateNeedy != null)
                {
                    KMNeedyModule.OnActivate += OnActivateNeedy;
                }
                if (OnNeedyActivation != null)
                {
                    KMNeedyModule.OnNeedyActivation += OnNeedyActivation;
                }
                if (OnNeedyDeactivation != null)
                {
                    KMNeedyModule.OnNeedyDeactivation += OnNeedyDeactivation;
                }
                if (OnTimerExpired != null)
                {
                    KMNeedyModule.OnTimerExpired += OnTimerExpired;
                }
            }
            else
            {
                LogErrorIfNotNull("KMNeedyModule", OnActivateNeedy, OnNeedyActivation, OnNeedyDeactivation, OnTimerExpired);
            }

            if (KMSelectable != null)
            {
                for (int i = 0; i < KMSelectable.Length; i++)
                {
                    for (int j = 0; j < KMSelectable[i].Length; j++)
                    {
                        AssignSelectable(KMSelectable[i][j], ref i, ref j);
                    }
                }
            }
            else
            {
                LogErrorIfNotNull("KMSelectable", OnCancel, OnDefocus, OnDeselect, OnFocus, OnHighlight, OnHighlightEnded, OnInteract, OnInteractEnded, OnLeft, OnRight, OnSelect);
            }
        }
Esempio n. 4
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);
    }