Beispiel #1
0
        private void LoadContent()
        {
            P_sign.LoadContent(0, 0, false, new Vector2(GameSettings.Instance.Dimensions.X / 2732f, GameSettings.Instance.Dimensions.Y / 1536f));
            P_poster.LoadContent(pos_X: 0,
                                 pos_Y: (int)(350 * (GameSettings.Instance.Dimensions.Y / 1080f)),
                                 centered: true,
                                 scale: new Vector2(GameSettings.Instance.Dimensions.X / 1920f, GameSettings.Instance.Dimensions.Y / 1080f));

            for (int i = 0; i < P_text.Length; i++)
            {
                P_menuItems[i].LoadContent(i);
                P_menuLenght.Y += P_menuItems[i].Text.SourceRect.Height;
            }
            P_menuPosition.Y = P_poster.Position.Y + (((P_poster.SourceRect.Height) - P_menuLenght.Y) / 2);

            float temp = 0;

            for (int i = 0; i < P_text.Length; i++)
            {
                if (i > 0)
                {
                    temp += P_menuItems[i - 1].Text.SourceRect.Height / 2;
                    P_menuItems[i].Position.Y = P_menuPosition.Y + temp;
                }
                else
                {
                    P_menuItems[i].Position.Y = P_menuPosition.Y;
                }

                P_menuItems[i].Position.X = P_poster.Position.X + P_poster.SourceRect.Width / 2;
                P_menuItems[i].SetPosition();
            }
        }
Beispiel #2
0
 public void Draw(SpriteBatch spriteBatch)
 {
     P_sign.Draw(spriteBatch);
     P_poster.Draw(spriteBatch);
     for (int i = 0; i < P_text.Length; i++)
     {
         P_menuItems[i].Draw(spriteBatch);
     }
 }
Beispiel #3
0
        public void Update(GameTime gameTime)
        {
            P_sign.Update(gameTime);
            P_poster.Update(gameTime);

            //If the down key is selected then move the selected 1 down
            if (InputManager.Instance.KeyPressed(Keys.Down) || ScreenManager.Instance.Controllers[0].Down(true))
            {
                P_menuItems[P_currentSelected].Selected = false;
                P_currentSelected++;
                if (P_currentSelected == P_text.Length)
                {
                    P_currentSelected = 0;
                }
                P_menuItems[P_currentSelected].Selected = true;
            }

            //If the up key is selected then move the selected 1 up
            if (InputManager.Instance.KeyPressed(Keys.Up) || ScreenManager.Instance.Controllers[0].Up(true))
            {
                P_menuItems[P_currentSelected].Selected = false;
                P_currentSelected--;
                if (P_currentSelected == -1)
                {
                    P_currentSelected = P_text.Length - 1;
                }
                P_menuItems[P_currentSelected].Selected = true;
            }

            int continueID = -1;

            foreach (PauseMenuItem item in P_menuItems)
            {
                continueID = item.GetID("Continue");
                if (continueID != -1)
                {
                    break;
                }
            }
            if (P_menuItems[P_currentSelected].ItemID == continueID && ((InputManager.Instance.KeyPressed(Keys.Enter)) || ScreenManager.Instance.Controllers[0].A_Button(true)) && continueID != -1)
            {
                Pause = true;
            }

            int ConnectID = -1;

            foreach (PauseMenuItem item in P_menuItems)
            {
                ConnectID = item.GetID("Connect/Disconnect controller");
                if (ConnectID != -1)
                {
                    break;
                }
            }
            if (P_menuItems[P_currentSelected].ItemID == ConnectID && ((InputManager.Instance.KeyPressed(Keys.Enter)) || ScreenManager.Instance.Controllers[0].A_Button(true)) && continueID != -1)
            {
            }

            int exitID = -1;

            foreach (PauseMenuItem item in P_menuItems)
            {
                exitID = item.GetID("Exit to menu");
                ScreenManager.Instance.Controllers[0].SaveSettings();
                if (exitID != -1)
                {
                    break;
                }
            }
            //If the Exit button is selected and Enter has been pressed exit the game
            if (P_menuItems[P_currentSelected].ItemID == exitID && ((InputManager.Instance.KeyPressed(Keys.Enter)) || ScreenManager.Instance.Controllers[0].A_Button(true)) && exitID != -1)
            {
                ScreenManager.Instance.ChangeScreen("MenuScreen");
            }

            for (int i = 0; i < P_text.Length; i++)
            {
                P_menuItems[i].Update(gameTime);
            }
        }
Beispiel #4
0
 public void UnloadContent()
 {
     P_sign.UnloadContent();
     P_poster.UnloadContent();
 }