void Start()
    {
        currentSelectable = GetComponent <TestSelectable>();

        KMBombModule[]  modules      = FindObjectsOfType <KMBombModule>();
        KMNeedyModule[] needyModules = FindObjectsOfType <KMNeedyModule>();
        currentSelectable.Children = new TestSelectable[modules.Length + needyModules.Length];
        for (int i = 0; i < modules.Length; i++)
        {
            currentSelectable.Children[i] = modules[i].GetComponent <TestSelectable>();
            modules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            modules[i].OnPass   = delegate() { Debug.Log("Module Passed"); return(false); };
            modules[i].OnStrike = delegate() { Debug.Log("Strike"); return(false); };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            currentSelectable.Children[modules.Length + i]         = needyModules[i].GetComponent <TestSelectable>();
            needyModules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();


        //Load all the audio clips in the asset database
        audioClips = new List <AudioClip>();
        string[] audioClipAssetGUIDs = AssetDatabase.FindAssets("t:AudioClip");

        foreach (var guid in audioClipAssetGUIDs)
        {
            AudioClip clip = AssetDatabase.LoadAssetAtPath <AudioClip>(AssetDatabase.GUIDToAssetPath(guid));

            if (clip != null)
            {
                audioClips.Add(clip);
            }
        }

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
Esempio n. 2
0
 void Cancel()
 {
     if (currentSelectable.Parent != null && currentSelectable.Cancel())
     {
         currentSelectable.DeactivateChildSelectableAreas(currentSelectable.Parent);
         currentSelectable = currentSelectable.Parent;
         currentSelectable.ActivateChildSelectableAreas();
         lastSelected = currentSelectable.GetCurrentChild();
     }
 }
Esempio n. 3
0
 void Interact()
 {
     if (currentSelectableArea != null && currentSelectableArea.Selectable.Interact())
     {
         currentSelectable.DeactivateChildSelectableAreas(currentSelectableArea.Selectable);
         currentSelectable = currentSelectableArea.Selectable;
         currentSelectable.ActivateChildSelectableAreas();
         lastSelected = currentSelectable.GetCurrentChild();
     }
 }
Esempio n. 4
0
    void EmulateDirection(Direction direction)
    {
        TestSelectable selectable = lastSelected.GetNearestSelectable(direction);

        if (selectable)
        {
            lastSelected = selectable;
            currentSelectable.LastSelectedChild = lastSelected;
        }
    }
    void AddSelectables()
    {
        List <KMSelectable> selectables = new List <KMSelectable>(GameObject.FindObjectsOfType <KMSelectable>());

        foreach (KMSelectable selectable in selectables)
        {
            TestSelectable testSelectable = selectable.gameObject.AddComponent <TestSelectable>();
            testSelectable.Highlight = selectable.Highlight.GetComponent <TestHighlightable>();
        }

        foreach (KMSelectable selectable in selectables)
        {
            TestSelectable testSelectable = selectable.gameObject.GetComponent <TestSelectable>();
            testSelectable.Children = new TestSelectable[selectable.Children.Length];
            for (int i = 0; i < selectable.Children.Length; i++)
            {
                if (selectable.Children[i] != null)
                {
                    testSelectable.Children[i] = selectable.Children[i].GetComponent <TestSelectable>();
                }
            }
        }
    }
    public TestSelectable GetChildInDirection(Direction direction, int i, int j)
    {
        TestSelectable result  = null;
        TestSelectable result2 = null;

        switch (direction)
        {
        case Direction.Up:
            result  = Parent.GetChild(x - i, y - j);
            result2 = Parent.GetChild(x + i, y - j);
            break;

        case Direction.Down:
            result  = Parent.GetChild(x - i, y + j);
            result2 = Parent.GetChild(x + i, y + j);
            break;

        case Direction.Left:
            result  = Parent.GetChild(x - j, y - i);
            result2 = Parent.GetChild(x - j, y + i);
            break;

        case Direction.Right:
            result  = Parent.GetChild(x + j, y - i);
            result2 = Parent.GetChild(x + j, y + i);
            break;
        }
        if (result != null)
        {
            return(result);
        }
        if (result2 != null)
        {
            return(result2);
        }
        return(null);
    }
    public void DeactivateChildSelectableAreas(TestSelectable newParent)
    {
        TestSelectable parent = newParent;

        while (parent != null)
        {
            if (parent == this && parent.GetComponent <TestHarness>() == null)
            {
                return;
            }
            parent = parent.Parent;
        }

        parent = this;

        while (parent != newParent && parent != null)
        {
            for (var i = 0; i < parent.Children.Length; i++)
            {
                if (parent.Children[i] != null)
                {
                    if (parent.Children[i].SelectableArea != null)
                    {
                        parent.Children[i].SelectableArea.DeactivateSelectableArea();
                    }
                }
            }

            parent = parent.Parent;

            if (parent != null && parent == newParent && parent.SelectableArea != null)
            {
                parent.SelectableArea.ActivateSelectableArea();
            }
        }
    }
    public TestSelectable GetNearestSelectable(Direction direction)
    {
        if (Parent == null || ModSelectable.IsPassThrough)
        {
            return(null);
        }

        int num = Mathf.Max(Parent.ChildRowLength, Parent.Children.Length / Parent.ChildRowLength);

        for (var i = 0; i < num; i++)
        {
            for (var j = 1; j < num; j++)
            {
                TestSelectable childInDirection = GetChildInDirection(direction, i, j);
                if (childInDirection != null)
                {
                    return(childInDirection);
                }
            }
        }
        if ((Parent != null && (direction == Direction.Down || direction == Direction.Up) && Parent.AllowSelectionWrapY) || ((direction == Direction.Left || direction == Direction.Right) && Parent.AllowSelectionWrapX))
        {
            for (var k = 0; k < num; k++)
            {
                for (var l = -num; l < 0; l++)
                {
                    TestSelectable childInDirection2 = GetChildInDirection(direction, k, l);
                    if (childInDirection2 != null)
                    {
                        return(childInDirection2);
                    }
                }
            }
        }
        return(null);
    }
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        Debug.DrawRay(ray.origin, ray.direction);
        RaycastHit hit;
        int        layerMask           = 1 << 11;
        bool       rayCastHitSomething = Physics.Raycast(ray, out hit, 1000, layerMask);

        if (rayCastHitSomething)
        {
            TestSelectableArea hitArea = hit.collider.GetComponent <TestSelectableArea>();
            if (hitArea != null)
            {
                if (currentSelectableArea != hitArea)
                {
                    if (currentSelectableArea != null)
                    {
                        currentSelectableArea.Selectable.Deselect();
                    }

                    hitArea.Selectable.Select();
                    currentSelectableArea = hitArea;
                }
            }
            else
            {
                if (currentSelectableArea != null)
                {
                    currentSelectableArea.Selectable.Deselect();
                    currentSelectableArea = null;
                }
            }
        }
        else
        {
            if (currentSelectableArea != null)
            {
                currentSelectableArea.Selectable.Deselect();
                currentSelectableArea = null;
            }
        }

        if (Input.GetMouseButtonDown(0))
        {
            if (currentSelectableArea != null && currentSelectableArea.Selectable.Interact())
            {
                currentSelectable.DeactivateChildSelectableAreas(currentSelectableArea.Selectable);
                currentSelectable = currentSelectableArea.Selectable;
                currentSelectable.ActivateChildSelectableAreas();
            }
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (currentSelectableArea != null)
            {
                currentSelectableArea.Selectable.InteractEnded();
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (currentSelectable.Parent != null && currentSelectable.Cancel())
            {
                currentSelectable.DeactivateChildSelectableAreas(currentSelectable.Parent);
                currentSelectable = currentSelectable.Parent;
                currentSelectable.ActivateChildSelectableAreas();
            }
        }
    }
Esempio n. 10
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();
        foreach (MonoBehaviour s in scripts)
        {
            IEnumerable <FieldInfo> fields = s.GetType().GetFields();
            foreach (FieldInfo f in fields)
            {
                if (f.FieldType.Equals(typeof(KMBombInfo)))
                {
                    KMBombInfo component = (KMBombInfo)f.GetValue(s);
                    if (component.OnBombExploded != null)
                    {
                        fakeInfo.Detonate += new FakeBombInfo.OnDetonate(component.OnBombExploded);
                    }
                    if (component.OnBombSolved != null)
                    {
                        fakeInfo.HandleSolved += new FakeBombInfo.OnSolved(component.OnBombSolved);
                    }
                    continue;
                }
            }
        }

        currentSelectable = GetComponent <TestSelectable>();

        KMBombModule[]  modules      = FindObjectsOfType <KMBombModule>();
        KMNeedyModule[] needyModules = FindObjectsOfType <KMNeedyModule>();
        fakeInfo.needyModules      = needyModules.ToList();
        currentSelectable.Children = new TestSelectable[modules.Length + needyModules.Length];
        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            currentSelectable.Children[i] = modules[i].GetComponent <TestSelectable>();
            modules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));
            modules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                fakeInfo.modules.Remove(fakeInfo.modules.First(t => t.Key.Equals(mod)));
                fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = true;
                foreach (KeyValuePair <KMBombModule, bool> m in fakeInfo.modules)
                {
                    if (!m.Value)
                    {
                        allSolved = false;
                        break;
                    }
                }
                if (allSolved)
                {
                    fakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            currentSelectable.Children[modules.Length + i]         = needyModules[i].GetComponent <TestSelectable>();
            needyModules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();


        //Load all the audio clips in the asset database
        audioClips = new List <AudioClip>();
        string[] audioClipAssetGUIDs = AssetDatabase.FindAssets("t:AudioClip");

        foreach (var guid in audioClipAssetGUIDs)
        {
            AudioClip clip = AssetDatabase.LoadAssetAtPath <AudioClip>(AssetDatabase.GUIDToAssetPath(guid));

            if (clip != null)
            {
                audioClips.Add(clip);
            }
        }

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
Esempio n. 11
0
    void Update()
    {
        if (!gamepadEnabled)
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            Debug.DrawRay(ray.origin, ray.direction);
            RaycastHit hit;
            int        layerMask           = 1 << 11;
            bool       rayCastHitSomething = Physics.Raycast(ray, out hit, 1000, layerMask);

            if (rayCastHitSomething)
            {
                TestSelectableArea hitArea = hit.collider.GetComponent <TestSelectableArea>();
                if (hitArea != null)
                {
                    if (currentSelectableArea != hitArea)
                    {
                        if (currentSelectableArea != null)
                        {
                            currentSelectableArea.Selectable.Deselect();
                        }

                        hitArea.Selectable.Select();
                        currentSelectableArea = hitArea;
                    }
                }
                else
                {
                    if (currentSelectableArea != null)
                    {
                        currentSelectableArea.Selectable.Deselect();
                        currentSelectableArea = null;
                    }
                }
            }
            else
            {
                if (currentSelectableArea != null)
                {
                    currentSelectableArea.Selectable.Deselect();
                    currentSelectableArea = null;
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                Interact();
            }
            if (Input.GetMouseButtonUp(0))
            {
                InteractEnded();
            }
            if (Input.GetMouseButtonDown(1))
            {
                Cancel();
            }
        }
        else
        {
            TestSelectable previousSelectable = lastSelected;
            if (Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown(KeyCode.Return))
            {
                Interact();
            }
            if (Input.GetKeyUp(KeyCode.X) || Input.GetKeyUp(KeyCode.Return))
            {
                InteractEnded();
            }
            if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Backspace))
            {
                Cancel();
            }
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                EmulateDirection(Direction.Left);
            }
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                EmulateDirection(Direction.Right);
            }
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                EmulateDirection(Direction.Up);
            }
            if (Input.GetKeyDown(KeyCode.DownArrow))
            {
                EmulateDirection(Direction.Down);
            }

            if (previousSelectable != lastSelected)
            {
                previousSelectable.Deselect();
                lastSelected.Select();
                currentSelectableArea = lastSelected.SelectableArea;
            }
        }
    }
