private void ButtonControls()
        {
            if (ControlManager.CheckPress(RebindableKeys.Down))
            {
                cursorIndex++;
            }

            else if (ControlManager.CheckPress(RebindableKeys.Up))
            {
                cursorIndex--;
            }

            if (cursorIndex > options.Count - 1)
            {
                cursorIndex = 0;
            }

            else if (cursorIndex < 0)
            {
                cursorIndex = options.Count - 1;
            }

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

            else if (ControlManager.CheckPress(RebindableKeys.Action2) ||
                     ControlManager.CheckPress(RebindableKeys.Pause) ||
                     ControlManager.CheckPress(RebindableKeys.Help))
            {
                Game.stateManager.ChangeState("OverworldState");
            }
        }
        private void CheckStateChangeCommands()
        {
            //State-Changers
            if (ControlManager.CheckPress(RebindableKeys.Pause) && elapsedSinceKey > elapseDelay && cursorLevel == 1)
            {
                BackToOverworldLogic();
            }

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

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

            if (ControlManager.CheckPress(RebindableKeys.Inventory) && elapsedTimeMilliseconds > 200 &&
                elapsedSinceKey > elapseDelay)
            {
                BackToOverworldLogic();
            }
        }
        public override void Update(GameTime gameTime)
        {
            #region Input

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

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

            #endregion

            introtimer += gameTime.ElapsedGameTime.Milliseconds;

            if (introtimer > timeInIntro)
            {
                Game.stateManager.ChangeState("IntroSecondState");
            }
        }
        public override void MissionLogic()
        {
            base.MissionLogic();

            if (ObjectiveIndex > 2 &&
                ObjectiveIndex <= 6 &&
                !Game.player.HyperspeedOn)
            {
                if (Vector2.Distance(Game.player.position, rebelShips[1].position) > 500)
                {
                    PopupHandler.DisplayPortraitMessage(PortraitID.RebelPilot, "Hey! Where are you going? The freighter will be here any minute now.");
                    Game.player.BounceBack();
                }

                if (ControlManager.CheckPress(RebindableKeys.Pause) &&
                    GameStateManager.currentState.Equals("OverworldState"))
                {
                    PopupHandler.DisplaySelectionMenu("Do you want to skip waiting?",
                                                      new List <string>()
                    {
                        "Yes", "No"
                    },
                                                      new List <System.Action>()
                    {
                        delegate
                        {
                            SkipForward();
                        },
                        delegate {}
                    });
                }
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (cursorIndex == 2)
            {
                if (ControlManager.CheckPress(RebindableKeys.Left))
                {
                    resIndex--;
                }

                else if (ControlManager.CheckPress(RebindableKeys.Right))
                {
                    resIndex++;
                }
            }

            if (resIndex > Game1.ResolutionOptions.Count - 1)
            {
                resIndex = 0;
            }

            else if (resIndex < 0)
            {
                resIndex = Game1.ResolutionOptions.Count - 1;
            }

            menuOptions[2, 1] = Game1.ResolutionOptions[resIndex].X + " x " + Game1.ResolutionOptions[resIndex].Y;

            base.Update(gameTime);
        }
Пример #6
0
        private void CheckStateChangeCommands()
        {
            //State-Changers
            if (ControlManager.CheckPress(RebindableKeys.Pause) &&
                elapsedSinceKey > 100 && cursorLevel == 1)
            {
                Game.stateManager.ChangeState(GameStateManager.previousState);
            }

            if (ControlManager.CheckPress(RebindableKeys.Action2) &&
                elapsedSinceKey > 100 && cursorLevel == 1)
            {
                Game.stateManager.ChangeState(GameStateManager.previousState);
            }

            if (ControlManager.CheckPress(RebindableKeys.Pause) &&
                elapsedSinceKey > 100 && cursorLevel > 1)
            {
                cursorLevel    -= 1;
                elapsedSinceKey = 0;
            }

            if (ControlManager.CheckPress(RebindableKeys.Missions) && elapsedTimeMilliseconds > 200 &&
                elapsedSinceKey > 100)
            {
                Game.stateManager.ChangeState(GameStateManager.previousState);
            }
        }
        public void UpdateBackdropPosition(GameTime gameTime)
        {
            distance = Math.Abs(Vector2.Distance(preferredBackdropPosition, backdropPosition));

            backdropDirection.RotateTowardsPointSingleTurn(gameTime, backdropPosition, preferredBackdropPosition, 1f);
            backdropPosition += (backdropSpeed * backdropDirection.GetDirectionAsVector()) * gameTime.ElapsedGameTime.Milliseconds;

            if (distance > totalDistance / 2)
            {
                backdropSpeed += backdropAcc * gameTime.ElapsedGameTime.Milliseconds;
            }
            else if (distance <= totalDistance / 2)
            {
                backdropSpeed -= backdropAcc * gameTime.ElapsedGameTime.Milliseconds;
            }

            pressDelay--;

            if (pressDelay < 0 &&
                (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckPress(RebindableKeys.Action2) ||
                 ControlManager.CheckKeyPress(Keys.Enter) || ControlManager.IsLeftMouseButtonClicked()))
            {
                backdropSpeed    = 0;
                backdropPosition = preferredBackdropPosition;
                game.stateManager.ChangeState(nextGameState);
                moveBackdrop = false;
            }

            if (distance < 5)
            {
                backdropSpeed = 0;
                game.stateManager.ChangeState(nextGameState);
                moveBackdrop = false;
            }
        }
        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;
        }
