Ejemplo n.º 1
0
        public override void HandleInput(InputState input)
        {
            if (!gamerSelected)
            {
                for (int i = 0; i < InputState.MaxInputs; i++)
                {
                    if (input.CurrentGamePadStates[i].IsButtonDown(Buttons.Start) == true && input.PreviousGamePadStates[i].IsButtonUp(Buttons.Start) == true ||
                        input.CurrentKeyboardStates[i].IsKeyDown(Keys.Enter) == true && input.PreviousKeyboardStates[i].IsKeyUp(Keys.Enter) ||
                        input.CurrentKeyboardStates[i].IsKeyDown(Keys.Space) == true && input.PreviousKeyboardStates[i].IsKeyUp(Keys.Space))
                    {
                        gamerOne = Gamer.SignedInGamers[(PlayerIndex)i];

                        gamerSelected = true;

                        if (gamerOne == null)
                        {
                            if (!Guide.IsVisible)
                            {
                                Guide.ShowSignIn(1, false);
                            }
                        }
                    }
                }
            }
        }
 public override void HandleInput(InputState input)
 {
     if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Back) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Back))
     {
         this.ExitScreen();
     }
 }
        public override void HandleInput(InputState input)
        {
            if (input.CurrentGamePadStates[(int)PlayerIndex.One].Buttons.Y == ButtonState.Pressed && input.PreviousGamePadStates[(int)PlayerIndex.One].Buttons.Y == ButtonState.Released)
            {
                const string message = "Are you sure you want to delete this file?";

                MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true);

                confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

                ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
            }

            base.HandleInput(input);
        }
Ejemplo n.º 4
0
        public override void HandleInput(InputState input)
        {
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.I) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.I))
            {
                if (!isInverted)
                {
                    scalar = 0;
                    isInverted = true;
                }
                else
                {
                    scalar = 0;
                    isInverted = false;
                }
            }

            base.HandleInput(input);
        }
