예제 #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);
        }
예제 #2
0
        public override void Init(Game game)
        {
            base.Init(game);
            GuiButton restart = new GuiButton("Restart", Width / 2 - 50, Height / 2, 100, 20)
            {
                Background = Color.Gray
            };

            restart.OnClick += (object sender, MouseEventArgs args) =>
            {
                if (restart.OnHover(args) && !loading)
                {
                    //In einem neuen Thread, damit die Form nicht hängt
                    new Thread(() =>
                    {
                        loading = true;
                        game.LoadIngame(false); //Laden des IngameSpiels
                        game.SetScreen(null);   //Setzten des Ingame-Fokuses
                    }).Start();
                }
            };
            Components.Add(restart);
        }
예제 #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);
        }