Exemple #1
0
        protected override void AwakeLive()
        {
#if (!DEBUG)
            using var wrapper = this.InstantiateComponent <MorseCodeComponent>();
            this._displayText = wrapper.Component.DisplayText;
            this._displayText.transform.SetParent(this.transform, false);

            var layout = wrapper.Component.transform.Find("Component_Morse");
            layout.SetParent(this.transform, false);
            //wrapper.Component.TransmitButton.Text.text = "XT";

            this.LightOff = wrapper.Component.LEDUnlit;
            this.LightOn  = wrapper.Component.LEDLit;

            this._buttons = new[] { wrapper.Component.DownButton, wrapper.Component.UpButton, wrapper.Component.TransmitButton };

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed  += this.KeypadEventConnector_ButtonPressed;
            keypadEventConnector.ButtonReleased += this.KeypadEventConnector_ButtonReleased;
            keypadEventConnector.Attach(this._buttons);

            var marker = layout.Find("Freq_Marker").GetComponent <FreqMarker>();
            this.freqMarker           = marker.transform;
            this.freqMarkerStart      = marker.StartPoint.localPosition;
            this.freqMarkerEnd        = marker.EndPoint.localPosition;
            this._freqMarkerStartFreq = marker.StartFreq;
            this._freqMarkerEndFreq   = marker.EndFreq;
            this._freqMarkerSpeed     = marker.Speed;
            Destroy(marker);              // FreqMarker doesn't do what we need it to and may throw exceptions in Update.
#endif
        }
        protected override void AwakeLive()
        {
#if (!DEBUG)
            this.tempModuleWrapper = this.InstantiateComponent <InvisibleWallsComponent>();
            this.tempModuleClone   = this.tempModuleWrapper.Component;
            this.playerIndicator   = this.tempModuleClone.transform.Find("PlayerIndicator");
            this.playerIndicator.SetParent(this.transform, false);
            this.playerIndicator.GetComponent <Renderer>().material = this.DotMaterial;
            this.GridParent = this.tempModuleClone.Background.transform;
            this.GridParent.SetParent(this.transform, false);
            var layout = this.tempModuleClone.transform.Find("Component_Maze");
            layout.SetParent(this.transform, false);

            // We need to prevent this object from being destroyed as well.
            this.tempModuleClone.transform.Find("WallSegmentPrefab").parent = null;

            this.buttons = this.tempModuleClone.Buttons;

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed += this.KeypadEventConnector_ButtonPressed;
            keypadEventConnector.Attach(this.buttons);

            this.mazeCells = new List <List <MazeCell> >(
                Enumerable.Range(0, 6).Select(x => new List <MazeCell>(
                                                  Enumerable.Range(0, 6).Select(y => new MazeCell(x, y))
                                                  ))
                );
#endif
        }
        protected override void AwakeLive()
        {
#if (!DEBUG)
            using var wrapper = this.InstantiateComponent <NeedyVentComponent>();
            wrapper.Component.transform.Find("Component_Needy_VentGas").SetParent(this.transform, false);

            this.displayTexts = new TextMeshPro[7];
            displayTexts[(int)Texts.VentGas]    = wrapper.Component.VentText.transform.Find("VentGas").GetComponent <TextMeshPro>();
            displayTexts[(int)Texts.VentYN]     = wrapper.Component.VentText.transform.Find("VentYN").GetComponent <TextMeshPro>();
            displayTexts[(int)Texts.Detonate]   = wrapper.Component.DetonateText.transform.Find("Detonate").GetComponent <TextMeshPro>();
            displayTexts[(int)Texts.DetonateYN] = wrapper.Component.DetonateText.transform.Find("DetonateYN").GetComponent <TextMeshPro>();
            displayTexts[(int)Texts.VentingPreventsExplosions] = wrapper.Component.PreventsText.transform.Find("VentingPreventsExplosions").GetComponent <TextMeshPro>();
            displayTexts[(int)Texts.VentingComplete]           = wrapper.Component.VentingCompleteText.transform.Find("VentingComplete").GetComponent <TextMeshPro>();
            displayTexts[(int)Texts.InputText] = wrapper.Component.InputText;

            foreach (var text in this.displayTexts)
            {
                DestroyImmediate(text.GetComponent <I2.Loc.Localize>());
            }

            var displayBases = new GameObject[5];
            displayBases[0] = wrapper.Component.VentText;
            displayBases[1] = wrapper.Component.DetonateText;
            displayBases[2] = wrapper.Component.PreventsText;
            displayBases[3] = wrapper.Component.VentingCompleteText;
            displayBases[4] = wrapper.Component.InputText.gameObject;

            foreach (var displayBase in displayBases)
            {
                //displayBase.gameObject.SetActive(false);
                displayBase.transform.SetParent(this.transform, false);
            }
            DisableDisplay();

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed += (sender, e) => this.ButtonPressed?.Invoke(this, new VentingGasButtonEventArgs((VentingGasButton)e.ButtonIndex));

            this.buttons = new[] { wrapper.Component.NoButton, wrapper.Component.YesButton };
            keypadEventConnector.Attach(this.buttons);

            FixKeypadButtons(this.buttons);
#endif
        }
        protected override void AwakeLive()
        {
#if (!DEBUG)
            using var wrapper = this.InstantiateComponent <PasswordComponent>();
            this.layout       = wrapper.Component.CurrentLayout = wrapper.Component.transform.Find("Layout_DEFAULT").GetComponent <PasswordLayout>();
            this.layout.transform.SetParent(this.transform, false);
            this.spinners     = wrapper.Component.Spinners;
            this.submitButton = wrapper.Component.SubmitButton;
            this.submitButton.transform.SetParent(this.transform, false);
            //this.submitButton.transform.Rotate(new Vector3(0, 180, 0));
            this.displayGlow = wrapper.Component.DisplayGlow;
            this.displayGlow.transform.SetParent(this.transform, false);
            this.displayGlow.SetActive(false);

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed += this.KeypadEventConnector_ButtonPressed;
            keypadEventConnector.Attach(this.submitButton);

            FixKeypadButtons(this.GetComponentsInChildren <KeypadButton>());
#endif
        }
        protected override void AwakeLive()
        {
#if (!DEBUG)
            var modulePrefab = GetComponentPrefab <KeypadComponent>();
            this.symbolTextures = modulePrefab.SymbolTextures;
            var model = Instantiate(modulePrefab.transform.Find("Model"), this.transform);

            this.buttons = model.transform.Cast <Transform>().Select(t => t.GetComponent <KeypadButton>()).Where(b => b != null).ToList();

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed += this.KeypadEventConnector_ButtonPressed;
            keypadEventConnector.Attach(this.buttons);

            for (int i = 0; i < this.buttons.Count; ++i)
            {
                var button = this.buttons[i];
                button.SymbolImage.AddComponent <ExcludeFromTexturePack>();
                this.LightRenderers[i].transform.parent.SetParent(button.transform);
            }
            FixKeypadButtons(this.buttons);

            var textPrefab = GetComponentPrefab <PasswordComponent>().transform.Find("Layout_DEFAULT").GetComponent <PasswordLayout>().Spinners[0].Display;
            this.colourblindTexts = new TextMeshPro[this.buttons.Count];
            for (int i = 0; i < this.buttons.Count; ++i)
            {
                var text = Instantiate(textPrefab, this.LightRenderers[i].transform.parent, false);
                this.colourblindTexts[i]     = text;
                text.enableAutoSizing        = false;
                text.transform.localPosition = new Vector3(0, 0.001f, 0.001f);
                text.transform.localScale    = new Vector3(0.005f, 0.005f, 1);
                text.alignment   = TextAlignmentOptions.Center;
                text.color       = new Color(0, 0, 0, 0.8f);
                text.lineSpacing = -12;
            }
            foreach (var text in this.TestModelColourblindTexts)
            {
                text.gameObject.SetActive(false);
            }
#endif
        }
        protected override void AwakeLive()
        {
#if (!DEBUG)
            using var wrapper = this.InstantiateComponent <SimonComponent>();
            this.buttons      = wrapper.Component.buttons;
            foreach (var button in this.buttons)
            {
                button.transform.SetParent(this.transform, false);
            }
            wrapper.Component.transform.Find("Frame").SetParent(this.transform, false);

            var positions = this.buttons.Select(b => b.ButtonGO.transform.localPosition).ToList();
            this.buttons[(int)SimonButtons.Red].ButtonGO.transform.localPosition    = positions[(int)SimonButtons.Blue];
            this.buttons[(int)SimonButtons.Blue].ButtonGO.transform.localPosition   = positions[(int)SimonButtons.Red];
            this.buttons[(int)SimonButtons.Green].ButtonGO.transform.localPosition  = positions[(int)SimonButtons.Yellow];
            this.buttons[(int)SimonButtons.Yellow].ButtonGO.transform.localPosition = positions[(int)SimonButtons.Green];

            var keypadEventConnector = new KeypadEventConnector();
            keypadEventConnector.ButtonPressed += this.KeypadEventConnector_ButtonPressed;
            keypadEventConnector.Attach(this.buttons);

            FixKeypadButtons(this.buttons);
#endif
        }