Ejemplo n.º 5
0
        public override void HandleInput(InputState input)
        {
            int playerIndex = (int)ControllingPlayer.Value;

            if (input.CurrentGamePadStates[playerIndex].Buttons.A == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.A == ButtonState.Released && scrollScreen)
            {
                scrollScreen = false;
            }
            else if (input.CurrentGamePadStates[playerIndex].Buttons.A == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.A == ButtonState.Released && !scrollScreen)
            {
                scrollScreen = true;
            }
            else if (input.CurrentGamePadStates[playerIndex].Buttons.B == ButtonState.Pressed && input.PreviousGamePadStates[playerIndex].Buttons.B == ButtonState.Released)
            {
                this.ExitScreen();
            }

            base.HandleInput(input);
        }
        public override void HandleInput(InputState input)
        {
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Back) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Back))
            {
                this.ExitScreen();
            }
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Delete) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Delete))
            {
                const string message = "Are you sure you want to delete this file?";

                MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message, true);

                confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

                ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
            }

            base.HandleInput(input);
        }
        public override void HandleInput(InputState input)
        {
            PlayerIndex playerIndex;
            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {

                if (Accepted != null)
                    Accepted(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                if (Cancelled != null)
                    Cancelled(this, new PlayerIndexEventArgs(playerIndex));

                ExitScreen();
            }
        }
Ejemplo n.º 8
0
        public override void HandleInput(InputState input)
        {
            if (input.CurrentMouseStates[(int)PlayerIndex.One].LeftButton == ButtonState.Pressed && input.PreviousMouseStates[(int)PlayerIndex.One].LeftButton == ButtonState.Released)
            {

                if (!isVoided)
                {
                    isVoided = true;
                    renderTarget = new Rectangle((int)input.CurrentMouseStates[(int)PlayerIndex.One].X, (int)input.CurrentMouseStates[(int)PlayerIndex.One].Y, 100, 100);
                }
                else
                {
                    isVoided = false;
                }

            }

            renderTargetReferenceRectangle.X = input.CurrentMouseStates[(int)PlayerIndex.One].X;
            renderTargetReferenceRectangle.Y = input.CurrentMouseStates[(int)PlayerIndex.One].Y;

            base.HandleInput(input);
        }
Ejemplo n.º 9
0
        public override void HandleInput(InputState input)
        {
            mousePoint = new Point((int)(input.CurrentMouseStates[(int)PlayerIndex.One].X), (int)(input.CurrentMouseStates[(int)PlayerIndex.One].Y));

            if (zoomScale > 1.0f || zoomScale < 1.0f)
            {
                #region Move Zoomed Screen
                if (input.CurrentMouseStates[(int)PlayerIndex.One].LeftButton == ButtonState.Pressed)
                {

                    if (input.CurrentMouseStates[(int)PlayerIndex.One].X != input.PreviousMouseStates[(int)PlayerIndex.One].X)
                    {

                        cameraPosition -= new Vector2(input.CurrentMouseStates[(int)PlayerIndex.One].X - input.PreviousMouseStates[(int)PlayerIndex.One].X, input.CurrentMouseStates[(int)PlayerIndex.One].Y - input.PreviousMouseStates[(int)PlayerIndex.One].Y);

                    }
                }
                #endregion
            }
            else
            {
                #region Pause
                KeyboardState keyboardState = input.CurrentKeyboardStates[(int)PlayerIndex.One];
                GamePadState gamePadState = input.CurrentGamePadStates[(int)PlayerIndex.One];

                bool playerOneGamePadDisconnected = !gamePadState.IsConnected &&
                                            input.GamePadWasConnected[(int)PlayerIndex.One];

                //...if so then pause and wait
                if (input.IsPauseGame(PlayerIndex.One) || playerOneGamePadDisconnected)
                {
                    if (LevelName != null)
                    {
                        ScreenManager.AddScreen(new PauseMenuScreen(Tiles, Backgrounds, LevelName, scrollOffset), PlayerIndex.One);

                    }
                    else
                    {
                        ScreenManager.AddScreen(new PauseMenuScreen(Tiles, Backgrounds, String.Empty, scrollOffset), PlayerIndex.One);
                    }

                }
                #endregion

                #region GetTiles
                //add references here
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.LeftShift) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.LeftShift))
                {
                    ScreenManager.AddScreen(new ObjectSelection(tileReferenceBlocks, tileReferenceSceneries, tileReferenceSlopes, tileSelectionBox, fileReferences, SpriteBatch), PlayerIndex.One);
                }

                #endregion

                #region GetBackgrounds

                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.RightShift) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.RightShift))
                {
                    //do this for background creation
                    ScreenManager.AddScreen(new ObjectSelectionBackgrounds(normalBackgroundReferences, otherBackgroundReferences, backgroundFileReferences, tileSelectionBox, SpriteBatch), PlayerIndex.One);
                }

                #endregion

                #region SelectAllowedObject
                if (!tileSelected && !backgroundSelected)
                {
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D1) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D1))
                    {
                        allowedObject = AllowedObject.Tile;

                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D2) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D2))
                    {
                        allowedObject = AllowedObject.Background;

                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D3) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D3))
                    {
                        allowedObject = AllowedObject.Scenery;

                    }
                    if (input.CurrentMouseStates[(int)PlayerIndex.One].ScrollWheelValue > input.PreviousMouseStates[(int)PlayerIndex.One].ScrollWheelValue)
                    {
                        allowedObject--;

                        if (allowedObject < 0)
                            allowedObject = AllowedObject.Scenery;
                    }
                    if (input.CurrentMouseStates[(int)PlayerIndex.One].ScrollWheelValue < input.PreviousMouseStates[(int)PlayerIndex.One].ScrollWheelValue)
                    {
                        allowedObject++;

                        if (allowedObject > AllowedObject.Scenery)
                            allowedObject = 0;
                    }

                    if (allowedObject == AllowedObject.Tile)
                    {
                        numberOneColor = Color.Red;
                        numberTwoColor = Color.White;
                        numberThreeColor = Color.White;
                    }
                    else if (allowedObject == AllowedObject.Background)
                    {
                        numberOneColor = Color.White;
                        numberTwoColor = Color.Red;
                        numberThreeColor = Color.White;
                    }
                    else if (allowedObject == AllowedObject.Scenery)
                    {
                        numberOneColor = Color.White;
                        numberTwoColor = Color.White;
                        numberThreeColor = Color.Red;
                    }
                }

                #endregion

                if (!toggleCameraMove)
                {
                    #region SelectObjects Mouse
                    if (input.CurrentMouseStates[(int)PlayerIndex.One].LeftButton == ButtonState.Pressed && input.PreviousMouseStates[(int)PlayerIndex.One].LeftButton == ButtonState.Released ||
                        input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Space) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Space))
                    {
                        if (allowedObject == AllowedObject.Tile || allowedObject == AllowedObject.Scenery)
                        {
                            if (!tileSelected)
                            {
                                for (int i = Tiles.Count - 1; i >= 0; i--)
                                {
                                    if (Tiles[i].type == TileType.Scenery && allowedObject == AllowedObject.Scenery)
                                    {
                                        if (Tiles[i].objectNumber == 15 || Tiles[i].objectNumber == 16)
                                        {
                                            tileRectangles[i] = new Rectangle((int)(Tiles[i].position.X + scrollOffset.X), (int)(Tiles[i].position.Y + scrollOffset.Y), 10, 10);
                                        }
                                        else
                                        {
                                            tileRectangles[i] = new Rectangle((int)(Tiles[i].position.X + scrollOffset.X), (int)(Tiles[i].position.Y + scrollOffset.Y), Tiles[i].sprite.Width, Tiles[i].sprite.Height);
                                        }

                                        if (tileRectangles[i].Contains(mousePoint))
                                        {
                                            tileSelected = true;
                                            tileNumber = i;
                                            break;
                                        }
                                    }
                                    if (Tiles[i].type != TileType.Scenery && allowedObject == AllowedObject.Tile)
                                    {

                                        tileRectangles[i] = new Rectangle((int)(Tiles[i].position.X + scrollOffset.X), (int)(Tiles[i].position.Y + scrollOffset.Y), Tiles[i].sprite.Width, Tiles[i].sprite.Height);

                                        if (tileRectangles[i].Contains(mousePoint))
                                        {
                                            tileSelected = true;
                                            tileNumber = i;
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                tileSelected = false;
                                tileRectangles[tileNumber] = new Rectangle((int)(Tiles[tileNumber].position.X + scrollOffset.X), (int)(Tiles[tileNumber].position.Y + scrollOffset.Y), Tiles[tileNumber].sprite.Width, Tiles[tileNumber].sprite.Height);
                                return;
                            }
                        }
                        if (allowedObject == AllowedObject.Background)
                        {
                            if (!backgroundSelected)
                            {
                                for (int i = Backgrounds.Count - 1; i >= 0; i--)
                                {

                                    backgroundRectangles[i] = new Rectangle((int)(Backgrounds[i].position.X + scrollOffset.X), (int)(Backgrounds[i].position.Y + scrollOffset.Y), Backgrounds[i].sprite.Width, Backgrounds[i].sprite.Height);

                                    if (backgroundRectangles[i].Contains(mousePoint))
                                    {
                                        backgroundSelected = true;
                                        tileNumber = i;
                                        break;
                                    }
                                }
                            }
                            else
                            {

                                backgroundSelected = false;
                                backgroundRectangles[tileNumber] = new Rectangle((int)(Backgrounds[tileNumber].position.X + scrollOffset.X), (int)(Backgrounds[tileNumber].position.Y + scrollOffset.Y), Backgrounds[tileNumber].sprite.Width, Backgrounds[tileNumber].sprite.Height);
                                return;
                            }
                        }
                    }
                    #endregion

                }
                else
                {
                    #region MoveCamera
                    if (input.CurrentMouseStates[(int)PlayerIndex.One].LeftButton == ButtonState.Pressed)
                    {

                        if (input.CurrentMouseStates[(int)PlayerIndex.One].X != input.PreviousMouseStates[(int)PlayerIndex.One].X)
                        {

                            cameraPosition -= new Vector2(input.CurrentMouseStates[(int)PlayerIndex.One].X - input.PreviousMouseStates[(int)PlayerIndex.One].X, input.CurrentMouseStates[(int)PlayerIndex.One].Y - input.PreviousMouseStates[(int)PlayerIndex.One].Y);

                        }
                    }
                    #endregion

                }

                #region Move Tile
                if (tileSelected)
                {

                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.A) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.A))
                    {
                        Tiles[tileNumber].position.X -= 1;
                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D))
                    {
                        Tiles[tileNumber].position.X += 1;
                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.W) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.W))
                    {
                        Tiles[tileNumber].position.Y -= 1;
                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.S) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.S))
                    {
                        Tiles[tileNumber].position.Y += 1;
                    }

                    Tiles[tileNumber].position += new Vector2(input.CurrentMouseStates[(int)PlayerIndex.One].X - input.PreviousMouseStates[(int)PlayerIndex.One].X, input.CurrentMouseStates[(int)PlayerIndex.One].Y - input.PreviousMouseStates[(int)PlayerIndex.One].Y);

                }
                #endregion

                #region MoveBackground

                if (backgroundSelected)
                {

                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.A) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.A))
                    {
                        Backgrounds[tileNumber].position.X -= 1;
                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D))
                    {
                        Backgrounds[tileNumber].position.X += 1;
                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.W) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.W))
                    {
                        Backgrounds[tileNumber].position.Y -= 1;
                    }
                    if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.S) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.S))
                    {
                        Backgrounds[tileNumber].position.Y += 1;
                    }

                    Backgrounds[tileNumber].position += new Vector2(input.CurrentMouseStates[(int)PlayerIndex.One].X - input.PreviousMouseStates[(int)PlayerIndex.One].X, input.CurrentMouseStates[(int)PlayerIndex.One].Y - input.PreviousMouseStates[(int)PlayerIndex.One].Y);
                }

                #endregion

                #region CopyTile

                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.C) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.C))
                {
                    if (tileSelected)
                    {
                        tileSelected = false;
                        LoadTile(Tiles[tileNumber].type, Tiles[tileNumber].objectNumber, Tiles[tileNumber].layerNumber);
                    }
                    if (backgroundSelected)
                    {
                        backgroundSelected = false;
                        LoadBackground(Backgrounds[tileNumber].type, Backgrounds[tileNumber].objectNumber, Backgrounds[tileNumber].layerNumber);
                    }

                }

                #endregion

                #region DeleteTile

                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Delete) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Delete))
                {
                    if (tileSelected)
                    {
                        tileSelected = false;
                        Tiles.RemoveAt(tileNumber);
                    }
                    if (backgroundSelected)
                    {
                        backgroundSelected = false;
                        Backgrounds.RemoveAt(tileNumber);
                    }

                }

                #endregion
            }

            #region Zoom Screen
            if (!tileSelected && !backgroundSelected)
            {
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.OemPlus) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.OemPlus))
                {
                    zoomScale += 0.1f;
                    if (zoomScale > 2.0f)
                        zoomScale -= 0.1f;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.OemMinus) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.OemMinus))
                {
                    zoomScale -= 0.1f;
                    if (zoomScale < 0.0f)
                        zoomScale += 0.1f;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D0) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D0))
                {
                    zoomScale = 1.0f;
                }
            }

            #endregion

            #region ToggleCamera
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.LeftControl))
            {
                toggleCameraMove = true;
            }
            else
            {
                toggleCameraMove = false;
            }
            #endregion
        }