Пример #9
0
        public override bool Completed()
        {
            if (isOnCompletedCalled)
            {
                return(true);
            }

            if (Destination is Planet)
            {
                return(mission.MissionHelper.IsPlayerOnPlanet(Destination.name));
            }
            else if (Destination is Station)
            {
                return(mission.MissionHelper.IsPlayerOnStation(Destination.name));
            }
            else if (Destination is SubInteractiveObject)
            {
                return(CollisionDetection.IsRectInRect(game.player.Bounds, Destination.Bounds) &&
                       (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) &&
                       !PopupHandler.IsMenuOpen);
            }
            else
            {
                return(CollisionDetection.IsRectInRect(game.player.Bounds, Destination.Bounds));
            }
        }
Пример #10
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            ButtonControls(gameTime);
            MouseControls();

            if ((ControlManager.CheckPress(RebindableKeys.Action2) ||
                 ControlManager.CheckPress(RebindableKeys.Pause)) && Game.menuBGController.backdropSpeed.Equals(0))
            {
                Game.menuBGController.SetPreferredBackdropPosition(new Vector2(-101, -703), "MainMenuState");
            }
            else if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                     ControlManager.CheckKeyPress(Keys.Enter))
            {
                ButtonActions();
            }

            selectedButton = buttons[buttonIndex];

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

            selectedButton.isActive = true;

            base.Update(gameTime);
        }
        public virtual void Update(GameTime gameTime)
        {
            activeMenuState.Update(gameTime);

            MouseControls();

            if (buttonControl == ButtonControl.Menu)
            {
                if (ControlManager.CheckPress(RebindableKeys.Down))
                {
                    activeButtonIndexY++;
                    WrapActiveButton();
                    ActiveMenuState.CursorActions();
                }

                else if (ControlManager.CheckPress(RebindableKeys.Up))
                {
                    activeButtonIndexY--;
                    WrapActiveButton();
                    ActiveMenuState.CursorActions();
                }

                previousButton = activeButton;
                activeButton   = allButtons[activeButtonIndexY];
            }

            else if (buttonControl.Equals(ButtonControl.Mission) ||
                     buttonControl.Equals(ButtonControl.Response) ||
                     buttonControl.Equals(ButtonControl.Confirm))
            {
                activeButton = null;
            }

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

            foreach (MenuDisplayObject button in allButtons)
            {
                if (button != null)
                {
                    button.isActive = false;
                }
            }

            if (activeButton != null)
            {
                activeButton.isActive = true;
            }

            missionMenuState.UpdateTextCursorPos();

            foreach (TextBox txtBox in textBoxes)
            {
                txtBox.Update(gameTime);
            }
        }
Пример #12
0
 private static void ButtonControls()
 {
     if (ControlManager.CheckPress(RebindableKeys.Pause) &&
         messageQueue.Count > 0)
     {
         messageQueue.Clear();
         Game1.Paused = false;
     }
 }
