コード例 #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            // DEPENDING ON WHICH BOOLEAN IS TRUE, IT DRAWS!

            spriteBatch.Begin();
            if (gamestate.Loading_Screen == true)
            {
                Loading_and_Menu.The_Loading_Screen(graphics, All_Textures, spriteBatch, gamestate);
            }

            if (gamestate.Main_Game == true)
            {
                spriteBatch.Draw(All_Textures.day_time_background, Vector2.Zero, Color.White);
                spriteBatch.DrawString(All_Textures.Arial_12, "Back to menu", new Vector2(700, 10), Color.Black);
                Monument.DrawAllMonumenten(spriteBatch, All_Textures.Arial_12, Monumentenlijst);
            }

            if (gamestate.Main_Menu == true)
            {
                Main_Menu_Screen.Draw_The_Menu(graphics, All_Textures, spriteBatch);
            }


            spriteBatch.End();


            base.Draw(gameTime);
        }
コード例 #2
0
        NpgsqlCommand cmd;              //For communicating with the server given to it in Program.cs

        public Game1(NpgsqlCommand cmd)
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            gamestate        = new GameState(All_Textures, oldState, oldMouse);
            Main_Menu_Screen = new Loading_and_Menu(cmd, new Rectangle(290, 435, 70, 25), new Rectangle(445, 435, 70, 25), new Rectangle(710, 10, 100, 20));

            this.cmd = cmd;
        }
コード例 #3
0
ファイル: GameState.cs プロジェクト: ChavaDekker/Project4
        public void UpdateWithInput(GraphicsDeviceManager graphics, List <Monument> Monumentenlijst, Loading_and_Menu Main_menu_instance, float Screen_Width_Ratio, float Screen_Height_Ratio)
        {
            KeyboardState newState = Keyboard.GetState();
            MouseState    newMouse = Mouse.GetState();                                      //Beneath stands the monogame/mouse ratio!!!


            float   ThisWillBeX         = newMouse.X * (Screen_Width_Ratio);     //Matches the pixel resolution with the mouse position
            float   ThisWillBeY         = newMouse.Y * (Screen_Height_Ratio);
            Vector2 NewMouseCoordinates = new Vector2(ThisWillBeX, ThisWillBeY); //Puts them together


            // Is the key down?
            if (newState.IsKeyDown(Keys.A))                                      //press A to change full screen mode, or don't
            {
                // If not down last update, key has just been pressed.
                if (!this.oldState.IsKeyDown(Keys.A))
                {
                    this.ChangeFullScreenMode(graphics);
                }
            }

            else if (this.oldState.IsKeyDown(Keys.A))
            {
                // Key was down last update, but not down now, so
                // it has just been released.
            }

            //Depending on which gamestate boolean is true, it checks if the mouse clicked in one of the areas linked with it.

            if (newMouse.LeftButton == ButtonState.Pressed)
            {
                // If not down last update, key has just been pressed.
                if (this.oldMouse.LeftButton != ButtonState.Pressed)
                {
                    if (this.Main_Game == true) //Every pin gets folded
                    {
                        foreach (Monument Monumentje in Monumentenlijst)
                        {
                            Monumentje.Pin_Un_Folded = false;
                        }

                        foreach (Monument Monumentje in Monumentenlijst) //If mouse is in one of the rectangles, unfold that pin
                        {
                            if (Monumentje.Click_area.Contains(NewMouseCoordinates.X, NewMouseCoordinates.Y))
                            {
                                Monumentje.ToggleFoldPin();
                            }
                        }

                        //If pressed on the word "menu", change gamestate booleans leading to main menu
                        if (Main_menu_instance.Click_area_exit.Contains(NewMouseCoordinates.X, NewMouseCoordinates.Y))
                        {
                            this.NextStep("Main_Menu");
                        }
                    }

                    else if (this.Main_Menu == true) //If in main menu, determine next gamestate
                    {
                        if (Main_menu_instance.Click_area_exit.Contains(NewMouseCoordinates.X, NewMouseCoordinates.Y))
                        {
                            Program.Game.Exit();
                        }
                        if (Main_menu_instance.Click_area_Start_map.Contains(NewMouseCoordinates.X, NewMouseCoordinates.Y))
                        {
                            this.NextStep("Main_Game");
                        }
                        if (Main_menu_instance.Click_area_start_graph.Contains(NewMouseCoordinates.X, NewMouseCoordinates.Y))
                        {
                            this.NextStep("Windows_Form");
                        }
                    }
                }
            }

            else if (this.oldMouse.LeftButton == ButtonState.Pressed)
            {
            }

            // Update saved state.
            this.oldState = newState;
            this.oldMouse = newMouse;
        }