Пример #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameplayScreen()
        {
            TransitionOnTime = TimeSpan.FromSeconds(1.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            pauseAction = new InputAction(
                new Buttons[] { Buttons.Start, Buttons.Back },
                new Keys[] { Keys.Escape },
                true);

            continueAction = new InputAction(
                new Buttons[] { Buttons.A , Buttons.B },
                new Keys[] { Keys.Space, Keys.Enter, Keys.NumPad0, Keys.NumPad1, Keys.NumPad2, Keys.NumPad3, Keys.NumPad4, Keys.NumPad5, Keys.NumPad6, Keys.NumPad7, Keys.NumPad8, Keys.NumPad9, },
                true);

            // set day
            Day = 1;
            NPCs = Character.CreateCharacters();
            Player = Character.CreatePlayer();

            Responses = Dialogue.getDialogueRoot(Day, Player);
            Response = Dialogue.ParseResponses(Responses);
            choices = Dialogue.getDialogueChoices(Day, Response.children);
        }
Пример #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
            this.IsMouseVisible = true;
            graphics.PreferredBackBufferWidth = 1440;
            graphics.PreferredBackBufferHeight = 900;
            graphics.ApplyChanges();

            //create characters and player
            // set day
            Day = 1;
            NPCs = Character.CreateCharacters();
            Player = Character.CreatePlayer();

            Responses = Dialogue.getDialogueRoot(Day, Player);
            Response = Dialogue.ParseResponses(Responses);
            choices = Dialogue.getDialogueChoices(Day, Response.children);
            base.Initialize();
        }
Пример #3
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            KeyboardState KeyState = Keyboard.GetState();

            PlayerIndex player;

            if (pauseAction.Evaluate(input, ControllingPlayer, out player))
            {
                ScreenManager.AddScreen(new PauseMenuScreen(), ControllingPlayer);

                // if there is only one choice with text "", its a blank joiner used to space out responses in a monologue something similar.
                // In this case, allow any keystroke to advance.
            } else if (oldState.IsKeyUp(pressedKeys) && (KeyState.GetPressedKeys().Length > 0))

                {
                    if (continueAction.Evaluate(input, ControllingPlayer, out player) && choices.Count == 1)
                    {
                        if (choices[0].Text == "")
                            Response = Dialogue.getResponses(Day, choices[0].children);
                        choices = Dialogue.getDialogueChoices(Day, Response.children);
                        pressedKeys = KeyState.GetPressedKeys().First();
                    }
                    else
                    {
                        if (KeyState.IsKeyDown(Keys.NumPad1) && (choices[0] != null))
                        {
                            Response = Dialogue.getResponses(Day, choices[0].children);
                            choices = Dialogue.getDialogueChoices(Day, Response.children);
                            pressedKeys = Keys.NumPad1;
                        }

                        if (KeyState.IsKeyDown(Keys.NumPad2) && (choices[1] != null))
                        {
                            Response = Dialogue.getResponses(Day, choices[1].children);
                            choices = Dialogue.getDialogueChoices(Day, Response.children);
                            pressedKeys = Keys.NumPad2;
                        }

                        if (KeyState.IsKeyDown(Keys.NumPad3) && (choices[2] != null))
                        {
                            Response = Dialogue.getResponses(Day, choices[2].children);
                            choices = Dialogue.getDialogueChoices(Day, Response.children);
                            pressedKeys = Keys.NumPad3;
                        }

                        if (KeyState.IsKeyDown(Keys.NumPad4) && (choices[3] != null))
                        {
                            Response = Dialogue.getResponses(Day, choices[3].children);
                            choices = Dialogue.getDialogueChoices(Day, Response.children);
                            pressedKeys = Keys.NumPad4;
                        }

                        if (KeyState.IsKeyDown(Keys.NumPad5) && (choices[4] != null))
                        {
                            Response = Dialogue.getResponses(Day, choices[4].children);
                            choices = Dialogue.getDialogueChoices(Day, Response.children);
                            pressedKeys = Keys.NumPad5;
                        }
                    }
            }
            oldState = KeyState;
        }
Пример #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            KeyboardState KeyState = Keyboard.GetState();

            // if there is only one choice with text "", its a blank joiner used to space out responses in a monologue something similar.
            // In this case, allow any keystroke to advance.
            if (oldState.IsKeyUp(pressedKeys) && (KeyState.GetPressedKeys().Length > 0))

            {
                if ((KeyState.GetPressedKeys().Length > 0) && choices.Count == 1)
                {
                    if (choices[0].Text == "")
                        Response = Dialogue.getResponses(Day, choices[0].children);
                    choices = Dialogue.getDialogueChoices(Day, Response.children);
                    pressedKeys = KeyState.GetPressedKeys().First();
                }
                else
                {
                    if (KeyState.IsKeyDown(Keys.NumPad1) && (choices[0] != null))
                    {
                        Response = Dialogue.getResponses(Day, choices[0].children);
                        choices = Dialogue.getDialogueChoices(Day, Response.children);
                        pressedKeys = Keys.NumPad1;
                    }

                    if (KeyState.IsKeyDown(Keys.NumPad2) && (choices[1] != null))
                    {
                        Response = Dialogue.getResponses(Day, choices[1].children);
                        choices = Dialogue.getDialogueChoices(Day, Response.children);
                        pressedKeys = Keys.NumPad2;
                    }

                    if (KeyState.IsKeyDown(Keys.NumPad3) && (choices[2] != null))
                    {
                        Response = Dialogue.getResponses(Day, choices[2].children);
                        choices = Dialogue.getDialogueChoices(Day, Response.children);
                        pressedKeys = Keys.NumPad3;
                    }

                    if (KeyState.IsKeyDown(Keys.NumPad4) && (choices[3] != null))
                    {
                        Response = Dialogue.getResponses(Day, choices[3].children);
                        choices = Dialogue.getDialogueChoices(Day, Response.children);
                        pressedKeys = Keys.NumPad4;
                    }

                    if (KeyState.IsKeyDown(Keys.NumPad5) && (choices[4] != null))
                    {
                        Response = Dialogue.getResponses(Day, choices[4].children);
                        choices = Dialogue.getDialogueChoices(Day, Response.children);
                        pressedKeys = Keys.NumPad5;
                    }
                }
            }
                oldState = KeyState;
            // TODO: Add your update logic here

            base.Update(gameTime);
        }