Example #1
0
        private void CreateButtonBack()
        {
            var nsr = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/little_notarget" + ".png");

            buttonBack = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, -4f, -1f), new Vector2(6f, 0.6f), "Game/Color");
            GUIHelper.TextButton(buttonBack, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Назад", new Color4(160, 185, 198, 255), Color4.White);
            buttonBack.MouseClick += ButtonBack_MouseClick;

            GUIElement.CreateImage(screenContainer.renderer, buttonBack.renderer.Position + new Vector3(0f, 0.03f, 0.5f), buttonBack.renderer.size, "GUI/ConfigureScreen/desk");
        }
Example #2
0
        private void CreateButtons()
        {
            CreateButtonBack();

            var windowButtonSelected       = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/window_target" + ".png");
            var windowButtonNoSelected     = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/window_notarget" + ".png");
            var fullscreenButtonSelected   = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/fullscreen_target" + ".png");
            var fullscreenButtonNoSelected = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/fullscreen_notarget" + ".png");
            var paths = new ImagesContainer(windowButtonSelected, windowButtonNoSelected, fullscreenButtonSelected, fullscreenButtonNoSelected);

            modeButton         = new ToggleButton(paths, new Vector3(0.9f, 2.95f, -2f), new Vector2(1.35f, 0.63f), screenContainer.renderer);
            modeButton.Choose += ModeButton_Choose;

            var sl         = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/big_target" + ".png");
            var nsl        = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/big_notarget" + ".png");
            var sr         = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/little_target" + ".png");
            var nsr        = GPUTextureLoader.LoadAsync("Images/" + "GUI/ConfigureScreen/Buttons/little_notarget" + ".png");
            var paths2     = new ImagesContainer(sl, nsl, sr, nsr);
            var fontButton = new ToggleButton(paths2, new Vector3(0.9f, 1.75f, -2f), new Vector2(1.35f, 0.63f), screenContainer.renderer);

            fontButton.Choose += FontButton_Choose;

            var textSpeed = new Slider(new Vector3(2.3f, 0.58f, -2f), screenContainer.renderer);

            textSpeed.UpdatePosition += TextSpeed_UpdatePosition;
            textSpeed.SetPosition(GameKernel.settings.settingsData.TextSpeed);

            var volumeMusic = new Slider(new Vector3(2.3f, -0.42f, -2f), screenContainer.renderer);

            volumeMusic.UpdatePosition += VolumeMusic_UpdatePosition;
            volumeMusic.SetPosition(GameKernel.settings.settingsData.MusicVolume);

            var volumeAmbient = new Slider(new Vector3(2.3f, -1.42f, -2f), screenContainer.renderer);

            volumeAmbient.UpdatePosition += VolumeAmbient_UpdatePosition;
            volumeAmbient.SetPosition(GameKernel.settings.settingsData.AmbientVolume);

            var volumeEffects = new Slider(new Vector3(2.3f, -2.42f, -2f), screenContainer.renderer);

            volumeEffects.UpdatePosition += VolumeEffects_UpdatePosition;
            volumeEffects.SetPosition(GameKernel.settings.settingsData.EffectsVolume);

            if (GameKernel.settings.settingsData.Fullscreen)
            {
                FullScreenMode();
            }
            else
            {
                WindowScreenMode();
            }
        }
Example #3
0
        public ExitMenu(ScreenManager screenManager, Renderer parent) : base(screenManager, parent)
        {
            // Parent is scenario screen
            background = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, 0f, -1f), new Vector2(19.2f, 10.8f), "SimpleTransitionForMenu");
            {
                CoroutineExecutor.Add(Routine());

                IEnumerator Routine()
                {
                    var ticket1 = GPUTextureLoader.LoadAsync("Images/GUI/ec_exit_bg_1.png");
                    var ticket2 = GPUTextureLoader.LoadAsync("Images/GUI/ec_exit_bg_2.png");

                    while (ticket1.texture == null || ticket2.texture == null)
                    {
                        yield return(null);
                    }

                    background.material.SetTexture("Tex1", ticket1.texture);
                    background.material.SetTexture("Tex2", ticket2.texture);

                    while (true)
                    {
                        foreach (var i in CoroutineExecutor.ForTime(5f))
                        {
                            yield return(null);
                        }

                        foreach (var i in CoroutineExecutor.ForTime(0.5f))
                        {
                            background.material.SetFloat("CrossFade", i);
                            yield return(null);
                        }

                        foreach (var i in CoroutineExecutor.ForTime(0.5f))
                        {
                            background.material.SetFloat("CrossFade", 1f - i);
                            yield return(null);
                        }
                    }
                }
            }

            var label = GUIElement.CreateEmpty(screenContainer.renderer, new Vector3(-2.3f, 0f, -2f), new Vector2(10f, 1.08f));

            label.renderer.name = "Label";

            {
                var textBox = label.Entity.CreateComponent <TextBox>(name);
                textBox.InitFromRenderer();
                textBox.CharHeight = 0.4f;
                textBox.FontName   = "Furore";
                textBox.Text       = "Ты правда хочешь сбежать?";
            }

            buttonYes = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(-5.2f, -1f, -2f), new Vector2(1.2f, 0.56f), "Game/Color");
            {
                buttonYes.renderer.name = "Yes";
                ODEngine.Helpers.GUIHelper.TextButton(buttonYes, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Да", new Color4(160, 185, 198, 255), Color4.White);
                buttonYes.MouseClick += ButtonYes_MouseClick;
            }

            buttonNo = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(-2.35f, -1f, -2f), new Vector2(1.2f, 0.56f), "Game/Color");
            {
                buttonNo.renderer.name = "No";
                ODEngine.Helpers.GUIHelper.TextButton(buttonNo, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Нет", new Color4(160, 185, 198, 255), Color4.White);
                buttonNo.MouseClick += ButtonNo_MouseClick;
            }

            screenContainer.renderer.isVisible = false;
        }
