示例#1
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     spriteBatch = new SpriteBatch(GraphicsDevice);
     RandomlyGeneratedStateSpace firstStateSpace = new RandomlyGeneratedStateSpace(new CaveGeneration(), 75, 125);
     PlayingState firstState = new PlayingState(firstStateSpace, gameCamera, Content, graphics);
     stateStack.Push(firstState);
 }
示例#2
0
        public IState UpdateContent(GameTime gameTime, Camera camera, ref GameSettings gameSettings)
        {
            camera.Position = Vector2.Zero;
            camera.Target   = Vector2.Zero;
            IState        nextState = this;
            KeyboardState keyState  = Keyboard.GetState();

            if (keyState.IsKeyDown(Keys.Up) && PrevKeyboardState.IsKeyUp(Keys.Up))
            {
                optionSelection -= 1;
                if (optionSelection < 0)
                {
                    optionSelection = optionsAmount - 1;
                }
                if (optionSelection >= optionsAmount)
                {
                    optionSelection = 0;
                }
                while (!menuOptions[optionSelection].Enabled)
                {
                    optionSelection -= 1;
                }
            }
            else if (keyState.IsKeyDown(Keys.Down) && PrevKeyboardState.IsKeyUp(Keys.Down))
            {
                optionSelection += 1;
                if (optionSelection < 0)
                {
                    optionSelection = optionsAmount - 1;
                }
                if (optionSelection >= optionsAmount)
                {
                    optionSelection = 0;
                }
                while (!menuOptions[optionSelection].Enabled)
                {
                    optionSelection += 1;
                }
            }

            else if (keyState.IsKeyDown(Keys.Enter) && PrevKeyboardState.IsKeyUp(Keys.Enter))
            {
                switch (optionSelection)
                {
                case (int)Options.NEW_GAME:
                    RandomlyGeneratedStateSpace nextStateSpace = new RandomlyGeneratedStateSpace(new CaveGeneration(), 75, 125);
                    nextState = new PlayingState(nextStateSpace, camera, Content, Graphics, this, keyboardState: keyState);
                    break;

                case (int)Options.LOAD_GAME:
                    RandomlyGeneratedStateSpace nextSpace = new RandomlyGeneratedStateSpace(DungeonInfo);
                    nextState = new PlayingState(nextSpace, camera, Content, Graphics, saveInfo: DungeonInfo, keyboardState: keyState);
                    break;

                case (int)Options.OPTIONS:
                    GameSettingsMenuStateSpace nextMenu = new GameSettingsMenuStateSpace(ref gameSettings);
                    nextState = new MenuState(nextMenu, camera, Content, Graphics, this, keyboardState: keyState);
                    break;

                case (int)Options.QUIT_GAME:
                    nextState = previousState;
                    break;
                }
            }

            PrevKeyboardState = Keyboard.GetState();
            PrevMouseState    = Mouse.GetState();
            PrevGamepadState  = GamePad.GetState(PlayerIndex.One);
            return(nextState);
        }
示例#3
0
        public IState UpdateContent(GameTime gameTime, Camera camera, ref GameSettings gameSettings)
        {
            camera.Position = Vector2.Zero;
            camera.Target = Vector2.Zero;
            IState nextState = this;
            KeyboardState keyState = Keyboard.GetState();
            if (keyState.IsKeyDown(Keys.Up) && PrevKeyboardState.IsKeyUp(Keys.Up))
            {
                optionSelection -= 1;
                if (optionSelection < 0)
                {
                    optionSelection = optionsAmount - 1;
                }
                if (optionSelection >= optionsAmount)
                {
                    optionSelection = 0;
                }
                while (!menuOptions[optionSelection].Enabled)
                {
                    optionSelection -= 1;
                }
            }
            else if (keyState.IsKeyDown(Keys.Down) && PrevKeyboardState.IsKeyUp(Keys.Down))
            {
                optionSelection += 1;
                if (optionSelection < 0)
                {
                    optionSelection = optionsAmount - 1;
                }
                if (optionSelection >= optionsAmount)
                {
                    optionSelection = 0;
                }
                while (!menuOptions[optionSelection].Enabled)
                {
                    optionSelection += 1;
                }
            }

            else if (keyState.IsKeyDown(Keys.Enter) && PrevKeyboardState.IsKeyUp(Keys.Enter))
            {
                switch (optionSelection)
                {
                    case (int)Options.NEW_GAME:
                        RandomlyGeneratedStateSpace nextStateSpace = new RandomlyGeneratedStateSpace(new CaveGeneration(), 75, 125);
                        nextState = new PlayingState(nextStateSpace, camera, Content, Graphics, this, keyboardState: keyState);
                        break;
                    case (int)Options.LOAD_GAME:
                        RandomlyGeneratedStateSpace nextSpace = new RandomlyGeneratedStateSpace(DungeonInfo);
                        nextState = new PlayingState(nextSpace, camera, Content, Graphics, saveInfo: DungeonInfo, keyboardState: keyState);
                        break;
                    case (int)Options.OPTIONS:
                        GameSettingsMenuStateSpace nextMenu = new GameSettingsMenuStateSpace(ref gameSettings);
                        nextState = new MenuState(nextMenu, camera, Content, Graphics, this, keyboardState: keyState);
                        break;
                    case (int)Options.QUIT_GAME:
                        nextState = previousState;
                        break;
                }
            }

            PrevKeyboardState = Keyboard.GetState();
            PrevMouseState = Mouse.GetState();
            PrevGamepadState = GamePad.GetState(PlayerIndex.One);
            return nextState;
        }