public void Update(GameTime gameTime)
        {
            if (IsEnergyLocked)
            {
                remainingEnergyLockTime -= gameTime.ElapsedGameTime.Milliseconds;
            }

            if (primaryOn)
            {
                ShipInventoryManager.currentPrimaryWeapon.Update(player, gameTime);
            }

            if (secondaryOn)
            {
                ShipInventoryManager.equippedSecondary.Update(player, gameTime);
            }

            if (ControlManager.CheckHold(RebindableKeys.Action1))
            {
                UseWeapon((PlayerWeapon)ShipInventoryManager.currentPrimaryWeapon, gameTime);
                UseWeapon((PlayerWeapon)ShipInventoryManager.equippedSecondary, gameTime);
            }

            shotHandlerHelper.Update();

            if (ControlManager.CheckPress(RebindableKeys.Action2))
            {
                shotHandlerHelper.ChangePrimary();
            }

            ShipInventoryManager.currentPrimaryWeapon = (PlayerWeapon)shotHandlerHelper.currentPrimary;
        }
        private void PlayerMovementControl()
        {
            if (Speed > maxSpeed)
            {
                Speed = maxSpeed;
            }

            bool moveKeyPressed = false;

            if (ControlManager.CheckHold(RebindableKeys.Left) || ControlManager.CheckHold(RebindableKeys.Up) ||
                ControlManager.CheckHold(RebindableKeys.Right) || ControlManager.CheckHold(RebindableKeys.Down))
            {
                moveKeyPressed = true;
            }

            if (!moveKeyPressed)
            {
                Speed -= 0.02f;
            }

            if (Speed < deAcceleration)
            {
                Speed = 0;
            }

            if (moveKeyPressed)
            {
                PlayerMovement();
            }
        }
Exemplo n.º 3
0
        private void CheckInput()
        {
            if (ControlManager.CheckHold(RebindableKeys.Up))
            {
                txtSpeed += 0.01f;
            }

            else
            {
                txtSpeed -= 0.01f;
            }
        }
Exemplo n.º 4
0
        // Updates camera position relative to players position if camera is within bounds of screen
        public void CameraUpdate(GameTime gameTime, PlayerOverworld player)
        {
            // Camera panning
            if (ZoomMap.MapState == MapState.On)
            {
                if (ControlManager.CheckHold(RebindableKeys.Right))
                {
                    cameraPos.X += CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }

                else if (ControlManager.CheckHold(RebindableKeys.Left))
                {
                    cameraPos.X -= CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }

                if (ControlManager.CheckHold(RebindableKeys.Up))
                {
                    cameraPos.Y -= CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }

                else if (ControlManager.CheckHold(RebindableKeys.Down))
                {
                    cameraPos.Y += CameraPanSpeed * MathFunctions.FPSSyncFactor(gameTime);
                }
            }

            else
            {
                originalCameraPos = cameraPos;
            }

            if (ZoomMap.MapState != MapState.On &&
                ((cameraPos.X - (Game1.ScreenSize.X / 2) >= 0 && (cameraPos.X + Game1.ScreenSize.X / 2) <= WorldWidth) ||
                 (cameraPos.Y - (Game1.ScreenSize.Y / 2) >= 0 && cameraPos.Y + (Game1.ScreenSize.Y / 2) <= WorldHeight)))
            {
                Position = player.position;
            }
        }