Пример #13
0
        private void CheckKeysCursorLevel1()
        {
            int temporaryCount = cursorManager.displayList.Count;

            if (ControlManager.CheckPress(RebindableKeys.Up) && elapsedSinceKey > 100)
            {
                if (cursorLevel1Position == 0)
                {
                    cursorLevel1Position = 3;
                }
                else if (cursorLevel1Position == 1)
                {
                    cursorLevel1Position = 0;
                }
                else if (cursorLevel1Position == 2)
                {
                    cursorLevel1Position = 1;
                }
                else if (cursorLevel1Position == 3)
                {
                    cursorLevel1Position = 2;
                }

                elapsedSinceKey = 0;
            }

            if (ControlManager.CheckPress(RebindableKeys.Down) && elapsedSinceKey > 100)
            {
                if (cursorLevel1Position == 0)
                {
                    cursorLevel1Position = 1;
                }
                else if (cursorLevel1Position == 1)
                {
                    cursorLevel1Position = 2;
                }
                else if (cursorLevel1Position == 2)
                {
                    cursorLevel1Position = 3;
                }
                else if (cursorLevel1Position == 3)
                {
                    cursorLevel1Position = 0;
                }

                elapsedSinceKey = 0;

                elapsedSinceKey = 0;
            }

            if ((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) &&
                elapsedSinceKey > 100)
            {
                OnPressCursorLevel1();
            }
        }
Пример #14
0
 private void CheckGameOverUserInput()
 {
     if (ControlManager.CheckKeyPress(Keys.R) && !isPirateLevel)
     {
         this.Initialize();
     }
     else if (ControlManager.CheckPress(RebindableKeys.Action2))
     {
         LeaveLevel();
     }
 }
        public override void Update(GameTime gameTime)
        {
            if (ControlManager.CheckPress(RebindableKeys.Action2) ||
                ControlManager.CheckPress(RebindableKeys.Pause))
            {
                if (BaseStateManager.ButtonControl.Equals(ButtonControl.SelectShop))
                {
                    OnEnter();
                }
            }

            base.Update(gameTime);
        }
Пример #16
0
        public override void Update(GameTime gameTime)
        {
            textBoxLeft.Update(gameTime);
            textBoxRight.Update(gameTime);

            if (ControlManager.CheckPress(RebindableKeys.Action1) ||
                ControlManager.CheckKeyPress(Keys.Enter) ||
                ControlManager.CheckPress(RebindableKeys.Action2) ||
                ControlManager.CheckKeyPress(Keys.Escape) ||
                ControlManager.IsLeftMouseButtonClicked())
            {
                Game.stateManager.ChangeState("MainMenuState");
            }
        }
Пример #17
0
        public virtual void Update(GameTime gameTime)
        {
            if (ControlManager.CheckPress(RebindableKeys.Pause) ||
                ControlManager.CheckPress(RebindableKeys.Action2))
            {
                if (BaseStateManager.ButtonControl != ButtonControl.Confirm &&
                    BaseStateManager.ButtonControl != ButtonControl.Response)
                {
                    if (BaseStateManager.ActiveMenuState.Equals(BaseStateManager.OverviewMenuState))
                    {
                        if (StatsManager.gameMode != GameMode.Campaign)
                        {
                            Game.stateManager.ChangeState("OverworldState");
                        }
                        else
                        {
                            Game.stateManager.ChangeState("CampaignState");
                        }
                    }

                    else if (BaseStateManager.ActiveMenuState.Equals(BaseStateManager.MissionMenuState) &&
                             BaseStateManager.ButtonControl.Equals(ButtonControl.Mission))
                    {
                        BaseState.HideOverlay();
                        BaseStateManager.ChangeMenuSubState("Overview");
                    }

                    else if (BaseStateManager.ActiveMenuState.Equals(BaseStateManager.MissionMenuState) &&
                             BaseStateManager.ButtonControl.Equals(ButtonControl.Response))
                    {
                        BaseStateManager.ActiveButton = BaseStateManager.AllButtons[BaseStateManager.ActiveButtonIndexY];
                        BaseStateManager.MissionMenuState.SelectMission();
                    }

                    else if (BaseStateManager.ActiveMenuState.Equals(BaseStateManager.ShopMenuState))
                    {
                        BaseStateManager.ActiveButton  = BaseStateManager.AllButtons[BaseStateManager.ActiveButtonIndexY];
                        BaseStateManager.ButtonControl = ButtonControl.Second;
                        BaseStateManager.ChangeMenuSubState("Overview");
                    }
                }
            }
        }
Пример #18
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (ControlManager.CheckPress(RebindableKeys.Right))
            {
                VolumeControl("right");
            }

            else if (ControlManager.CheckPress(RebindableKeys.Left))
            {
                VolumeControl("left");
            }

            if (!SoundEffectsManager.LoadSoundEffects)
            {
                game.soundEffectsManager.SetSoundMuted(true);
                menuOptions[2, 1] = "Off";
            }
        }
