Esempio n. 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            IsMouseVisible = true;

            graphics.ToggleFullScreen();
            windowwidth = GraphicsDevice.PresentationParameters.BackBufferWidth;
            windowheight = GraphicsDevice.PresentationParameters.BackBufferHeight;

            //Buttons
            //Schließen-Button
            btnPause = new Button(this);
            btnPause.Texture = Content.Load<Texture2D>("Buttons/btnPause");
            btnPause.TextureSel = Content.Load<Texture2D>("Buttons/btnPauseSel");
            btnPause.Position = new Vector2(windowwidth - 30, 0);
            btnPause.IsVisible = false;
            btnPause.Clicked += btnclose_Clicked;
            this.Components.Add(btnPause);

            //Spiel-Starten-Button
            btnSpStart = new Button(this);
            btnSpStart.Texture = Content.Load<Texture2D>("Buttons/btnSpielStarten");
            btnSpStart.TextureSel = Content.Load<Texture2D>("Buttons/btnSpielStartenSel");
            btnSpStart.Position = new Vector2((windowwidth / 2) - 150, 200);
            btnSpStart.IsVisible = true;
            btnSpStart.Clicked += btnSpStarten_Clicked;
            this.Components.Add(btnSpStart);

            //Beenden-Button
            btnBeenden = new Button(this);
            btnBeenden.Texture = Content.Load<Texture2D>("Buttons/btnBeenden");
            btnBeenden.TextureSel = Content.Load<Texture2D>("Buttons/btnBeendenSel");
            btnBeenden.Position = new Vector2((windowwidth / 2) - 150, 320);
            btnBeenden.IsVisible = true;
            btnBeenden.Clicked += btnBeenden_Clicked;
            this.Components.Add(btnBeenden);

            //Spiel-Fortsetzen-Button
            btnSpFortsetzen = new Button(this);
            btnSpFortsetzen.Texture = Content.Load<Texture2D>("Buttons/btnSpielFortsetzen");
            btnSpFortsetzen.TextureSel = Content.Load<Texture2D>("Buttons/btnSpielFortsetzenSel");
            btnSpFortsetzen.Position = new Vector2((windowwidth / 2) - 150, 230);
            btnSpFortsetzen.IsVisible = true;
            btnSpFortsetzen.Clicked += btnSpFortsetzen_Clicked;
            this.Components.Add(btnSpFortsetzen);

            //Menü-Button
            btnMenu = new Button(this);
            btnMenu.Texture = Content.Load<Texture2D>("Buttons/btnMenu");
            btnMenu.TextureSel = Content.Load<Texture2D>("Buttons/btnMenuSel");
            btnMenu.Position = new Vector2((windowwidth / 2) - 150, 290);
            btnMenu.IsVisible = true;
            btnMenu.Clicked += btnMenu_Clicked;
            this.Components.Add(btnMenu);

            //Spiel-Beitreten-Button
            btnSpBeitreten = new Button(this);
            btnSpBeitreten.Texture = Content.Load<Texture2D>("Buttons/btnSpielBeitreten");
            btnSpBeitreten.TextureSel = Content.Load<Texture2D>("Buttons/btnSpielBeitretenSel");
            btnSpBeitreten.Position = new Vector2((windowwidth / 2) - 150, 260);
            btnSpBeitreten.IsVisible = true;
            btnSpBeitreten.Clicked += btnSpBeitreten_Clicked;
            this.Components.Add(btnSpBeitreten);

            pause = true;
            menu = true;

            abstand.bottom = 10;
            abstand.top = 100;
            abstand.left = 10;
            abstand.right = 400;

            mapwidth = windowwidth - abstand.left - abstand.right;
            mapheight = windowheight - abstand.top - abstand.bottom;

            mousecontrol = new MouseControl(this);
            mousecontrol.abstand.bottom = abstand.bottom;
            mousecontrol.abstand.top = abstand.top;
            mousecontrol.abstand.right = abstand.right;
            mousecontrol.abstand.left = abstand.left;

            mousecontrol.mapwidth = mapwidth;
            mousecontrol.mapheight = mapheight;
            mousecontrol.ZoomIn += mousecontrol_ZoomIn;
            mousecontrol.ZoomOut += mousecontrol_ZoomOut;
            mousecontrol.Drag += mousecontrol_Drag;
            this.Components.Add(mousecontrol);

            liniendicke = 2;

            dragx = 0;
            dragy = 0;
            zoom = 1.0;

            mapColors = new Color[XMAX * YMAX];

            base.Initialize();
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            IsMouseVisible = true;

            graphics.ToggleFullScreen();
            windowwidth  = GraphicsDevice.PresentationParameters.BackBufferWidth;
            windowheight = GraphicsDevice.PresentationParameters.BackBufferHeight;


            //Buttons
            //Schließen-Button
            btnPause            = new Button(this);
            btnPause.Texture    = Content.Load <Texture2D>("Buttons/btnPause");
            btnPause.TextureSel = Content.Load <Texture2D>("Buttons/btnPauseSel");
            btnPause.Position   = new Vector2(windowwidth - 30, 0);
            btnPause.IsVisible  = false;
            btnPause.Clicked   += btnclose_Clicked;
            this.Components.Add(btnPause);

            //Spiel-Starten-Button
            btnSpStart            = new Button(this);
            btnSpStart.Texture    = Content.Load <Texture2D>("Buttons/btnSpielStarten");
            btnSpStart.TextureSel = Content.Load <Texture2D>("Buttons/btnSpielStartenSel");
            btnSpStart.Position   = new Vector2((windowwidth / 2) - 150, 200);
            btnSpStart.IsVisible  = true;
            btnSpStart.Clicked   += btnSpStarten_Clicked;
            this.Components.Add(btnSpStart);

            //Beenden-Button
            btnBeenden            = new Button(this);
            btnBeenden.Texture    = Content.Load <Texture2D>("Buttons/btnBeenden");
            btnBeenden.TextureSel = Content.Load <Texture2D>("Buttons/btnBeendenSel");
            btnBeenden.Position   = new Vector2((windowwidth / 2) - 150, 320);
            btnBeenden.IsVisible  = true;
            btnBeenden.Clicked   += btnBeenden_Clicked;
            this.Components.Add(btnBeenden);

            //Spiel-Fortsetzen-Button
            btnSpFortsetzen            = new Button(this);
            btnSpFortsetzen.Texture    = Content.Load <Texture2D>("Buttons/btnSpielFortsetzen");
            btnSpFortsetzen.TextureSel = Content.Load <Texture2D>("Buttons/btnSpielFortsetzenSel");
            btnSpFortsetzen.Position   = new Vector2((windowwidth / 2) - 150, 230);
            btnSpFortsetzen.IsVisible  = true;
            btnSpFortsetzen.Clicked   += btnSpFortsetzen_Clicked;
            this.Components.Add(btnSpFortsetzen);

            //Menü-Button
            btnMenu            = new Button(this);
            btnMenu.Texture    = Content.Load <Texture2D>("Buttons/btnMenu");
            btnMenu.TextureSel = Content.Load <Texture2D>("Buttons/btnMenuSel");
            btnMenu.Position   = new Vector2((windowwidth / 2) - 150, 290);
            btnMenu.IsVisible  = true;
            btnMenu.Clicked   += btnMenu_Clicked;
            this.Components.Add(btnMenu);

            //Spiel-Beitreten-Button
            btnSpBeitreten            = new Button(this);
            btnSpBeitreten.Texture    = Content.Load <Texture2D>("Buttons/btnSpielBeitreten");
            btnSpBeitreten.TextureSel = Content.Load <Texture2D>("Buttons/btnSpielBeitretenSel");
            btnSpBeitreten.Position   = new Vector2((windowwidth / 2) - 150, 260);
            btnSpBeitreten.IsVisible  = true;
            btnSpBeitreten.Clicked   += btnSpBeitreten_Clicked;
            this.Components.Add(btnSpBeitreten);



            pause = true;
            menu  = true;

            abstand.bottom = 10;
            abstand.top    = 100;
            abstand.left   = 10;
            abstand.right  = 400;

            mapwidth  = windowwidth - abstand.left - abstand.right;
            mapheight = windowheight - abstand.top - abstand.bottom;

            mousecontrol = new MouseControl(this);
            mousecontrol.abstand.bottom = abstand.bottom;
            mousecontrol.abstand.top    = abstand.top;
            mousecontrol.abstand.right  = abstand.right;
            mousecontrol.abstand.left   = abstand.left;

            mousecontrol.mapwidth  = mapwidth;
            mousecontrol.mapheight = mapheight;
            mousecontrol.ZoomIn   += mousecontrol_ZoomIn;
            mousecontrol.ZoomOut  += mousecontrol_ZoomOut;
            mousecontrol.Drag     += mousecontrol_Drag;
            this.Components.Add(mousecontrol);

            liniendicke = 2;

            dragx = 0;
            dragy = 0;
            zoom  = 1.0;

            mapColors = new Color[XMAX * YMAX];


            base.Initialize();
        }