Exemplo n.º 5
0
        private void ButtonControls(GameTime gameTime)
        {
            if (!ControlManager.GamepadReady)
            {
                if (ControlManager.CheckPress(RebindableKeys.Down))
                {
                    cursorIndex++;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();

                    if (cursorIndex > menuOptions.Length / 2 - 1)
                    {
                        cursorIndex = 0;
                    }
                }

                else if (ControlManager.CheckHold(RebindableKeys.Down))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex++;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }

                    if (cursorIndex > menuOptions.Length / 2 - 1)
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                }

                else if (ControlManager.CheckPress(RebindableKeys.Up))
                {
                    cursorIndex--;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();

                    if (cursorIndex < 0)
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                }

                else if (ControlManager.CheckHold(RebindableKeys.Up))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex--;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }

                    if (cursorIndex < 0)
                    {
                        cursorIndex = 0;
                    }
                }
            }

            else
            {
                if (ControlManager.CheckButtonPress(Buttons.DPadDown) ||
                    ControlManager.CheckButtonPress(Buttons.LeftThumbstickDown))
                {
                    cursorIndex++;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();
                }

                else if (ControlManager.CurrentGamepadState.IsButtonDown(Buttons.DPadDown) ||
                         ControlManager.CurrentGamepadState.IsButtonDown(Buttons.LeftThumbstickDown))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex++;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }
                }

                else if (ControlManager.CheckButtonPress(Buttons.DPadUp) ||
                         ControlManager.CheckButtonPress(Buttons.LeftThumbstickUp))
                {
                    cursorIndex--;
                    holdTimer = game.HoldKeyTreshold;

                    PlayHoverSound();
                }

                else if (ControlManager.CurrentGamepadState.IsButtonDown(Buttons.DPadUp) ||
                         ControlManager.CurrentGamepadState.IsButtonDown(Buttons.LeftThumbstickUp))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorIndex--;
                        holdTimer = game.ScrollSpeedFast;

                        PlayHoverSound();
                    }
                }

                if (cursorIndex < 0)
                {
                    if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.DPadUp))
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                    else if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.LeftThumbstickUp))
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                    else
                    {
                        cursorIndex = 0;
                    }
                }

                else if (cursorIndex > menuOptions.Length / 2 - 1)
                {
                    if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.DPadDown))
                    {
                        cursorIndex = 0;
                    }
                    else if (ControlManager.CurrentGamepadState.IsButtonUp(Buttons.LeftThumbstickUp))
                    {
                        cursorIndex = 0;
                    }
                    else
                    {
                        cursorIndex = menuOptions.Length / 2 - 1;
                    }
                }
            }


            if (ControlManager.CheckPress(RebindableKeys.Action2) ||
                ControlManager.CheckPress(RebindableKeys.Pause))
            {
                optionsMenuState.LeaveSubState();
                OnLeave();
            }

            else if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                     ControlManager.CheckKeyPress(Keys.Enter))
            {
                ButtonActions();
            }
        }
        public override void Update(GameTime gameTime)
        {
            #region Input

            if (ControlManager.CheckHold(RebindableKeys.Up))
            {
                txtSpeed += 0.01f;
            }

            else
            {
                txtSpeed -= 0.01f;
            }

            if (ControlManager.GamepadReady == false)
            {
                if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                    ControlManager.CheckKeyPress(Keys.Enter))
                {
                    Game.stateManager.ChangeState("OverworldState");
                }
            }

            if (ControlManager.GamepadReady == true)
            {
                if (ControlManager.CurrentGamepadState.IsButtonDown(ControlManager.GamepadAction))
                {
                    Game.stateManager.ChangeState("OverworldState");
                }
            }

            #endregion

            textBox.Update(gameTime);
            textBox.TextBoxPosY -= txtSpeed;

            if (txtSpeed > txtMaxSpeed)
            {
                txtSpeed = txtMaxSpeed;
            }

            else if (txtSpeed < txtMinSpeed)
            {
                txtSpeed = txtMinSpeed;
            }

            if (textBox.TextBoxPosY < 325)
            {
                Game.stateManager.ChangeState("OverworldState");
            }

            for (int i = 0; i < NumberOfStars; i++)
            {
                starPositions[i].X += (starSpeed * starSpeedModifiers[i]) * gameTime.ElapsedGameTime.Milliseconds;

                int returnValue = StaticFunctions.IsPositionOutsideScreenX(starPositions[i], Game);

                if (returnValue == 2)
                {
                    starPositions[i] = new Vector2(-30, (float)Game.random.Next(0, Game1.ScreenSize.Y));
                }
            }
        }