Пример #19
0
        public override void Update(GameTime gameTime)
        {
            MouseControls();

            if (activeOptionState != null && Game.menuBGController.DisplayButtons)
            {
                activeOptionState.Update(gameTime);
            }
            else if (Game.menuBGController.DisplayButtons)
            {
                ButtonControls(gameTime);

                if ((ControlManager.CheckPress(RebindableKeys.Action2) ||
                     ControlManager.CheckPress(RebindableKeys.Pause)) && Game.menuBGController.backdropSpeed.Equals(0))
                {
                    if (GameStateManager.previousState == "MainMenuState")
                    {
                        Game.menuBGController.SetPreferredBackdropPosition(new Vector2(-101, -703), "MainMenuState");
                    }
                    else
                    {
                        Game.stateManager.ChangeState("OverworldState");
                    }
                }

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

            selectedButton = buttons[buttonIndex];

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

            selectedButton.isActive = true;
        }
Пример #20
0
        private void CheckKeyboard()
        {
            if (ControlManager.CheckPress(RebindableKeys.Pause) && timeSinceStarted > 200)
            {
                PopupHandler.DisplayMenu();
            }

            if (ControlManager.CheckKeyPress(Keys.Y))
            {
                //Game.messageBox.DisplayMessage("Hello world!");
                Game.soundEffectsManager.MutateLaserSound_DEVELOP();
            }

            //if (ControlManager.CheckKeypress(Keys.F1))
            //    AlliedShip.ShowSightRange = !AlliedShip.ShowSightRange;

            if (StatsManager.gameMode == GameMode.Develop || StatsManager.gameMode == GameMode.Campaign)
            {
                DevelopCommands();
            }
        }
Пример #21
0
        public virtual void Update(GameTime gameTime)
        {
            foreach (GameObjectOverworld obj in gameObjects)
            {
                obj.Update(gameTime);
            }

            if ((ControlManager.CheckPress(RebindableKeys.Action1) ||
                 ControlManager.CheckKeyPress(Keys.Enter)) &&
                !game.player.HyperspeedOn &&
                !game.stateManager.overworldState.IsBurnOutEndingActivated)
            {
                EnterCheck();
            }

            if (garbageGameObjects.Count > 0)
            {
                DeleteRemovedGameObjects();
            }

            ShopManager.UpdateShops(gameObjects);
        }
        private void CheckKeysLevel1()
        {
            int temporaryCount = cursorManager.displayList.Count;

            if (ControlManager.CheckPress(RebindableKeys.Down) && cursorLevel == 1 &&
                elapsedSinceKey > elapseDelay)
            {
                cursorCoordLv1.MoveCursor(0, 1);
                elapsedSinceKey = 0;
            }

            if (ControlManager.CheckPress(RebindableKeys.Up) && cursorLevel == 1 &&
                elapsedSinceKey > elapseDelay)
            {
                cursorCoordLv1.MoveCursor(0, -1);
                elapsedSinceKey = 0;
            }

            if (ControlManager.CheckPress(RebindableKeys.Left) && cursorLevel == 1 &&
                elapsedSinceKey > elapseDelay)
            {
                cursorCoordLv1.MoveCursor(-1, 0);
                elapsedSinceKey = 0;
            }

            if (ControlManager.CheckPress(RebindableKeys.Right) && cursorLevel == 1 &&
                elapsedSinceKey > elapseDelay)
            {
                cursorCoordLv1.MoveCursor(1, 0);
                elapsedSinceKey = 0;
            }

            if (((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) && cursorLevel == 1 &&
                 elapsedSinceKey > elapseDelay))
            {
                OnPressLevel1();
            }
        }
Пример #23
0
 private void ButtonControls()
 {
     if (ControlManager.CheckPress(RebindableKeys.Action1) ||
         ControlManager.CheckKeyPress(Keys.Enter))
     {
         OnPress(RebindableKeys.Action1);
     }
     else if (ControlManager.CheckPress(RebindableKeys.Action2))
     {
         OnPress(RebindableKeys.Action2);
     }
     else if (ControlManager.CheckPress(RebindableKeys.Pause) ||
              ControlManager.CheckKeyPress(Keys.Escape))
     {
         OnPress(RebindableKeys.Pause);
     }
     else if (ControlManager.CheckPress(RebindableKeys.Right))
     {
         OnPress(RebindableKeys.Right);
     }
     else if (ControlManager.CheckPress(RebindableKeys.Left))
     {
         OnPress(RebindableKeys.Left);
     }
     else if (ControlManager.CheckPress(RebindableKeys.Up))
     {
         OnPress(RebindableKeys.Up);
     }
     else if (ControlManager.CheckPress(RebindableKeys.Down))
     {
         OnPress(RebindableKeys.Down);
     }
     else if (ControlManager.IsLeftMouseButtonClicked())
     {
         OnPress(RebindableKeys.Action1);
     }
 }
Пример #24
0
        private void Inputhandling()
        {
            if ((ControlManager.CheckPress(RebindableKeys.Action1) ||
                 ControlManager.CheckKeyPress(Keys.Enter)))
            {
                EnterCheck();
            }

            else if (ControlManager.CheckPress(RebindableKeys.Pause) &&
                     Game.player.IsControlsEnabled &&
                     (MissionManager.GetMission(MissionID.Main5_Retribution).MissionState != StateOfMission.Active ||
                      (MissionManager.GetMission(MissionID.Main5_Retribution).ObjectiveIndex <= 2 ||
                       MissionManager.GetMission(MissionID.Main5_Retribution).ObjectiveIndex >= 6)))
            {
                PopupHandler.DisplayMenu();
            }

            else if (ControlManager.CheckPress(RebindableKeys.Missions))
            {
                Game.stateManager.ChangeState("MissionScreenState");
            }

            else if (ControlManager.CheckPress(RebindableKeys.Inventory))
            {
                Game.stateManager.ChangeState("ShipManagerState");
                Game.stateManager.shooterState.Initialize();
            }
            else if (ControlManager.CheckPress(RebindableKeys.Help))
            {
                Game.stateManager.ChangeState("HelpScreenState");
            }

            if (StatsManager.gameMode == GameMode.Develop && ControlManager.CheckKeyPress(Keys.U))
            {
                DevelopCommands();
            }
        }
Пример #25
0
        private void ButtonControls()
        {
            if (ControlManager.CheckPress(RebindableKeys.Down))
            {
                cursorIndex++;
            }

            else if (ControlManager.CheckPress(RebindableKeys.Up))
            {
                cursorIndex--;
            }

            if (cursorIndex > options.Count - 1)
            {
                cursorIndex = 0;
            }

            else if (cursorIndex < 0)
            {
                cursorIndex = options.Count - 1;
            }

            if (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter))
            {
                if (cursorIndex < beacons.Count)
                {
                    currentBeacon.StartJump(beacons[cursorIndex]);
                }

                Hide();
            }

            if (ControlManager.CheckPress(RebindableKeys.Action2) || ControlManager.CheckKeyPress(Keys.Escape))
            {
                Hide();
            }
        }