Ejemplo n.º 10
0
        public override void HandleInput(InputState input)
        {
            if (input.IsMenuUp(PlayerIndex.One))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

            if (input.IsMenuDown(PlayerIndex.One))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            PlayerIndex playerIndex;

            if (input.IsMenuSelect(PlayerIndex.One, out playerIndex))
            {
                OnSelectEntry(selectedEntry, playerIndex);

            }
            else if (input.IsMenuCancel(PlayerIndex.One, out playerIndex))
            {

                OnCancel(playerIndex);

            }

            SelectedEntry = selectedEntry;
        }
        public override void HandleInput(InputState input)
        {
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Down) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Down))
            {
                if (tileSelection)
                {
                    tileSelected++;

                    if (type == BackgroundType.Normal)
                    {
                        if (tileSelected == normalBackgroundReferences.Length)
                        {
                            tileSelected = 0;
                        }
                    }
                    if (type == BackgroundType.Other)
                    {
                        if (tileSelected == otherBackgroundReferences.Length)
                        {
                            tileSelected = 0;
                        }
                    }

                    selectionBoxPosition = new Vector2(backgrounds[tileSelected].menuEntryPosition.X, backgrounds[tileSelected].menuEntryPosition.Y);

                }
                else
                {

                    fileSelected++;

                    if (fileSelected == backgroundTypes.Length)
                    {
                        fileSelected = 0;
                    }

                    fileSelectionBoxPosition = new Vector2(backgroundTypes[fileSelected].menuEntryPosition.X, backgroundTypes[fileSelected].menuEntryPosition.Y);

                }

                LevelCreate.tileChosen = false;
                color = Color.White;
            }
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Up) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Up))
            {
                if (tileSelection)
                {
                    tileSelected--;

                    if (type == BackgroundType.Normal)
                    {
                        if (tileSelected < 0)
                        {
                            tileSelected = normalBackgroundReferences.Length - 1;
                        }
                    }
                    if (type == BackgroundType.Other)
                    {
                        if (tileSelected < 0)
                        {
                            tileSelected = otherBackgroundReferences.Length - 1;
                        }
                    }

                    selectionBoxPosition = new Vector2(backgrounds[tileSelected].menuEntryPosition.X, backgrounds[tileSelected].menuEntryPosition.Y);
                }
                else
                {
                    fileSelected--;

                    if (fileSelected < 0)
                    {
                        fileSelected = backgroundTypes.Length - 1;
                    }

                    fileSelectionBoxPosition = new Vector2(backgroundTypes[fileSelected].menuEntryPosition.X, backgroundTypes[fileSelected].menuEntryPosition.Y);

                }

                LevelCreate.tileChosen = false;
                color = Color.White;
            }
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Back) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Back))
            {
                if (tileSelection)
                {
                    if (LevelCreate.tileChosen)
                    {

                        this.ExitScreen();

                    }
                    else
                    {
                        MenuEntries.Clear();

                        foreach (MenuEntry backgroundType in backgroundTypes)
                        {
                            MenuEntries.Add(backgroundType);
                        }

                        tileSelection = false;
                        //isAssigned = false;
                    }
                }
                else
                {
                    this.ExitScreen();
                }
            }

            if (tileSelection)
            {
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D0) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D0))
                {
                    layerSelected = 0;
                    layerOneColor = Color.Red;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.White;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D1) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D1))
                {
                    layerSelected = 1;
                    layerOneColor = Color.White;
                    layerTwoColor = Color.Red;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.White;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D2) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D2))
                {
                    layerSelected = 2;
                    layerOneColor = Color.White;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.Red;
                    layerFourColor = Color.White;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D3) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D3))
                {
                    layerSelected = 3;
                    layerOneColor = Color.White;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.Red;
                }
                if (layerSelected == 0)
                {

                    layerOneColor = Color.Red;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.White;

                }
            }

            base.HandleInput(input);
        }