Exemplo n.º 7
0
        private void PlayerMovement(GameTime gameTime)
        {
            if (speed > maxSpeed)
            {
                speed = maxSpeed;
            }

            else if (speed < -maxSpeed)
            {
                speed = -maxSpeed;
            }

            if (StatsManager.Fuel >= normalFuelCost)
            {
                if (ControlManager.CheckHold(RebindableKeys.Action3) &&
                    isHyperSpeedUnlocked &&
                    !isDevelopSpeedUnlocked &&
                    controlsEnabled)
                {
                    maxSpeed     = boostSpeed;
                    turningSpeed = boostTurningSpeed;
                    playerAcc    = commonAcc;
                    usingBoost   = true;
                }

                else if (ControlManager.CheckHold(RebindableKeys.Action3) &&
                         isDevelopSpeedUnlocked &&
                         controlsEnabled)
                {
                    maxSpeed     = developSpeed;
                    turningSpeed = boostTurningSpeed;
                    playerAcc    = developAcc;
                    usingBoost   = true;
                }

                else
                {
                    maxSpeed     = commonSpeed;
                    turningSpeed = commonTurningSpeed;
                    playerAcc    = commonAcc;
                    usingBoost   = false;
                }
            }

            if (ControlManager.CheckHold(RebindableKeys.Up) && controlsEnabled)
            {
                if (StatsManager.Fuel > normalFuelCost)
                {
                    if (ControlManager.GamepadReady && ControlManager.ThumbStickAngleY != 0)
                    {
                        if (StatsManager.Fuel > normalFuelCost)
                        {
                            speed += playerAcc * MathFunctions.FPSSyncFactor(gameTime);
                        }

                        AddParticle();
                    }
                    else
                    {
                        if (StatsManager.Fuel > normalFuelCost)
                        {
                            speed += playerAcc * MathFunctions.FPSSyncFactor(gameTime);
                        }

                        AddParticle();

                        Game.soundEffectsManager.PlaySoundEffect(SoundEffects.OverworldEngine, 0f, 0f);
                    }
                }
            }

            if (ControlManager.CheckHold(RebindableKeys.Right) && controlsEnabled)
            {
                if (StatsManager.Fuel > normalFuelCost)
                {
                    Direction.SetDirection(Direction.GetDirectionAsDegree() + turningSpeed * MathFunctions.FPSSyncFactor(gameTime));
                }
            }

            else if (ControlManager.CheckHold(RebindableKeys.Left) &&
                     controlsEnabled)
            {
                if (StatsManager.Fuel > normalFuelCost)
                {
                    Direction.SetDirection(Direction.GetDirectionAsDegree() - turningSpeed * MathFunctions.FPSSyncFactor(gameTime));
                }
            }

            if (!ControlManager.CheckHold(RebindableKeys.Up) && controlsEnabled)
            {
                if (speed > 0)
                {
                    speed -= playerAcc * MathFunctions.FPSSyncFactor(gameTime);
                }

                else if (speed <= 0)
                {
                    speed = 0;
                }

                Game.soundEffectsManager.FadeOutSoundEffect(SoundEffects.OverworldEngine);
            }

            angle = (float)(MathFunctions.RadiansFromDir(new Vector2(
                                                             Direction.GetDirectionAsVector().X, Direction.GetDirectionAsVector().Y)) + (Math.PI * 90) / 180);
        }
        private void PlayerMovement()
        {
            if (ControlManager.CheckHold(RebindableKeys.Left) && !ControlManager.CheckHold(RebindableKeys.Up) &&
                !ControlManager.CheckHold(RebindableKeys.Right) && !ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = -1.0f;
                DirectionY = 0;
                Speed     += acceleration;
            }

            if (!ControlManager.CheckHold(RebindableKeys.Left) && ControlManager.CheckHold(RebindableKeys.Up) &&
                !ControlManager.CheckHold(RebindableKeys.Right) && !ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = 0;
                DirectionY = -1.0f;
                Speed     += acceleration;
            }

            if (!ControlManager.CheckHold(RebindableKeys.Left) && !ControlManager.CheckHold(RebindableKeys.Up) &&
                ControlManager.CheckHold(RebindableKeys.Right) && !ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = 1.0f;
                DirectionY = 0;
                Speed     += acceleration;
            }

            if (!ControlManager.CheckHold(RebindableKeys.Left) && !ControlManager.CheckHold(RebindableKeys.Up) &&
                !ControlManager.CheckHold(RebindableKeys.Right) && ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = 0;
                DirectionY = 1.0f;
                Speed     += acceleration;
            }

            if (ControlManager.CheckHold(RebindableKeys.Left) && ControlManager.CheckHold(RebindableKeys.Up) &&
                !ControlManager.CheckHold(RebindableKeys.Right) && !ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = -1.0f;
                DirectionY = -1.0f;
                Speed     += acceleration;
            }

            if (ControlManager.CheckHold(RebindableKeys.Left) && !ControlManager.CheckHold(RebindableKeys.Up) &&
                !ControlManager.CheckHold(RebindableKeys.Right) && ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = -1.0f;
                DirectionY = 1.0f;
                Speed     += acceleration;
            }

            if (!ControlManager.CheckHold(RebindableKeys.Left) && ControlManager.CheckHold(RebindableKeys.Up) &&
                ControlManager.CheckHold(RebindableKeys.Right) && !ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = 1.0f;
                DirectionY = -1.0f;
                Speed     += acceleration;
            }

            if (!ControlManager.CheckHold(RebindableKeys.Left) && !ControlManager.CheckHold(RebindableKeys.Up) &&
                ControlManager.CheckHold(RebindableKeys.Right) && ControlManager.CheckHold(RebindableKeys.Down))
            {
                DirectionX = 1.0f;
                DirectionY = 1.0f;
                Speed     += acceleration;
            }
        }