Пример #26
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();
            }
        }
Пример #27
0
        protected override void SetupObjectives()
        {
            objectives.Clear();

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0],
                                               delegate { SetupAllyShips(allyShips1, destinations[0].position, destinations[1]); },
                                               delegate { },
                                               delegate { return(true); },
                                               delegate { return(false); }));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0],
                                               new EventTextCapsule(GetEvent((int)EventID.OutsideRebelStation1), null, EventTextCanvas.MessageBox, PortraitID.Sair),
                                               delegate { },
                                               delegate { },
                                               delegate { return(GameStateManager.currentState.ToLower().Equals("overworldstate")); },
                                               delegate { return(false); }));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0],
                                               new EventTextCapsule(GetEvent((int)EventID.AtRebelRendezvous), null, EventTextCanvas.MessageBox, PortraitID.RebelTroopLeader),
                                               delegate
            {
                readyToLeave      = false;
                allyShipRectangle = new Rectangle(
                    (int)allyShips1[0].position.X - AllyShipRectOffset,
                    (int)allyShips1[0].position.Y - AllyShipRectOffset,
                    AllyShipRectWidth, AllyShipRectHeight);

                PopupHandler.DisplayPortraitMessage(PortraitID.Rok, "[Rok] \"Talk to the ships waiting nearby our base when you're ready to leave.\"");
            },
                                               delegate
            {
                if (CollisionDetection.IsRectInRect(Game.player.Bounds, allyShipRectangle) &&
                    (ControlManager.CheckPress(RebindableKeys.Action1) ||
                     ControlManager.CheckKeyPress(Keys.Enter)) &&
                    GameStateManager.currentState.Equals("OverworldState"))
                {
                    PopupHandler.DisplaySelectionMenu("[Rebel Pilot] Ready to go?",
                                                      new List <string>()
                    {
                        "Yes", "No"
                    },
                                                      new List <System.Action>()
                    {
                        delegate { readyToLeave = true; },
                        delegate { readyToLeave = false; }
                    });
                }
            },
                                               delegate { return(readyToLeave); },
                                               delegate { return(false); }));

            //objectives.Add(new CloseInOnLocationObjective(Game, this, ObjectiveDescriptions[0],
            //    200, new EventTextCapsule(GetEvent((int)EventID.AtRebelRendezvous), null, EventTextCanvas.MessageBox, PortraitID.RebelTroopLeader)));

            AutoPilotObjective autoPilotObjective = new AutoPilotObjective(Game, this, ObjectiveDescriptions[0], AutoPilotSpeed,
                                                                           allyShips1, destinations[3].position,
                                                                           new EventTextCapsule(GetEvent((int)EventID.ArriveAtScienceStation),
                                                                                                null,
                                                                                                EventTextCanvas.MessageBox, PortraitID.RebelTroopLeader), false);

            autoPilotObjective.Initialize();
            autoPilotObjective.SetTimedMessages(new Dictionary <string, List <float> >
            {
                { GetEvent((int)EventID.TravelToScienceStation1).Text, new List <float> {
                      5000, 3000
                  } },
                { GetEvent((int)EventID.TravelToScienceStation2).Text, new List <float> {
                      1000, 3000
                  } },
                { GetEvent((int)EventID.TravelToScienceStation3).Text, new List <float> {
                      13000, 3000
                  } }
            }
                                                , new List <List <PortraitID> >()
            {
                new List <PortraitID> {
                    PortraitID.Ai
                },
                new List <PortraitID> {
                    PortraitID.Sair
                },
                new List <PortraitID> {
                    PortraitID.Ai
                }
            }
                                                , new List <List <int> > {
                new List <int> {
                }, new List <int> {
                }, new List <int> {
                }
            });

            objectives.Add(autoPilotObjective);

            objectives.Add(new ShootingLevelObjective(Game, this, ObjectiveDescriptions[0],
                                                      "Itnos_1", LevelStartCondition.TextCleared,
                                                      new EventTextCapsule(GetEvent((int)EventID.AfterLevel1),
                                                                           null, EventTextCanvas.MessageBox, PortraitID.RebelTroopLeader)));

            objectives.Add(new ArriveAtLocationObjective(Game, this, ObjectiveDescriptions[0],
                                                         new EventTextCapsule(GetEvent((int)EventID.InsideScienceStation1), null, EventTextCanvas.MessageBox, PortraitID.Sair)));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0],
                                               new EventTextCapsule(GetEvent((int)EventID.InsideScienceStation2), null, EventTextCanvas.MessageBox),
                                               delegate { }, delegate { }, delegate { return(true); }, delegate { return(false); }));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0],
                                               new EventTextCapsule(GetEvent((int)EventID.InsideScienceStation3), null, EventTextCanvas.MessageBox, PortraitID.Ente),
                                               delegate { }, delegate { }, delegate { return(true); }, delegate { return(false); }));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[1],
                                               new EventTextCapsule(GetEvent((int)EventID.OutsideScienceStation), null, EventTextCanvas.MessageBox, PortraitID.Sair),
                                               delegate
            {
                RemoveShips();
            }, delegate { },
                                               delegate
            {
                return(GameStateManager.currentState == "OverworldState");
            },
                                               delegate { return(false); }));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[1],
                                               new EventTextCapsule(GetEvent((int)EventID.BreakThroughLevel), null, EventTextCanvas.MessageBox, PortraitID.Sair),
                                               delegate
            {
                hangarAttackTime = StatsManager.PlayTime.GetFutureOverworldTime(2000);
            },
                                               delegate { },
                                               delegate
            {
                return(StatsManager.PlayTime.HasOverworldTimePassed(hangarAttackTime));
            },
                                               delegate { return(false); }));

            objectives.Add(new ShootingLevelObjective(Game, this, ObjectiveDescriptions[1],
                                                      "Itnos_2", LevelStartCondition.TextCleared,
                                                      new EventTextCapsule(GetEvent((int)EventID.AfterLevel2), null, EventTextCanvas.MessageBox, PortraitID.RebelTroopLeader)));

            objectives.Add(new CloseInOnLocationObjective(Game, this, ObjectiveDescriptions[1], 200,
                                                          new EventTextCapsule(GetEvent((int)EventID.OutsideRebelStation2), null, EventTextCanvas.MessageBox, PortraitID.Ente)));

            objectives.Add(new ArriveAtLocationObjective(Game, this, ObjectiveDescriptions[1]));
        }