Ejemplo n.º 12
0
 public virtual void HandleInput(InputState input)
 {
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Check for input
        /// </summary>
        /// <param name="input">grabs the values from InputState</param>
        public override void HandleInput(InputState input)
        {
            if (!LevelCreateSession)
            {

                if (input == null)
                    throw new ArgumentNullException("input");

                //did you disconnect? //Switch this to two players if we want both players to be able to pause
                #region IsPlayerControllerDisconnectedOrOutOfBatteries?

                KeyboardState keyboardState = input.CurrentKeyboardStates[(int)PlayerIndex.One];
                GamePadState gamePadState = input.CurrentGamePadStates[(int)PlayerIndex.One];

                bool playerOneGamePadDisconnected = !gamePadState.IsConnected &&
                                            input.GamePadWasConnected[(int)PlayerIndex.One];

                //...if so then pause and wait
                if (input.IsPauseGame(PlayerIndex.One) || playerOneGamePadDisconnected)
                {

                    ScreenManager.AddScreen(new PauseMenuScreen(), PlayerIndex.One);

                }

                #endregion

                #region Move Left and Right

                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Right))
                {
                    player.velocity.X = 3.0f;
                }
                else if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Left))
                {
                    player.velocity.X = -3.0f;
                }
                else
                {
                    player.velocity.X = 0;
                }

                #endregion

                #region Fly/Jump
                //if we press and hold A then velocity is applied, or its just 0
                //if we press and hold A and still flying energy then we fly, or we just float on down due to gravity but the flying energy doesn't replenish unless we've hit something
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Space) && flyingAllowed)
                {
                    player.velocity.Y = -2;
                    flyingBarScalar = -2;
                    gravityAcceleration = 0;
                }
                else
                {
                    flyingBarScalar = 0;
                    gravityAcceleration = .1f;

                }
                //CheckImaginaryRectangles();
                HandleTileCollision();
                #endregion

            }

            refInput = input;
        }