Exemplo n.º 9
0
        private void ButtonControls(GameTime gameTime)
        {
            if (ControlManager.CheckPress(RebindableKeys.Down))
            {
                buttonIndex++;
                holdTimer = Game.HoldKeyTreshold;

                PlayHoverSound();
            }

            else if (ControlManager.CheckHold(RebindableKeys.Down))
            {
                holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (holdTimer <= 0)
                {
                    buttonIndex++;
                    holdTimer = Game.ScrollSpeedFast;

                    PlayHoverSound();
                }
            }

            else if (ControlManager.CheckPress(RebindableKeys.Up))
            {
                buttonIndex--;
                holdTimer = Game.HoldKeyTreshold;

                PlayHoverSound();
            }

            else if (ControlManager.CheckHold(RebindableKeys.Up))
            {
                holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (holdTimer <= 0)
                {
                    buttonIndex--;
                    holdTimer = Game.ScrollSpeedFast;

                    PlayHoverSound();
                }
            }

            if (buttonIndex < 0)
            {
                if (ControlManager.PreviousKeyUp(RebindableKeys.Up))
                {
                    buttonIndex = buttons.Count - 1;
                }
                else
                {
                    buttonIndex = 0;
                }
            }

            else if (buttonIndex > buttons.Count - 1)
            {
                if (ControlManager.PreviousKeyUp(RebindableKeys.Down))
                {
                    buttonIndex = 0;
                }
                else
                {
                    buttonIndex = buttons.Count - 1;
                }
            }
        }
