Ejemplo n.º 1
0
        public override void Init(Game game)
        {
            base.Init(game);
            loading = false;
            //Button zum erneuten spielen
            GuiButton start = new GuiButton("Restart", Width / 2 - 50, Height / 2, 100, 20)
            {
                Background = Color.White
            };

            start.OnClick += (object sender, MouseEventArgs e) =>
            {
                if (loading || !start.OnHover(e)) //nur ausführen wenn auch über dem Button
                {
                    return;
                }
                //In einem neuen Thread, damit die Form nicht hängt
                new Thread(() =>
                {
                    loadingText = "Loading";
                    loading     = true;
                    game.LoadIngame(hard); //Laden des IngameSpiels
                    game.SetScreen(null);  //Setzten des Ingame-Fokuses
                }).Start();
            };
            //Erstellen eines Buttons für das Beenden des Spieles
            GuiButton quit = new GuiButton("Quit", Width / 2 - 50, Height / 2 + 30, 100, 20)
            {
                Background = Color.White
            };

            quit.OnClick += (object sender, MouseEventArgs e) =>
            {
                if (loading || !quit.OnHover(e))
                {
                    return;
                }
                Application.Exit();
            };
            //Ob der Modus Hard aktiviert werden soll
            GuiCheckbox box = new GuiCheckbox("Hard", false)
            {
                Position = new Vector(Width / 2 - 50, Height / 2 - 30),
                Size     = new Vector(100, 20)
            };

            box.OnClick += (object sender, MouseEventArgs args) =>
            {
                hard = box.State;
            };
            Components.Add(box);
            Components.Add(start);
            Components.Add(quit);
        }
Ejemplo n.º 2
0
        public override void Show()
        {
            base.Show();

            var guiLayer = new GuiLayer(GraphicsDevice, Game.Camera);

            Layers.Add(guiLayer);

            var guiButtonRegion = AssetManager.Load <Texture>("play-button.png").ToTextureRegion();
            var guiButton       = new GuiButton(guiButtonRegion)
            {
                Position = new Vector2(400, 240)
            };

            guiLayer.Controls.Add(guiButton);
            _mouseCursor = guiButton;

            var font     = AssetManager.Load("courier-new-32.fnt", new BitmapFontLoader());
            var guiLabel = new GuiLabel(font)
            {
                Text = "This is a label",
                HorizontalAlignment = HorizontalAlignment.Left,
                Position            = new Vector2(100, 100),
                TextColor           = Color.Black
            };

            guiLayer.Controls.Add(guiLabel);

            var guiImageTexture = AssetManager.Load <Texture>("photo.png");
            var guiImage        = new GuiImage(guiImageTexture)
            {
                Position = new Vector2(800, 0),
                Origin   = new Vector2(1.0f, 0.0f)
            };

            guiLayer.Controls.Add(guiImage);

            var guiCheckboxTexture = AssetManager.Load <Texture>("play-button.png");
            var guiCheckbox        = new GuiCheckbox(guiCheckboxTexture.ToTextureRegion())
            {
                Position = new Vector2(500, 100),
            };

            guiLayer.Controls.Add(guiCheckbox);
        }
Ejemplo n.º 3
0
        public override void Init(Game game)
        {
            base.Init(game);
            loading = false;
            GuiButton start = new GuiButton("Start", Width / 2 - 50, Height / 2, 100, 20)
            {
                Background = Color.Gray
            };

            start.OnClick += (object sender, MouseEventArgs e) =>
            {
                if (loading || !start.OnHover(e)) //nur ausführen wenn auch über dem Button
                {
                    return;
                }
                //In einem neuen Thread, damit die Form nicht hängt
                new Thread(() =>
                {
                    loadingText = "Loading";
                    loading     = true;
                    game.LoadIngame(hard); //Laden des IngameSpiels
                    game.SetScreen(null);  //Setzten des Ingame-Fokuses
                }).Start();
            };
            GuiCheckbox box = new GuiCheckbox("Hard", false)
            {
                Position = new Vector(Width / 2 - 50, Height / 2 - 30),
                Size     = new Vector(100, 20)
            };

            box.OnClick += (object sender, MouseEventArgs args) =>
            {
                hard = box.State;
            };
            Components.Add(box);
            Components.Add(start);
        }