Esempio n. 1
0
        /// <summary>
        /// Let the user do stuff...
        /// </summary>
        public override void HandleInput()
        {
            if (input == null)
            {
                Mouse.WindowHandle = base.ScreenManager.Game.Window.Handle;
                input = new InputHandler(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
                input.Viewport = new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            }
            else
            {
                Mouse.WindowHandle = base.ScreenManager.Game.Window.Handle;
                Mouse.SetPosition((int)MathHelper.Clamp(Mouse.GetState().X, -10, ScreenManager.GraphicsDevice.Viewport.Width + 10), (int)MathHelper.Clamp(Mouse.GetState().Y, -20, ScreenManager.GraphicsDevice.Viewport.Height + 10));
                input.Update(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
            }

            IsPaused = (input.BackPress || input.StartPress || input.EscPress);

            if (IsPaused)
            {
                ScreenManager.AddScreen(new Backdrop(txBackground, new PauseMenuScreen()), ControllingPlayer);
            }
            else if (input.LeftMBDown)
            {
                foreach (Buyable btn in shopItems)
                    btn.ClickDown(input.Mouse);
            }
            else if (input.LeftMBUp)
            {
                foreach (Buyable btn in shopItems)
                    btn.ClickUp(input.Mouse);
            }
            else if (input.APress || input.LTPress || input.RTPress)
            {
                foreach (Buyable btn in shopItems)
                {
                    btn.ClickDown(input.Mouse);
                    btn.ClickUp(input.Mouse);
                }
            }
            else if (input.SpacePress || input.LBPress)
            {
                Player.cash += 3.05m;
                Player.wantedLevel++;
            }

            if (input != null)
            {
                shopBLUR.setPos((int)(input.Mouse.X - (mouseCursor.Width / 2)), (int)(input.Mouse.Y - (mouseCursor.Height / 2)),
                                 fadeSpeed_X, fadeSpeed_Y);
            }
        }
        /// <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()
        {
            if (input == null)
            {
                input = new InputHandler(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
                input.Viewport = new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            }
            else
            {
                Mouse.SetPosition((int)MathHelper.Clamp(Mouse.GetState().X, -10, ScreenManager.GraphicsDevice.Viewport.Width + 10), (int)MathHelper.Clamp(Mouse.GetState().Y, -20, ScreenManager.GraphicsDevice.Viewport.Height + 10));
                input.Update(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
            }

            // The game pauses either if the user presses the pause button, or if
            // they unplug the active gamepad. This requires us to keep track of
            // whether a gamepad was ever plugged in, because we don't want to pause
            // on PC if they are playing with a keyboard and have no gamepad at all!
            bool IsPaused = (input.BackPress || input.EscPress);

            if (IsPaused)
            {
                input = null;
                ScreenManager.AddScreen(new Backdrop(txBackground, new PauseMenuScreen()), ControllingPlayer);
            }
            else
            {
                if (input.DpadLeftPress || input.LStickLeft || input.LeftPress)
                    selector.Move(Selector.direction.Left);
                else if (input.DpadRightPress || input.LStickRight || input.RightPress)
                    selector.Move(Selector.direction.Right);
                else if (input.StartPress || input.APress || input.EnterPress)
                {
                    character Player = null;
                    if ((Player = AVAILABLE_CHARACTERS.CHARACTERS[selector.character]) != null)
                    {
                        Player.hoboNumber = selector.character;
                        //Gameplay screen begins
                        if (ScreenManager.GlobalOptions.SOUND_ENABLE)
                            seSelect.Play();
                        ScreenManager.AddScreen(new GameplayScreen(Player), ControllingPlayer);
                        //Character selection screen goes away
                        ExitScreen();
                    }
                    else
                        throw new ArgumentNullException("invalid char select");
                }
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameplayScreen(character player)
        {
            TransitionOnTime = TimeSpan.FromSeconds(1.5);
            TransitionOffTime = TimeSpan.FromSeconds(0.5);

            input = new InputHandler(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
            debugMouseAlpha = new Color(255, 255, 255, (byte)0.5);
            Player = player;
            rotation = 0;
            rotationDirection = new Vector2(-1 , 0);
            fadeDirection = new Vector2(1 , 1);
            backgroundScale = 1.25;
            hitboxScale = MathHelper.Clamp((1 - (Player.intoxicationLevel / 100)), 0.40f, 1.00f);
            machineFadeSpeed_X = 1;
            machineFadeSpeed_Y = 1;
            confrontationInterval = random.Next(30000, 300000);
        }
        /// <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()
        {
            if (input == null)
            {
                input = new InputHandler(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
                input.Viewport = new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width, ScreenManager.GraphicsDevice.Viewport.Height);
            }
            else
            {
                Mouse.SetPosition((int)MathHelper.Clamp(Mouse.GetState().X, -10, ScreenManager.GraphicsDevice.Viewport.Width + 10), (int)MathHelper.Clamp(Mouse.GetState().Y, -20, ScreenManager.GraphicsDevice.Viewport.Height + 10));
                input.Update(GamePad.GetState(PlayerIndex.One), Keyboard.GetState(), Mouse.GetState());
            }

            if (input.EnterPress || input.BPress)
                ExitScreen();
        }