Esempio n. 12
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();
        foreach (MonoBehaviour s in scripts)
        {
            IEnumerable <FieldInfo> fields = s.GetType().GetFields();
            foreach (FieldInfo f in fields)
            {
                if (f.FieldType.Equals(typeof(KMBombInfo)))
                {
                    KMBombInfo component = (KMBombInfo)f.GetValue(s);
                    fakeInfo.Detonate += delegate { if (component.OnBombExploded != null)
                                                    {
                                                        component.OnBombExploded();
                                                    }
                    };
                    fakeInfo.HandleSolved += delegate { if (component.OnBombSolved != null)
                                                        {
                                                            component.OnBombSolved();
                                                        }
                    };
                }
            }
        }

        currentSelectable = GetComponent <TestSelectable>();

        KMBombModule[]  modules      = FindObjectsOfType <KMBombModule>();
        KMNeedyModule[] needyModules = FindObjectsOfType <KMNeedyModule>();
        fakeInfo.needyModules            = needyModules.ToList();
        currentSelectable.Children       = new TestSelectable[modules.Length + needyModules.Length];
        currentSelectable.ChildRowLength = currentSelectable.Children.Length;
        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            TestSelectable testSelectable = modules[i].GetComponent <TestSelectable>();
            currentSelectable.Children[i] = testSelectable;
            testSelectable.Parent         = currentSelectable;
            testSelectable.x = i;

            fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));
            modules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                fakeInfo.modules.Remove(fakeInfo.modules.First(t => t.Key.Equals(mod)));
                fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = true;
                foreach (KeyValuePair <KMBombModule, bool> m in fakeInfo.modules)
                {
                    if (!m.Value)
                    {
                        allSolved = false;
                        break;
                    }
                }
                if (allSolved)
                {
                    fakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            TestSelectable testSelectable = needyModules[i].GetComponent <TestSelectable>();
            currentSelectable.Children[modules.Length + i] = testSelectable;
            testSelectable.Parent = currentSelectable;
            testSelectable.x      = modules.Length + i;

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
Esempio n. 13
0
    void OnGUI()
    {
        if (GUILayout.Button("Activate Needy Modules"))
        {
            foreach (KMNeedyModule needyModule in GameObject.FindObjectsOfType <KMNeedyModule>())
            {
                if (needyModule.OnNeedyActivation != null)
                {
                    needyModule.OnNeedyActivation();
                }
            }
        }

        if (GUILayout.Button("Deactivate Needy Modules"))
        {
            foreach (KMNeedyModule needyModule in GameObject.FindObjectsOfType <KMNeedyModule>())
            {
                if (needyModule.OnNeedyDeactivation != null)
                {
                    needyModule.OnNeedyDeactivation();
                }
            }
        }

        if (GUILayout.Button("Lights On"))
        {
            TurnLightsOn();
            fakeInfo.OnLightsOn();
        }

        if (GUILayout.Button("Lights Off"))
        {
            TurnLightsOff();
            fakeInfo.OnLightsOff();
        }

        bool previous = gamepadEnabled;

        gamepadEnabled = GUILayout.Toggle(gamepadEnabled, "Emulate Gamepad");
        if (!previous && gamepadEnabled)
        {
            lastSelected = currentSelectable.GetCurrentChild();
            lastSelected.Select();
            currentSelectableArea = lastSelected.SelectableArea;
        }

        GUILayout.Label("Time remaining: " + fakeInfo.GetFormattedTime());

        GUILayout.Space(10);

        GUI.SetNextControlName("commandField");
        command = GUILayout.TextField(command);
        if ((GUILayout.Button("Simulate Twitch Command") || Event.current.keyCode == KeyCode.Return) && GUI.GetNameOfFocusedControl() == "commandField" && command != "")
        {
            Debug.Log("Twitch Command: " + command);

            foreach (var module in FindObjectsOfType <KMBombModule>().Concat <MonoBehaviour>(FindObjectsOfType <KMNeedyModule>()))
            {
                Component[] allComponents = module.gameObject.GetComponentsInChildren <Component>(true);
                foreach (var component in allComponents)
                {
                    var type   = component.GetType();
                    var method = type.GetMethod("ProcessTwitchCommand", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                    if (method != null)
                    {
                        StartCoroutine(SimulateModule(component, module.transform, method, command));
                    }
                }
            }
            command = "";
        }
    }
Esempio n. 14
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();

        currentSelectable = GetComponent <TestSelectable>();

        var modules      = Modules;
        var needyModules = NeedyModules;

        fakeInfo.needyModules      = needyModules.ToList();
        currentSelectable.Children = new TestSelectable[modules.Length + needyModules.Length];
        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            currentSelectable.Children[i] = modules[i].GetComponent <TestSelectable>();
            modules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));

            modules[i].OnPass = delegate() {
                Debug.Log("Module Passed");
                fakeInfo.modules.Remove(fakeInfo.modules.First(t => t.Key.Equals(mod)));
                fakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = true;
                foreach (KeyValuePair <KMBombModule, bool> m in fakeInfo.modules)
                {
                    if (!m.Value)
                    {
                        allSolved = false;
                        break;
                    }
                }
                if (allSolved)
                {
                    fakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate() {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            currentSelectable.Children[modules.Length + i]         = needyModules[i].GetComponent <TestSelectable>();
            needyModules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            Handlers(needyModules[i].GetComponent <KMBombInfo>());

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                fakeInfo.HandleStrike();
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();

        audioSource = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform += PlaySoundHandler;
        }
    }
Esempio n. 15
0
 public void OnDrillAway(TestSelectable newParent)
 {
     DeactivateChildSelectableAreas(newParent);
 }
Esempio n. 16
0
    void Start()
    {
        MonoBehaviour[] scripts = MonoBehaviour.FindObjectsOfType <MonoBehaviour>();
        foreach (MonoBehaviour s in scripts)
        {
            IEnumerable <FieldInfo> fields = s.GetType().GetFields();
            foreach (FieldInfo f in fields)
            {
                if (f.FieldType.Equals(typeof(KMBombInfo)))
                {
                    KMBombInfo component = (KMBombInfo)f.GetValue(s);
                    if (component.OnBombExploded != null)
                    {
                        FakeInfo.Detonate += new FakeBombInfo.OnDetonate(component.OnBombExploded);
                    }
                    if (component.OnBombSolved != null)
                    {
                        FakeInfo.HandleSolved += new FakeBombInfo.OnSolved(component.OnBombSolved);
                    }
                    continue;
                }
            }
        }

        FakeInfo.Detonate     += OnBombExploded;
        FakeInfo.HandleSolved += OnBombSolved;

        currentSelectable = GetComponent <TestSelectable>();

        KMBombModule[]    modules      = FindObjectsOfType <KMBombModule>();
        KMNeedyModule[]   needyModules = FindObjectsOfType <KMNeedyModule>();
        KMWidget[]        widgets      = FindObjectsOfType <KMWidget>();
        KMSoundOverride[] overrides    = FindObjectsOfType <KMSoundOverride>();
        FakeInfo.needyModules      = needyModules.ToList();
        currentSelectable.Children = new TestSelectable[modules.Length + needyModules.Length];

        FakeInfo.kmWidgets.AddRange(widgets);

        foreach (KMSoundOverride sound in overrides)
        {
            SoundEffects.OverwriteClips(sound);
        }

        for (int i = 0; i < modules.Length; i++)
        {
            KMBombModule mod = modules[i];

            KMStatusLightParent statuslightparent = modules[i].GetComponentInChildren <KMStatusLightParent>();
            var statuslight = Instantiate <StatusLight>(StatusLightPrefab);
            statuslight.transform.parent        = statuslightparent.transform;
            statuslight.transform.localPosition = Vector3.zero;
            statuslight.transform.localScale    = Vector3.one;
            statuslight.transform.localRotation = Quaternion.identity;
            statuslight.SetInActive();

            currentSelectable.Children[i] = modules[i].GetComponent <TestSelectable>();
            modules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            FakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(modules[i], false));
            modules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                statuslight.SetPass();

                FakeInfo.modules.Remove(FakeInfo.modules.First(t => t.Key.Equals(mod)));
                FakeInfo.modules.Add(new KeyValuePair <KMBombModule, bool>(mod, true));
                bool allSolved = !FakeInfo.detonated;
                foreach (KeyValuePair <KMBombModule, bool> m in FakeInfo.modules)
                {
                    if (!allSolved)
                    {
                        break;
                    }
                    allSolved &= m.Value;
                }
                if (allSolved)
                {
                    FakeInfo.Solved();
                }
                return(false);
            };
            modules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                statuslight.FlashStrike();
                FakeInfo.HandleStrike();
                if (!FakeInfo.detonated)
                {
                    PlayGameSoundHandler(KMSoundOverride.SoundEffect.Strike, transform);
                }
                return(false);
            };
        }

        for (int i = 0; i < needyModules.Length; i++)
        {
            currentSelectable.Children[modules.Length + i]         = needyModules[i].GetComponent <TestSelectable>();
            needyModules[i].GetComponent <TestSelectable>().Parent = currentSelectable;

            needyModules[i].OnPass = delegate()
            {
                Debug.Log("Module Passed");
                return(false);
            };
            needyModules[i].OnStrike = delegate()
            {
                Debug.Log("Strike");
                FakeInfo.HandleStrike();
                if (!FakeInfo.detonated)
                {
                    PlayGameSoundHandler(KMSoundOverride.SoundEffect.Strike, transform);
                }
                return(false);
            };
        }

        currentSelectable.ActivateChildSelectableAreas();

        _alarmAudioSource = gameObject.AddComponent <AudioSource>();
        _alarmAudioSource.transform.position = transform.position;
        _alarmAudioSource.loop = true;
        audioSource            = gameObject.AddComponent <AudioSource>();
        KMAudio[] kmAudios = FindObjectsOfType <KMAudio>();
        foreach (KMAudio kmAudio in kmAudios)
        {
            kmAudio.HandlePlaySoundAtTransform            += PlaySoundHandler;
            kmAudio.HandlePlayGameSoundAtTransform        += PlayGameSoundHandler;
            kmAudio.HandlePlaySoundAtTransformWithRef     += PlaySoundwithRefHandler;
            kmAudio.HandlePlayGameSoundAtTransformWithRef += PlayGameSoundHandlerWithRef;
        }
    }