private static IList <INumberHandler> CreateNumberHandlers(BurglarAlarmHelper burglarAlarmHelper)
    {
        var numberHandlers = new List <INumberHandler>();

        numberHandlers.Add(new NumberHandlerPos1(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos2(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos3(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos4(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos5(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos6(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos7(burglarAlarmHelper));
        numberHandlers.Add(new NumberHandlerPos8(burglarAlarmHelper));

        return(numberHandlers);
    }
    void Activate()
    {
        this.activated    = false;
        this.moduleNumber = new int[8];
        this.answers      = new int[8];

        for (int i = 0; i < this.moduleNumber.Length; ++i)
        {
            this.moduleNumber[i] = Rnd.Range(0, 10);
        }
        ;

        var burglarAlarmHelper = new BurglarAlarmHelper(this.moduleNumber, this.Info);

        this.numberHandlers = CreateNumberHandlers(burglarAlarmHelper);

        Debug.LogFormat("[Burglar Alarm #{0}] Module number is: {1}.", this._moduleId, string.Join(string.Empty, this.moduleNumber.Select(x => x.ToString()).ToArray()));
        LogSolutionAlternatives(this._moduleId, this.moduleNumber, this.Info);

        this.DisplayText.text = burglarAlarmHelper.ToStringNumber;

        this.Info.OnBombExploded += delegate()
        {
            this.StopSound();
        };

        for (int i = 0; i < this.Buttons.Count(); ++i)
        {
            var myIndex = i;
            this.Buttons[i].OnInteract += delegate()
            {
                Audio.PlaySoundAtTransform("Button sound", this.Buttons[myIndex].transform);
                this.Buttons[myIndex].AddInteractionPunch();

                if (!activated || this.isSolved)
                {
                    return(false);
                }

                if (this.noPressed >= 8)
                {
                    Debug.LogFormat("[Burglar Alarm #{0}] Pressed too many numbers! Strike!", this._moduleId);
                    this.HandleStrike();
                    return(false);
                }

                else
                {
                    this.answers[this.noPressed++] = myIndex;
                }

                return(false);
            };
        }

        this.ActivateButton.OnInteract += delegate()
        {
            Audio.PlaySoundAtTransform("Button sound", this.ActivateButton.transform);
            ActivateButton.AddInteractionPunch();
            if (this.isSolved)
            {
                return(false);
            }

            if (this.activated)
            {
                this.HandleStrike();
            }
            else
            {
                Debug.LogFormat("[Burglar Alarm #{0}] Module activated!", this._moduleId);
                Debug.LogFormat("[Burglar Alarm #{0}] Started at {1} solves.", this._moduleId, this.Info.GetSolvedModuleNames().Count);
                Debug.LogFormat("[Burglar Alarm #{0}] Expected input: {1}.", this._moduleId, LogModuleSolutionNumber(numberHandlers));
                StartCoroutine("Countdown");
                this.activationSound = Audio.PlaySoundAtTransformWithRef("Activation sound", Module.transform);
                this.activated       = true;
            }

            return(false);
        };

        this.SubmitButton.OnInteract += delegate()
        {
            if (this.activated)
            {
                Debug.LogFormat("[Burglar Alarm #{0}] Submitted: {1}.", this._moduleId, string.Join(string.Empty, this.answers.Select(x => x.ToString()).ToArray()));
            }

            Audio.PlaySoundAtTransform("Button sound", this.SubmitButton.transform);
            SubmitButton.AddInteractionPunch();
            if (this.isSolved)
            {
                return(false);
            }

            if (!this.activated)
            {
                Debug.LogFormat("[Burglar Alarm #{0}] Submitted a number before activating the module. Strike!", this._moduleId);
                this.HandleStrike();
                return(false);
            }

            bool success = true;
            for (int i = 0; i < this.answers.Count(); ++i)
            {
                if (this.answers[i] != this.numberHandlers[i].GetNumber())
                {
                    success = false;
                }
            }

            if (success)
            {
                Debug.LogFormat("[Burglar Alarm #{0}] Module passed!", this._moduleId);
                this.HandlePass();
            }
            else
            {
                Debug.LogFormat("[Burglar Alarm #{0}] Wrong answer!", this._moduleId);
                this.HandleStrike();
            }

            return(false);
        };
    }
 public NumberHandlerPos8(BurglarAlarmHelper metadata)
 {
     this.metadata = metadata;
 }