Exemplo n.º 10
0
        private void ButtonControls(GameTime gameTime)
        {
            if (ControlManager.CheckPress(RebindableKeys.Up))
            {
                buttonIndex--;
                holdTimer = Game.HoldKeyTreshold;

                PlayHoverSound();
            }

            else if (ControlManager.CheckHold(RebindableKeys.Up))
            {
                holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (holdTimer <= 0)
                {
                    buttonIndex--;
                    holdTimer = Game.ScrollSpeedSlow;

                    PlayHoverSound();
                }
            }

            else if (ControlManager.CheckPress(RebindableKeys.Down))
            {
                buttonIndex++;
                holdTimer = Game.HoldKeyTreshold;

                PlayHoverSound();
            }

            else if (ControlManager.CheckHold(RebindableKeys.Down))
            {
                holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (holdTimer <= 0)
                {
                    buttonIndex++;
                    holdTimer = Game.ScrollSpeedSlow;

                    PlayHoverSound();
                }
            }

            if (buttonIndex > buttons.Count - 1)
            {
                if (ControlManager.PreviousKeyUp(RebindableKeys.Down))
                {
                    buttonIndex = 0;
                }
                else
                {
                    buttonIndex = buttons.Count - 1;
                }
            }

            else if (buttonIndex < 0)
            {
                if (ControlManager.PreviousKeyUp(RebindableKeys.Up))
                {
                    buttonIndex = buttons.Count - 1;
                }
                else
                {
                    buttonIndex = 0;
                }
            }

            activeButton = buttons[buttonIndex];

            foreach (MenuDisplayObject button in buttons)
            {
                button.isActive = false;
            }

            activeButton.isActive = true;

            if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                ControlManager.CheckKeyPress(Keys.Enter))
            {
                ButtonActions();
            }

            // TODO: REMOVE FOR RELEASE VERSION
            //if (ControlManager.CheckKeyPress(Keys.M))
            //{
            //    Game.stateManager.ChangeState("LevelTesterState");
            //}

            if (ControlManager.CheckKeyHold(Keys.LeftAlt) &&
                ControlManager.CheckKeyPress(Keys.C))
            {
                Game.stateManager.ChangeState("CampaignState");
            }
        }
        private void CheckKeysLevel2(GameTime gameTime)
        {
            if (cursorLevel == 2 && cursorCoordLv1.Position != inventoryPos)
            {
                int listLength;

                if (cursorCoordLv1.Position != 5)
                {
                    listLength = ShipInventoryManager.ownCounts[cursorCoordLv1.Position - 1];
                }

                else
                {
                    if (cursorCoordLv1.Y == 0)
                    {
                        listLength = ShipInventoryManager.GetAvailablePrimaryWeapons(1).Count;
                    }
                    else
                    {
                        listLength = ShipInventoryManager.GetAvailablePrimaryWeapons(2).Count;
                    }
                }

                if (ControlManager.CheckPress(RebindableKeys.Down) && cursorLevel == 2 &&
                    elapsedSinceKey > elapseDelay)
                {
                    cursorLevel2Position += 1;
                    if (cursorLevel2Position > listLength)
                    {
                        cursorLevel2Position = 0;
                    }

                    elapsedSinceKey = 0;

                    holdTimer = Game.HoldKeyTreshold;
                }

                else if (ControlManager.CheckHold(RebindableKeys.Down))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorLevel2Position += 1;
                        if (cursorLevel2Position > listLength)
                        {
                            cursorLevel2Position = listLength;
                        }

                        elapsedSinceKey = 0;

                        holdTimer = Game.ScrollSpeedFast;
                    }
                }

                if (ControlManager.CheckPress(RebindableKeys.Up) && cursorLevel == 2 &&
                    elapsedSinceKey > elapseDelay)
                {
                    cursorLevel2Position -= 1;
                    if (cursorLevel2Position < 0)
                    {
                        cursorLevel2Position = listLength;
                    }

                    elapsedSinceKey = 0;

                    holdTimer = Game.HoldKeyTreshold;
                }

                else if (ControlManager.CheckHold(RebindableKeys.Up))
                {
                    holdTimer -= gameTime.ElapsedGameTime.Milliseconds;

                    if (holdTimer <= 0)
                    {
                        cursorLevel2Position -= 1;
                        if (cursorLevel2Position < 0)
                        {
                            cursorLevel2Position = 0;
                        }

                        elapsedSinceKey = 0;

                        holdTimer = Game.ScrollSpeedFast;
                    }
                }

                //This is where the magic happens.
                if (((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) && cursorLevel == 2 &&
                     elapsedSinceKey > elapseDelay))
                {
                    if (cursorLevel2Position < listLength)
                    {
                        OnPressLevel2();
                    }
                    else
                    {
                        cursorLevel     = 1;
                        elapsedSinceKey = 0;
                    }
                }

                if (ControlManager.CheckPress(RebindableKeys.Action2) && cursorLevel == 2 &&
                    elapsedSinceKey > elapseDelay)
                {
                    cursorLevel     = 1;
                    elapsedSinceKey = 0;
                }
            }
        }