Ejemplo n.º 14
0
        public override void HandleInput(InputState input)
        {
            #region MenuDown
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Down) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Down))
            {
                if (tileSelection)
                {
                    tileSelected++;

                    if (type == TileType.Block)
                    {
                        if (tileSelected == tileReferenceBlocks.Length)
                        {
                            tileSelected = 0;
                        }
                    }
                    if (type == TileType.Scenery)
                    {
                        if (tileSelected == tileReferenceSceneries.Length)
                        {
                            tileSelected = 0;
                        }
                    }
                    if (type == TileType.Slope)
                    {
                        if (tileSelected == tileReferenceSlopes.Length)
                        {
                            tileSelected = 0;
                        }
                    }

                    selectionBoxPosition = new Vector2(tiles[tileSelected].menuEntryPosition.X, tiles[tileSelected].menuEntryPosition.Y);

                }
                else
                {

                    fileSelected++;

                    if (fileSelected == tileTypes.Length)
                    {
                        fileSelected = 0;
                    }

                    fileSelectionBoxPosition = new Vector2(tileTypes[fileSelected].menuEntryPosition.X, tileTypes[fileSelected].menuEntryPosition.Y);

                }

                LevelCreate.tileChosen = false;
                color = Color.White;
            }
            #endregion
            #region MenuUp
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Up) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Up))
            {
                if (tileSelection)
                {
                    tileSelected--;

                    if (type == TileType.Block)
                    {
                        if (tileSelected < 0)
                        {
                            tileSelected = tileReferenceBlocks.Length - 1;
                        }
                    }
                    if (type == TileType.Scenery)
                    {
                        if (tileSelected < 0)
                        {
                            tileSelected = tileReferenceSceneries.Length - 1;
                        }
                    }
                    if (type == TileType.Slope)
                    {
                        if (tileSelected < 0)
                        {
                            tileSelected = tileReferenceSlopes.Length - 1;
                        }
                    }

                    selectionBoxPosition = new Vector2(tiles[tileSelected].menuEntryPosition.X, tiles[tileSelected].menuEntryPosition.Y);
                }
                else
                {
                    fileSelected--;

                    if (fileSelected < 0)
                    {
                        fileSelected = tileTypes.Length - 1;
                    }

                    fileSelectionBoxPosition = new Vector2(tileTypes[fileSelected].menuEntryPosition.X, tileTypes[fileSelected].menuEntryPosition.Y);

                }

                LevelCreate.tileChosen = false;
                color = Color.White;
            }
            #endregion
            #region LayerSelect
            if (tileSelection)
            {
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D0) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D0))
                {
                    layerSelected = 0;
                    layerOneColor = Color.Red;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.White;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D1) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D1))
                {
                    layerSelected = 1;
                    layerOneColor = Color.White;
                    layerTwoColor = Color.Red;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.White;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D2) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D2))
                {
                    layerSelected = 2;
                    layerOneColor = Color.White;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.Red;
                    layerFourColor = Color.White;
                }
                if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.D3) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.D3))
                {
                    layerSelected = 3;
                    layerOneColor = Color.White;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.Red;
                }
                if (layerSelected == 0)
                {
                    layerOneColor = Color.Red;
                    layerTwoColor = Color.White;
                    layerThreeColor = Color.White;
                    layerFourColor = Color.White;
                }
            }

            #endregion
            #region Back
            if (input.CurrentKeyboardStates[(int)PlayerIndex.One].IsKeyDown(Keys.Back) && input.PreviousKeyboardStates[(int)PlayerIndex.One].IsKeyUp(Keys.Back))
            {
                if (tileSelection)
                {
                    if (LevelCreate.tileChosen)
                    {

                        this.ExitScreen();

                    }
                    else
                    {
                        MenuEntries.Clear();

                        foreach (MenuEntry tileType in tileTypes)
                        {
                            MenuEntries.Add(tileType);
                        }

                        tileSelection = false;
                        //isAssigned = false;
                    }
                }
                else
                {
                    this.ExitScreen();
                }
            }
            #endregion

            base.HandleInput(input);
        }