Example #4
0
        public MainMenu(ScreenManagerVN screenManager, Renderer parent) : base(screenManager, parent)
        {
            screenContainer.name          = "MainMenu screenContainer";
            screenContainer.renderer.name = "MainMenu screenContainer Renderer";
            screenContainer.material.SetFloat("alpha", 0f);

            var backBack   = GUIElement.CreateImage(screenContainer.renderer, Vector3.Zero, parentRenderer.size, "GUI/MainMenu/BackBack");
            var character1 = GUIElement.CreateImage(screenContainer.renderer, Vector3.Zero, parentRenderer.size, "GUI/MainMenu/Character1");

            buttonsContainer = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, -4.85f, -1f), new Vector2(19.2f, 0.88f), "Game/Alpha");
            deskImage        = GUIElement.CreateImage(buttonsContainer.renderer, Vector3.Zero, new Vector2(19.2f, 0.88f), "GUI/MainMenu/Buttons/desk");
            buttonsContainer.renderer.isVisible = false;
            buttonsContainer.material.SetFloat("alpha", 0f);

            var rays = GUIElement.CreateImage(screenContainer.renderer, Vector3.Zero, parentRenderer.size, "GUI/MainMenu/PostAber", new Material(null, "Game/Alpha"));

            { // Лучи
                IEnumerator AlphaAnimation()
                {
                    while (true)
                    {
                        rays.material.SetFloat("alpha", 0f);
                        yield return(null);

                        for (float i = 0f; i < 7f; i += Kernel.deltaTimeUpdate)
                        {
                            yield return(null);
                        }
                        for (float i = 0f; i < 1f; i += Kernel.deltaTimeUpdate / 2f)
                        {
                            rays.material.SetFloat("alpha", i * i * i * i);
                            yield return(null);
                        }
                        for (float i = 0f; i < MathF.PI * 2; i += Kernel.deltaTimeUpdate * MathF.PI)
                        {
                            rays.material.SetFloat("alpha", (MathF.Cos(i) / 2f + 0.5f) * 0.3f + 0.7f);
                            yield return(null);
                        }
                        for (float i = 0f; i < 1f; i += Kernel.deltaTimeUpdate / 2f)
                        {
                            rays.material.SetFloat("alpha", 1f - i * i * i * i);
                            yield return(null);
                        }
                    }
                }

                var animation = AlphaAnimation();
                CoroutineExecutor.Add(animation);
            }

            buttonStart = GUIElement.CreateEmpty(screenContainer.renderer, new Vector3(-5.69f, -1.73f, -1f), new Vector2(5.64f, 5.29f) * 0.73f);
            { // Кнопка начала игры
                buttonStart.renderer.name = "Start game";
                ODEngine.Helpers.GUIHelper.ImageButton(buttonStart,
                                                       "Images/GUI/MainMenu/BookGo_idle.png",
                                                       "Images/GUI/MainMenu/BookGo_hover.png");

                var imageTicket = ImageLoader.LoadRaw("Images/GUI/MainMenu/BookGo_idle.png", (ticket) =>
                {
                    buttonStart.CreateMask(ticket.rawImage).Wait();
                    ticket.Unload();
                });

                buttonStart.threshold = 0.5f;

                buttonStart.MouseClick += ButtonStart_MouseClick;
            }

            // Надпись "Глубина Холода"
            var labelDOC = GUIElement.CreateFrameAnimation(screenContainer.renderer, new Vector3(-4.64f, 3.46f, -1f), new Vector2(8.67f, 3.54f),
                                                           ("GUI/MainMenu/Title", ColorMatrix.Identity, 10f),
                                                           ("GUI/MainMenu/Title_G1", ColorMatrix.Identity, 0.04f),
                                                           ("GUI/MainMenu/Title_G2", ColorMatrix.Identity, 0.04f),
                                                           ("GUI/MainMenu/Title_G3", ColorMatrix.Identity, 0.04f),
                                                           ("GUI/MainMenu/Title_G4", ColorMatrix.Identity, 0.04f),
                                                           ("GUI/MainMenu/Title", ColorMatrix.Identity, 8f),
                                                           ("GUI/MainMenu/Title_G1", ColorMatrix.Identity, 0.05f),
                                                           ("GUI/MainMenu/Title", ColorMatrix.Identity, 10f),
                                                           ("GUI/MainMenu/Title_G1", ColorMatrix.Identity, 0.03f),
                                                           ("GUI/MainMenu/Title_G2", ColorMatrix.Identity, 0.03f));

            buttonMenu = GUIElement.CreateEmpty(screenContainer.renderer, new Vector3(9.23f, -4.87f, -2f), new Vector2(0.74f, 0.88f));
            {
                buttonMenu.renderer.name = "Menu";

                var imageFile1 = "Images/GUI/MainMenu/Buttons/Triangle_idle.png";
                var texTicket1 = GPUTextureLoader.LoadAsync(imageFile1);
                var imageFile2 = "Images/GUI/MainMenu/Buttons/Triangle_hover.png";
                var texTicket2 = GPUTextureLoader.LoadAsync(imageFile2);
                var imageFile3 = "Images/GUI/MainMenu/Buttons/TriangleBack_idle.png";
                var texTicket3 = GPUTextureLoader.LoadAsync(imageFile3);
                var imageFile4 = "Images/GUI/MainMenu/Buttons/TriangleBack_hover.png";
                var texTicket4 = GPUTextureLoader.LoadAsync(imageFile4);

                buttonMenu.renderer.onRender = (input, output) =>
                {
                    if (!menuIsVisible)
                    {
                        if (!buttonMenu.mouseOnElement)
                        {
                            if (texTicket1 != null)
                            {
                                Graphics.Blit(texTicket1.texture, output);
                            }
                        }
                        else
                        {
                            if (texTicket2 != null)
                            {
                                Graphics.Blit(texTicket2.texture, output);
                            }
                        }
                    }
                    else
                    {
                        if (!buttonMenu.mouseOnElement)
                        {
                            if (texTicket1 != null)
                            {
                                Graphics.Blit(texTicket3.texture, output);
                            }
                        }
                        else
                        {
                            if (texTicket2 != null)
                            {
                                Graphics.Blit(texTicket4.texture, output);
                            }
                        }
                    }
                };

                buttonMenu.isLoaded = () => texTicket1.isLoaded && texTicket2.isLoaded && texTicket3.isLoaded && texTicket4.isLoaded;

                buttonMenu.MouseClick += ButtonMenu_MouseClick;
            }

            buttonExit = GUIElement.CreateContainer(buttonsContainer.renderer, new Vector3(6.75f, 0f, -1f), new Vector2(1.95f, 0.56f), "Game/Color");
            { // Кнопка выхода
                buttonExit.renderer.name = "Exit";
                ODEngine.Helpers.GUIHelper.TextButton(buttonExit, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Выход", new Color4(160, 185, 198, 255), Color4.White);
                buttonExit.MouseClick += ButtonExit_MouseClick;
            }

            buttonSettings = GUIElement.CreateContainer(buttonsContainer.renderer, new Vector3(3.88f, 0f, -1f), new Vector2(3.02f, 0.56f), "Game/Color");
            { // Кнопка "Настройки"
                buttonSettings.renderer.name = "Settings";
                ODEngine.Helpers.GUIHelper.TextButton(buttonSettings, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Настройки", new Color4(160, 185, 198, 255), Color4.White);
                buttonSettings.MouseClick += ButtonSettings_MouseClick;
            }

            buttonLoad = GUIElement.CreateContainer(buttonsContainer.renderer, new Vector3(0.5f, 0f, -1f), new Vector2(3.02f, 0.56f), "Game/Color");
            { // Кнопка "Загрузить"
                buttonLoad.renderer.name = "Load";
                ODEngine.Helpers.GUIHelper.TextButton(buttonLoad, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Загрузить", new Color4(160, 185, 198, 255), Color4.White);
                buttonLoad.MouseClick += ButtonLoad_MouseClick;
            }

            buttonFragment = GUIElement.CreateContainer(buttonsContainer.renderer, new Vector3(-2.65f, 0f, -1f), new Vector2(3.02f, 0.56f), "Game/Color");
            { // Кнопка "Фрагмент"
                buttonFragment.renderer.name = "Fragment";
                ODEngine.Helpers.GUIHelper.TextButton(buttonFragment, new Vector3(0f, 0.02f, 0f), "Furore", 0.45f, "Фрагмент", new Color4(160, 185, 198, 255), Color4.White);
                buttonFragment.MouseClick += ButtonFragment_MouseClick;
            }

            isLoaded = () => backBack.IsLoaded && character1.IsLoaded && deskImage.IsLoaded && rays.IsLoaded &&
                       buttonStart.IsLoaded && labelDOC.IsLoaded && buttonSettings.IsLoaded && buttonExit.IsLoaded && buttonMenu.IsLoaded;
        }