Пример #28
0
        private void CheckKeysCursorLevel2()
        {
            if (cursorLevel1Position == 0)
            {
                if (ControlManager.CheckPress(RebindableKeys.Down) && elapsedSinceKey > 100)
                {
                    cursorLevel2Position += 1;

                    if (cursorLevel2Position > MissionManager.ReturnActiveMissions().Count)
                    {
                        cursorLevel2Position = 0;
                    }

                    elapsedSinceKey = 0;
                }

                if (ControlManager.CheckPress(RebindableKeys.Up) && elapsedSinceKey > 100)
                {
                    cursorLevel2Position -= 1;
                    if (cursorLevel2Position < 0)
                    {
                        cursorLevel2Position = MissionManager.ReturnActiveMissions().Count;
                    }

                    elapsedSinceKey = 0;
                }

                if ((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) &&
                    elapsedSinceKey > 100)
                {
                    int missionCount = MissionManager.ReturnActiveMissions().Count;

                    if (missionCount > 0 &&
                        cursorLevel2Position == missionCount)
                    {
                        cursorLevel = 1;
                    }

                    elapsedSinceKey = 0;
                }

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

            else if (cursorLevel1Position == 1)
            {
                if (ControlManager.CheckPress(RebindableKeys.Down) && elapsedSinceKey > 100)
                {
                    cursorLevel2Position += 1;
                    if (cursorLevel2Position > MissionManager.ReturnCompletedDeadMissions().Count)
                    {
                        cursorLevel2Position = 0;
                    }

                    elapsedSinceKey = 0;
                }

                if (ControlManager.CheckPress(RebindableKeys.Up) && elapsedSinceKey > 100)
                {
                    cursorLevel2Position -= 1;
                    if (cursorLevel2Position < 0)
                    {
                        cursorLevel2Position = MissionManager.ReturnCompletedDeadMissions().Count;
                    }

                    elapsedSinceKey = 0;
                }

                if ((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) &&
                    elapsedSinceKey > 100)
                {
                    int missionCount = MissionManager.ReturnCompletedDeadMissions().Count;

                    if (missionCount > 0 &&
                        cursorLevel2Position == missionCount)
                    {
                        cursorLevel = 1;
                    }

                    elapsedSinceKey = 0;
                }

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

            else if (cursorLevel1Position == 2)
            {
                if (ControlManager.CheckPress(RebindableKeys.Down) && elapsedSinceKey > 100)
                {
                    cursorLevel2Position += 1;
                    if (cursorLevel2Position > MissionManager.ReturnFailedDeadMissions().Count)
                    {
                        cursorLevel2Position = 0;
                    }

                    elapsedSinceKey = 0;
                }

                if (ControlManager.CheckPress(RebindableKeys.Up) && elapsedSinceKey > 100)
                {
                    cursorLevel2Position -= 1;
                    if (cursorLevel2Position < 0)
                    {
                        cursorLevel2Position = MissionManager.ReturnFailedDeadMissions().Count;
                    }

                    elapsedSinceKey = 0;
                }

                if ((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) &&
                    elapsedSinceKey > 100)
                {
                    int missionCount = MissionManager.ReturnFailedDeadMissions().Count;

                    if (missionCount > 0 &&
                        cursorLevel2Position == missionCount)
                    {
                        cursorLevel = 1;
                    }

                    elapsedSinceKey = 0;
                }

                if (ControlManager.CheckPress(RebindableKeys.Action2) && elapsedSinceKey > 100)
                {
                    cursorLevel     = 1;
                    elapsedSinceKey = 0;
                }
            }
        }
        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));
                }
            }
        }
        public override void Update(GameTime gameTime)
        {
            if (BaseState.GetBase() != null)
            {
                availableMissions = MissionManager.ReturnAvailableMissions(BaseState.GetBase().name);
            }

            if (BaseStateManager.ButtonControl.Equals(ButtonControl.Mission) ||
                BaseStateManager.ButtonControl.Equals(ButtonControl.Response))
            {
                missionCursor.isActive  = true;
                missionCursor.isVisible = true;
            }

            else
            {
                missionCursor.isActive  = false;
                missionCursor.isVisible = false;
            }


            if (BaseStateManager.ButtonControl == ButtonControl.Mission)
            {
                //Moves button cursor right when pressing up.
                if (ControlManager.CheckPress(RebindableKeys.Up))
                {
                    missionCursorIndex--;
                }

                //Moves button cursor left when pressing down
                else if (ControlManager.CheckPress(RebindableKeys.Down))
                {
                    missionCursorIndex++;
                }

                if (MissionCursorIndex > availableMissions.Count)
                {
                    missionCursorIndex = 0;
                }

                else if (MissionCursorIndex < 0)
                {
                    missionCursorIndex = availableMissions.Count;
                }

                for (int i = 0; i < availableMissions.Count + 1; i++)
                {
                    String text = i != availableMissions.Count ? availableMissions[i].MissionName : "Back";

                    if (ControlManager.IsMouseOverText(FontManager.GetFontStatic(14), text,
                                                       new Vector2(Game1.ScreenSize.X / 2,
                                                                   Game1.ScreenSize.Y / 2 - 40 + (20 * (i + (i == availableMissions.Count ? 1 : 0)))
                                                                   + FindTextBoxWithText(text).TextBoxRect.Height)))
                    {
                        if (ControlManager.IsMouseMoving())
                        {
                            missionCursorIndex = i;
                        }
                    }
                }

                if (availableMissions.Count > 0 && missionCursorIndex != availableMissions.Count)
                {
                    selectedMission = availableMissions[MissionCursorIndex];
                }
            }

            else if (BaseStateManager.ButtonControl == ButtonControl.Response)
            {
                //Moves button cursor right when pressing up.
                if (ControlManager.CheckPress(RebindableKeys.Up))
                {
                    responseCursorIndex--;
                }

                //Moves button cursor left when pressing down
                else if (ControlManager.CheckPress(RebindableKeys.Down))
                {
                    responseCursorIndex++;
                }

                if (MissionManager.MissionResponseBuffer.Count <= 0)
                {
                    if (ControlManager.IsMouseOverArea(new Rectangle(
                                                           BaseStateManager.ResponseRectangles[0].X - (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.PosResponse).X / 2,
                                                           BaseStateManager.ResponseRectangles[0].Y + BaseStateManager.ResponseRectangles[0].Height / 2,
                                                           (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.PosResponse).X,
                                                           (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.PosResponse).Y)))
                    {
                        responseCursorIndex = 0;
                    }

                    else if (ControlManager.IsMouseOverArea(new Rectangle(
                                                                BaseStateManager.ResponseRectangles[1].X - (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.NegResponse).X / 2,
                                                                BaseStateManager.ResponseRectangles[1].Y + BaseStateManager.ResponseRectangles[1].Height / 2,
                                                                (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.NegResponse).X,
                                                                (int)FontManager.GetFontStatic(14).MeasureString(selectedMission.NegResponse).Y)))
                    {
                        responseCursorIndex = 1;
                    }

                    if (responseCursorIndex > 1)
                    {
                        responseCursorIndex = 0;
                    }

                    else if (responseCursorIndex < 0)
                    {
                        responseCursorIndex = 1;
                    }
                }

                else
                {
                    for (int i = 0; i < MissionManager.MissionResponseBuffer.Count; i++)
                    {
                        if (ControlManager.IsMouseOverArea(new Rectangle(
                                                               BaseStateManager.ResponseRectangles[i].X - (int)FontManager.GetFontStatic(14).MeasureString(MissionManager.MissionResponseBuffer[i]).X / 2,
                                                               BaseStateManager.ResponseRectangles[i].Y + BaseStateManager.ResponseRectangles[i].Height / 2,
                                                               (int)FontManager.GetFontStatic(14).MeasureString(MissionManager.MissionResponseBuffer[i]).X,
                                                               (int)FontManager.GetFontStatic(14).MeasureString(MissionManager.MissionResponseBuffer[i]).Y)))
                        {
                            responseCursorIndex = i;
                        }
                    }

                    if (responseCursorIndex > MissionManager.MissionResponseBuffer.Count - 1)
                    {
                        responseCursorIndex = 0;
                    }

                    else if (responseCursorIndex < 0)
                    {
                        responseCursorIndex = MissionManager.MissionResponseBuffer.Count - 1;
                    }
                }
            }

            if (BaseStateManager.ButtonControl != ButtonControl.Response &&
                ControlManager.CheckPress(RebindableKeys.Pause))
            {
                SkipMissionText();
            }
            else
            {
                base.Update(gameTime);
            }
        }