private void DrawEndPanel(int screenWidth, int screenHeight) { _endGamePanel = new UISequentialContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center, }; var container = new UISequentialContainer(Vector2.Zero, new Vector2(400.0f, 400.0f)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center, Background = new NinePartsTextureBackground("Panel") }; _endGameText = new UIText("Вы выиграли", new Vector2(300.0f, 50.0f), "Text", "TextLight"); container.Add(new UIMarginContainer(_endGameText, 0.0f, 20.0f)); var text = new UIText("Ок", new Vector2(250.0f, 70.0f), "Text", "TextDark"); var button = new UIButton(new Vector2(250.0f, 70.0f), text) { ReleasedBackground = new NinePartsTextureBackground("ButtonRealesed"), PressedBackground = new NinePartsTextureBackground("ButtonPressed") }; button.OnClicked += () => { _endGamePanel.IsVisible = false; _menu.IsVisible = true; }; container.Add(new UIMarginContainer(button, 0.0f, 20.0f)); _endGamePanel.Add(container); _endGamePanel.IsVisible = false; }
protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight) { context.NewNinePartsBitmap("menuBitmap", loader.LoadBitmapFromFile(@"Textures\menu.png"), 15, 121, 15, 46); context.NewNinePartsBitmap("buttonBitmap", loader.LoadBitmapFromFile(@"Textures\button.png"), 15, 121, 15, 46); context.NewNinePartsBitmap("buttonPressedBitmap", loader.LoadBitmapFromFile(@"Textures\buttonPressed.png"), 15, 121, 15, 46); context.NewBitmap("backgroundBitmapWon", loader.LoadBitmapFromFile(@"Textures\Won.png")); context.NewSolidBrush("whiteBrush", new RawColor4(1f, 1f, 1f, 1f)); context.NewTextFormat("textFormat", textAlignment: TextAlignment.Center, paragraphAlignment: ParagraphAlignment.Center); var ui = new UISequentialContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.End, Background = new TextureBackground("backgroundBitmapWon") }; var menu = new UISequentialContainer(Vector2.Zero, new Vector2(200, 200)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center, Background = new NinePartsTextureBackground("menuBitmap") }; ui.Add(new UIMarginContainer(menu, 0, 640, -100, 0)); var startText = new UIText("Start", new Vector2(120, 42), "textFormat", "whiteBrush"); var quitText = new UIText("Quit", new Vector2(120, 42), "textFormat", "whiteBrush"); var startButton = new UILibrary.Elements.UILibrary(startText) { ReleasedBackground = new NinePartsTextureBackground("buttonBitmap"), PressedBackground = new NinePartsTextureBackground("buttonPressedBitmap") }; var quitButton = new UILibrary.Elements.UILibrary(quitText) { ReleasedBackground = new NinePartsTextureBackground("buttonBitmap"), PressedBackground = new NinePartsTextureBackground("buttonPressedBitmap") }; startButton.OnClicked += () => { Game.ChangeScene(new MainGameScene()); }; quitButton.OnClicked += () => { Game.CloseProgramm(); }; menu.Add(new UIMarginContainer(startButton, 4f)); menu.Add(new UIMarginContainer(quitButton, 4f)); return(ui); }
protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight) { var ui = new UIMultiElementsContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)); // Create ui and gui context.NewSolidBrush("ProgressBarBrush", new RawColor4(30f / 255f, 144f / 255f, 255f / 255f, 0.6f)); _healthBar = new UIProgressBar(Vector2.Zero, new Vector2(100, 20), "ProgressBarBrush"); _healthBar.MaxValue = 100; _healthBar.Value = 100; var gui = new UISequentialContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)) { MainAxis = UISequentialContainer.Alignment.Start, CrossAxis = UISequentialContainer.Alignment.Center, }; ui.OnResized += () => gui.Size = ui.Size; ui.Add(gui); gui.Add(new UIMarginContainer(_healthBar, 15)); return(ui); }
protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight) { context.NewNinePartsBitmap("glowingBorder", loader.LoadBitmapFromFile(@"Textures\GlowingBorder.png"), 21, 29, 21, 29); context.NewBitmap("bulletsTexture", loader.LoadBitmapFromFile(@"Textures\Bullets.png")); context.NewSolidBrush("neonBrush", new RawColor4(144f / 255f, 238f / 255f, 233f / 255f, 1f)); context.NewTextFormat("ammoFormat", fontWeight: SharpDX.DirectWrite.FontWeight.Black, textAlignment: SharpDX.DirectWrite.TextAlignment.Center, paragraphAlignment: SharpDX.DirectWrite.ParagraphAlignment.Center); var ui = new UISequentialContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)) { MainAxis = UISequentialContainer.Alignment.End, CrossAxis = UISequentialContainer.Alignment.Start }; _healthBar = new UIProgressBar(Vector2.Zero, new Vector2(100, 20), "neonBrush"); _ammoCounter = new UIText("0", new Vector2(48, 10), "ammoFormat", "neonBrush"); var ammoImage = new UIPanel(Vector2.Zero, new Vector2(40, 36)) { Background = new TextureBackground("bulletsTexture") }; var ammoContainer = new UISequentialContainer(Vector2.Zero, new Vector2(100, 36), false) { MainAxis = UISequentialContainer.Alignment.Start, CrossAxis = UISequentialContainer.Alignment.Center }; var healthContainer = new UIMarginContainer(_healthBar, 15) { Background = new NinePartsTextureBackground("glowingBorder") }; ammoContainer.Add(new UIMarginContainer(ammoImage, 6, 0)); ammoContainer.Add(_ammoCounter); ui.Add(ammoContainer); ui.Add(healthContainer); return(ui); }
private void DrawMenu(int screenWidth, int screenHeight) { _menu = new UISequentialContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center, }; var container = new UISequentialContainer(Vector2.Zero, new Vector2(400.0f, 400.0f)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center, Background = new NinePartsTextureBackground("Panel") }; var text = new UIText("Охота на волков", new Vector2(300.0f, 50.0f), "Text", "TextLight"); container.Add(new UIMarginContainer(text, 0.0f, 20.0f)); text = new UIText("Новая игра", new Vector2(250.0f, 70.0f), "Text", "TextDark"); var button = new UIButton(new Vector2(250.0f, 70.0f), text) { ReleasedBackground = new NinePartsTextureBackground("ButtonRealesed"), PressedBackground = new NinePartsTextureBackground("ButtonPressed") }; button.OnClicked += () => Game.ChangeScene(new GameScene()); container.Add(new UIMarginContainer(button, 0.0f, 20.0f)); text = new UIText("Выход", new Vector2(250.0f, 70.0f), "Text", "TextDark"); button = new UIButton(new Vector2(250.0f, 70.0f), text) { ReleasedBackground = new NinePartsTextureBackground("ButtonRealesed"), PressedBackground = new NinePartsTextureBackground("ButtonPressed") }; button.OnClicked += () => Game.CloseProgramm(); container.Add(new UIMarginContainer(button, 0.0f, 20.0f)); _menu.Add(container); }
protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight) { string textFormat = "testSceneTextFormat"; string whiteBrush = "testSceneWhiteBrush"; string text1background = "testSceneText1background"; string text2background = "testSceneText2background"; string text3background = "testSceneText3background"; string panelBitmap = "testScenePanelBitmap"; //string buttonlBitmap = "panelBitmap"; //context.NewBitmap(buttonlBitmap, loader.LoadBitmapFromFile(@"Textures\button.png")); context.NewNinePartsBitmap(panelBitmap, loader.LoadBitmapFromFile(@"Textures\button.png"), 15, 121, 15, 46); context.NewSolidBrush(whiteBrush, new RawColor4(1f, 1f, 1f, 1f)); context.NewSolidBrush(text1background, new RawColor4(0.6f, 0.1f, 0.2f, 1f)); context.NewSolidBrush(text2background, new RawColor4(0.2f, 0.4f, 0.8f, 1f)); context.NewSolidBrush(text3background, new RawColor4(0.5f, 0.4f, 0.3f, 1f)); context.NewTextFormat(textFormat); _ui = new UIMultiElementsContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)); _panel = new UISequentialContainer(Vector2.Zero, new Vector2(200, 200)) { MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center, //Background = new TextureBackground(panelBitmap) Background = new NinePartsTextureBackground(panelBitmap) }; _ui.Add(_panel); _text1 = new UIText("X", new Vector2(120, 16), textFormat, whiteBrush) { Background = new ColorBackground(text1background) }; _text2 = new UIText("Y", new Vector2(120, 16), textFormat, whiteBrush) { Background = new ColorBackground(text2background) }; _text3 = new UIText("Z", new Vector2(120, 16), textFormat, whiteBrush) { Background = new ColorBackground(text3background) }; UIElement text4 = new UIText("Click Me!", new Vector2(120, 16), textFormat, whiteBrush); UIElement m = new UIMarginContainer(_text1, 2f); UIButton button = new UIButton(text4) { ReleasedBackground = new ColorBackground(text1background), PressedBackground = new ColorBackground(text2background) }; button.OnClicked += () => { MainMenuScene menu = new MainMenuScene(); Game.ChangeScene(menu); }; _panel.Add(m); _panel.Add(_text2); _panel.Add(_text3); _panel.Add(button); _text1.OnClicked += () => { Transition transition = new SmoothTransition(_go.Rotation.X, _go.Rotation.X + MathUtil.TwoPi, 2); transition.Process += value => _go.SetRotationX(value); transition.Process += value => _go.SetRotationY(value); transition.Process += value => _go.SetRotationZ(value); }; _text2.OnClicked += () => { Transition transition = new SmoothTransition(_go.Rotation.Y, _go.Rotation.Y + MathUtil.TwoPi, 2); transition.Process += value => _go.SetRotationY(value); //_voice.Stop(); //_voice.Play(); _voice2.Stop(); _voice2.Play(); }; _text3.OnClicked += () => { Transition transition = new SmoothTransition(_go.Rotation.Z, _go.Rotation.Z + MathUtil.TwoPi, 2); transition.Process += value => _go.SetRotationZ(value); _voice.Play(); //_voice2.Play(); }; _text1.IsClickable = true; _text2.IsClickable = true; _text3.IsClickable = true; return(_ui); }
protected override UIElement InitializeUI(Loader loader, DrawingContext context, int screenWidth, int screenHeight) { Cursor.Hide(); context.NewNinePartsBitmap("Panel", loader.LoadBitmapFromFile(@"Resources\UI\panel.png"), 30, 98, 30, 98); context.NewBitmap("Heart", loader.LoadBitmapFromFile(@"Resources\UI\heart.png")); context.NewBitmap("ArrowStandart", loader.LoadBitmapFromFile(@"Resources\UI\arrowStandart.png")); context.NewBitmap("ArrowPoison", loader.LoadBitmapFromFile(@"Resources\UI\arrowPoison.png")); context.NewBitmap("WolfIcon", loader.LoadBitmapFromFile(@"Resources\UI\wolfIcon.png")); var header1 = new UISequentialContainer(new Vector2(0.0f, 0.0f), new Vector2(screenWidth, 100.0f), false); // здоровье var counter = new UISequentialContainer(Vector2.Zero, new Vector2(300.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; var image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("Heart") }; context.NewSolidBrush("HealthBarBack", new RawColor4(144.0f / 255.0f, 31.0f / 255.0f, 61.0f / 255.0f, 1.0f)); context.NewSolidBrush("HealthBar", new RawColor4(187.0f / 255.0f, 48.0f / 255.0f, 48.0f / 255.0f, 1.0f)); _healthProgressBar = new UIProgressBar(Vector2.Zero, new Vector2(180.0f, 20.0f), "HealthBar") { Background = new ColorBackground("HealthBarBack"), MaxValue = 100.0f, Value = 50.0f }; counter.Add(image); counter.Add(_healthProgressBar); header1.Add(new UIMarginContainer(counter, 5.0f, 0.0f)); // обычные стрелы counter = new UISequentialContainer(Vector2.Zero, new Vector2(200.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("ArrowStandart") }; context.NewSolidBrush("Text", new RawColor4(1.0f, 1.0f, 1.0f, 1.0f)); context.NewTextFormat("Text", fontSize: 40.0f, textAlignment: SharpDX.DirectWrite.TextAlignment.Center); _arrowStandartText = new UIText("0", new Vector2(50.0f, 50.0f), "Text", "Text"); counter.Add(image); counter.Add(_arrowStandartText); header1.Add(new UIMarginContainer(counter, 5.0f, 0.0f)); // стрелы яда counter = new UISequentialContainer(Vector2.Zero, new Vector2(200.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("ArrowPoison") }; _arrowPoisonText = new UIText("0", new Vector2(50.0f, 50.0f), "Text", "Text"); counter.Add(image); counter.Add(_arrowPoisonText); header1.Add(new UIMarginContainer(counter, 5.0f, 0.0f)); var header2 = new UISequentialContainer(new Vector2(5.0f, 110.0f), new Vector2(screenWidth, 100.0f), false); // счет врагов counter = new UISequentialContainer(Vector2.Zero, new Vector2(200.0f, 100.0f), false) { Background = new NinePartsTextureBackground("Panel"), MainAxis = UISequentialContainer.Alignment.Center, CrossAxis = UISequentialContainer.Alignment.Center }; image = new UIPanel(Vector2.Zero, new Vector2(80.0f, 80.0f)) { Background = new TextureBackground("WolfIcon") }; _wolfCounter = new UIText("0", new Vector2(100.0f, 50.0f), "Text", "Text"); counter.Add(image); counter.Add(_wolfCounter); header2.Add(counter); var ui = new UIMultiElementsContainer(Vector2.Zero, new Vector2(screenWidth, screenHeight)); ui.OnResized += () => header1.Size = ui.Size; ui.OnResized += () => header2.Size = ui.Size; ui.Add(header1); ui.Add(header2); return(ui); }