public LoadMenu(ScreenManager screenManager, Renderer parent) : base(screenManager, parent) { background = GUIElement.CreateImage(screenContainer.renderer, new Vector3(0f, 0f, 0f), new Vector2(19.2f, 10.8f), "GUI/ConfigureScreen/BackSett"); var label = GUIElement.CreateEmpty(screenContainer.renderer, new Vector3(0f, 4.5f, -2f), new Vector2(10f, 1.08f)); label.renderer.name = "Label"; { var textBox = label.Entity.CreateComponent <TextBox>(name); textBox.InitFromRenderer(); textBox.CharHeight = 0.45f; textBox.FontName = "Furore"; textBox.Text = "Загрузить"; textBox.Align = ODEngine.Core.Text.TextAlign.Center; } var buttonCancel = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, -4f, -2f), new Vector2(3f, 0.56f), "Game/Color"); { buttonCancel.renderer.name = "Cancel"; ODEngine.Helpers.GUIHelper.TextButton(buttonCancel, new Vector3(0f, 0.02f, 0f), "Furore", 0.4f, "Вернуться", new Color4(160, 185, 198, 255), Color4.White); buttonCancel.MouseClick += ButtonCancel_MouseClick; } screenContainer.renderer.isVisible = false; }
protected override void OnEnable() { screenContainer.renderer.isVisible = true; screenContainer.material.SetFloat("alpha", 1f); CoroutineExecutor.Add(Routine(), true); IEnumerator Routine() { var backBlack = new Entity().CreateComponent <Renderer>(); backBlack.SetParent(screenContainer.renderer); backBlack.Position = new Vector3(0f, 0f, -2f); backBlack.size = screenContainer.renderer.size; backBlack.onRender = (_, output) => Graphics.Clear(output, Color4.Black); GUIElement[] labelContainers = new GUIElement[data.captions.Length]; GUIElement[] labels = new GUIElement[data.captions.Length]; for (int i = 0; i < data.captions.Length; i++) { labelContainers[i] = GUIElement.CreateContainer(screenContainer.renderer, new Vector3(0f, (data.captions.Length - 1 - i * 2 + (i == 0 ? 0.2f : 0f)) * data.fontSize * data.interval, -3f), new Vector2(19.2f, 2f * data.fontSize), "Game/Alpha"); labels[i] = GUIElement.CreateEmpty(labelContainers[i].renderer, new Vector3(0f, 0f, 0f), new Vector2(19.2f, 2f * data.fontSize)); { var textBox = labels[i].Entity.CreateComponent <TextBox>(); textBox.InitFromRenderer(); textBox.CharHeight = i switch { 0 => 1f, _ => 0.8f, } *data.fontSize; textBox.Text = new TextColored(data.captions[i], new SColor(1f, 1f, 1f)); textBox.Align = ODEngine.Core.Text.TextAlign.Center; } labelContainers[i].material.SetFloat("alpha", 0f); } foreach (var i in CoroutineExecutor.ForTime(data.startDelay)) // Start delay { if (!isEnable) { Finish2(); yield break; } yield return(null); } if (data.isSimultaneous) // Labels fade in { foreach (var i in CoroutineExecutor.ForTime(data.fadeInTime)) { if (!isEnable) { Finish2(); yield break; } for (int j = 0; j < data.captions.Length; j++) { labelContainers[j].material.SetFloat("alpha", i * i); yield return(null); } } } else { for (int i = 0; i < data.captions.Length; i++) { foreach (var j in CoroutineExecutor.ForTime(data.fadeInTime)) { if (!isEnable) { Finish2(); yield break; } labelContainers[i].material.SetFloat("alpha", j * j); yield return(null); } } } foreach (var _ in CoroutineExecutor.ForTime(data.showTime)) // Show { if (!isEnable) { Finish2(); yield break; } yield return(null); } foreach (var i in CoroutineExecutor.ForTime(data.captionsFadeOutTime)) // Fade out { if (!isEnable) { Finish2(); yield break; } for (int j = 0; j < data.captions.Length; j++) { labelContainers[j].material.SetFloat("alpha", (1f - i) * (1f - i)); } yield return(null); } Finish2(); void Finish2() { for (int i = 0; i < data.captions.Length; i++) { labels[i].Entity.Destroy(); labelContainers[i].Entity.Destroy(); } } foreach (var i in CoroutineExecutor.ForTime(data.screenFadeOutTime)) { if (!isEnable) { Finish(); yield break; } screenContainer.material.SetFloat("alpha", (1f - i) * (1f - i)); yield return(null); } Finish(); void Finish() { backBlack.Entity.Destroy(); Disable(); } } }
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; }
private static void TextManager_InterfaceCreating(object sender, EventArgs e) { TextManager textManager = (TextManager)sender; textManager.guiRoot = new Entity().CreateComponent <Renderer>("GUI Root"); textManager.gameTextADV = new Entity().CreateComponent <GameText>("ADV"); textManager.gameTextNVL = new Entity().CreateComponent <GameText>("NVL"); textManager.gameTextName = new Entity().CreateComponent <GameText>("Name"); Renderer renderer; { // GUI Root textManager.guiRoot.SetParent(GameKernel.screenManager.scenarioScreen.screenRenderer); textManager.guiRoot.Position = new Vector3(0f, 0f, -6f); } { // ADV var size = new Vector2(19.2f, 3.5f); textManager.containerADV = GUIElement.CreateContainer(textManager.guiRoot, new Vector3(0f, -3.7f, -1f), size + new Vector2(6f, 6f), "Game/Alpha"); textManager.containerADV.name = "containerADV"; renderer = textManager.gameTextADV.Entity.GetComponent <Renderer>(); renderer.SetParent(textManager.containerADV.renderer); //var background = GUIElement.CreateImage(textManager.containerADV.renderer, new Vector3(0f, 0f, 1f), new Vector2(19.2f, 3.5f), "GUI/newdialogue", 0.8f); var background = GUIElement.CreateImage(textManager.containerADV.renderer, new Vector3(0f, -0.45f, 1f), new Vector2(15.56f, 1.71f), "GUI/adv_box"); background.renderer.name = "ADV Background"; var clickArea = GUIElement.CreateEmpty(textManager.containerADV.renderer, new Vector3(0f, 0f, 0f), textManager.containerADV.renderer.size); clickArea.name = "clickAreaADV"; clickArea.renderer.name = "clickAreaADV"; clickArea.MouseDown += scenarioScreen.ClickArea_MouseDown; ADVNormalTransform(textManager); } { // NVL var size = new Vector2(14.93f, 9.5187f); textManager.containerNVL = GUIElement.CreateContainer(textManager.guiRoot, new Vector3(0f, -0.192f, -1f), size + new Vector2(4f, 4f), "Game/Alpha"); textManager.containerNVL.name = "containerNVL"; renderer = textManager.gameTextNVL.Entity.GetComponent <Renderer>(); textManager.gameTextNVL.UpdateSize(size); textManager.gameTextNVL.FontName = "BloggerSans"; textManager.gameTextNVL.Refresh(); renderer.SetParent(textManager.containerNVL.renderer); var background = GUIElement.CreateImage(textManager.containerNVL.renderer, new Vector3(0f, 0f, 1f), size + new Vector2(0.5f, 0.5f), "GUI/NVL_New", 0.8f); background.renderer.name = "NVL Background"; var clickArea = GUIElement.CreateEmpty(textManager.containerNVL.renderer, new Vector3(0f, 0f, 0f), textManager.containerNVL.renderer.size); clickArea.name = "clickAreaNVL"; clickArea.renderer.name = "clickAreaNVL"; textManager.nvlSetPosition += e => TextManager_NvlSetPosition(textManager, background, e); TextManager_NvlSetPosition(textManager, background, TextManager.NVLPosition.Center); clickArea.MouseDown += scenarioScreen.ClickArea_MouseDown; } { // Name textManager.containerName = GUIElement.CreateContainer(textManager.guiRoot, new Vector3(-5.624f, -3.097f, 0f), new Vector2(4.14f, 0.49f), "Game/Alpha"); renderer = textManager.gameTextName.Entity.GetComponent <Renderer>(); textManager.gameTextName.UpdateSize(4.14f, 0.49f); textManager.gameTextName.outline = true; textManager.gameTextName.FontName = "BloggerSans"; textManager.gameTextName.Refresh(); renderer.SetParent(textManager.containerName.renderer); } }
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; }