예제 #1
0
        protected override void Update(GameTime gameTime)
        {
            Window.Title = "The Sun Will Go Out";
            //Window.Title = "Pos x: " + player.position.X + " Pos y: " + player.position.Y;

            if (IsActive)
            {
                ControlManager.Update(gameTime);

                //Toggles fullscreen on/off
                if (ControlManager.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) && ControlManager.CheckKeyPress(Keys.F))
                {
                    graphics.ToggleFullScreen();
                    graphics.ApplyChanges();
                }

                //Checks if the player should be used
                if (GameStateManager.currentState == "OverworldState" || GameStateManager.currentState == "System1State" ||
                    GameStateManager.currentState == "System2State" || GameStateManager.currentState == "System3State")
                {
                    player.IsUsed = true;
                }
                else
                {
                    player.IsUsed = false;
                }

                if (!Paused)
                {
                    if (player.IsUsed)
                    {
                        player.Update(gameTime);
                    }

                    stateManager.Update(gameTime);
                    missionManager.Update(gameTime);
                    tutorialManager.Update(gameTime);
                    shopManager.Update(gameTime);
                }

                else if (ZoomMap.IsMapOn)
                {
                    camera.CameraUpdate(gameTime, player);
                }

                soundEffectsManager.Update(gameTime);

                if (ControlManager.CheckPress(RebindableKeys.Map) &&
                    GameStateManager.currentState == "OverworldState" &&
                    !PopupHandler.IsMenuOpen)
                {
                    ZoomMap.ToggleMap();
                    soundEffectsManager.StopSoundEffect(SoundEffects.OverworldEngine);
                }

                if (ZoomMap.IsMapOn)
                {
                    ZoomMap.Update(gameTime, stateManager.overworldState.GetZoomObjects, camera);
                }

                popupHandler.Update(gameTime);
                helper.Update(gameTime);
                beaconMenu.Update(gameTime);

                fpsTimer -= gameTime.ElapsedGameTime.Milliseconds;
                if (fpsTimer <= 0)
                {
                    fps      = (float)Math.Round((1 / gameTime.ElapsedGameTime.TotalSeconds), 0);
                    fpsTimer = 250;
                }

                if (ControlManager.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) &&
                    ControlManager.CheckKeyPress(Keys.M))
                {
                    musicManager.SwitchMusicMuted();
                }

                menuBGController.Update(gameTime);

                base.Update(gameTime);
            }
        }
예제 #2
0
        public void DrawEndMessage(SpriteBatch spriteBatch)
        {
            if (IsObjectiveCompleted)
            {
                spriteBatch.DrawString(font1, "Level Completed!\n\n" + EndText,
                                       new Vector2(Game1.ScreenSize.X / 2,
                                                   Game1.ScreenSize.Y / 2) + Game.fontManager.FontOffset,
                                       Game.fontManager.FontColor,
                                       0f,
                                       font1.MeasureString("Level Completed!\n\n" + EndText) / 2,
                                       1f,
                                       SpriteEffects.None,
                                       0.9f);
            }
            else if (IsObjectiveFailed || isLevelGivenUp)
            {
                String failText;
                if (!isPirateLevel)
                {
                    failText = String.Format("You are dead!\n\nPress 'R' to try again '{0}' to go back.", ControlManager.GetKeyName(RebindableKeys.Action2));
                }
                else
                {
                    failText = String.Format("You are dead! You lost {0} crebits.\n\nPress '{1}' to go back.", pirateLossPenaly, ControlManager.GetKeyName(RebindableKeys.Action2));
                }

                spriteBatch.DrawString(font1, failText,
                                       new Vector2(Game1.ScreenSize.X / 2,
                                                   Game1.ScreenSize.Y / 2) + Game.fontManager.FontOffset,
                                       Game.fontManager.FontColor,
                                       0f,
                                       font1.MeasureString(failText) / 2,
                                       1f,
                                       SpriteEffects.None,
                                       1f);
            }
        }
예제 #3
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");
            }
        }
예제 #4
0
        protected override void Initialize()
        {
            Game1.GameRestarted = false;

            CreateDirectories();
            SetAvailableResolutions();
            GameStarted = false;

            settingsFile = new SaveFile(this);
            settingsFile.Load(SaveFilePath, "settings.ini");

            Vector2 defaultResolution = GetDefaultResolution();

            resolution = new Vector2(settingsFile.GetPropertyAsFloat("visual", "resolutionx", defaultResolution.X),
                                     settingsFile.GetPropertyAsFloat("visual", "resolutiony", defaultResolution.Y));

            random = new Random(DateTime.Now.Millisecond);

            showFPS = settingsFile.GetPropertyAsBool("visual", "showfps", false);

            // MAC CHANGE - Fullscreen before resolution
            graphics.IsFullScreen = settingsFile.GetPropertyAsBool("visual", "fullscreen", !IsDualMonitor());
            //
            graphics.PreferredBackBufferWidth       = (int)resolution.X;
            graphics.PreferredBackBufferHeight      = (int)resolution.Y;
            graphics.SynchronizeWithVerticalRetrace = true;

            // Uncomment to unlock FPS
            //IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;

            graphics.ApplyChanges();

            // MAC CHANGE - Set ScreenSize to clientbounds after applyChanges
            ScreenSize = new Point((int)Window.ClientBounds.Width, (int)Window.ClientBounds.Height);

            CenterScreenWindow();

            IsMouseVisible = settingsFile.GetPropertyAsBool("game options", "showmouse", true);

            menuBGController = new MenuBackdropController(this);
            menuBGController.Initialize();

            musicManager = new MusicManager(this);
            musicManager.Initialize();

            soundEffectsManager = new SoundEffectsManager(this);
            soundEffectsManager.Initialize();

            fontManager = new FontManager(this);
            fontManager.Initialize();

            ControlManager.LoadControls(settingsFile);

            spriteSheetOverworld       = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/smallObjectSpriteSheet"));
            spriteSheetVerticalShooter = new Sprite(Content.Load <Texture2D>("Vertical-Sprites/shooterSheet"));
            messageBoxSpriteSheet      = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/messageBoxSpriteSheet"));
            spriteSheetItemDisplay     = new Sprite(Content.Load <Texture2D>("itemVisualSheet"));
            beaconMenuSprite           = new Sprite(Content.Load <Texture2D>("Overworld-Sprites/BeaconMenu"));
            CollisionHandlingOverWorld.LoadLineTexture(this);

            shipInventoryManager = new ShipInventoryManager(this);
            shipInventoryManager.Initialize();

            statsManager = new StatsManager(this);
            statsManager.Initialize();

            player = new PlayerOverworld(this, spriteSheetOverworld);
            player.Initialize();

            beaconMenu = new BeaconMenu(this, beaconMenuSprite);
            beaconMenu.Initialize();

            stateManager = new GameStateManager(this);
            stateManager.Initialize();

            missionManager = new MissionManager(this);
            missionManager.Initialize();

            tutorialManager = new TutorialManager(this);
            tutorialManager.Initialize();
            tutorialManager.TutorialsUsed = settingsFile.GetPropertyAsBool("game options", "tutorials", true);

            shopManager = new ShopManager();

            saveFile = new SaveFile(this);

            Portrait.InitializePortraitSpriteSheet(this);
            popupHandler = new PopupHandler(this, messageBoxSpriteSheet);
            popupHandler.Initialize();

            helper = new HelperBox(this);

            ShopManager.SetShopUpdateTime(ShopManager.PRESET_SHOPTIME);

            base.Initialize();
        }
        private void UpdateTutorialMessages(GameTime gameTime)
        {
            if (!hasEnteredStation && GameStateManager.currentState.Equals("StationState") &&
                game.stateManager.stationState.SubStateManager.ButtonControl == ButtonControl.Menu)
            {
                hasEnteredStation = true;
                DisplayTutorialMessage("You can disable tutorial messages in the options menu.", TutorialImage.MenuControls);
            }

            if (!hasEnteredOverworld && GameStateManager.currentState.Equals("OverworldState"))
            {
                tempTimer -= gameTime.ElapsedGameTime.Milliseconds;

                if (tempTimer < 0)
                {
                    tempTimer           = 50;
                    hasEnteredOverworld = true;

                    DisplayTutorialImage(TutorialImage.OverworldControls);
                }
            }

            else if (!coordinatesDisplayed &&
                     hasEnteredOverworld &&
                     PopupHandler.TextBufferEmpty)
            {
                coordinatesDisplayed = true;

                DisplayTutorialMessage("Your current objective is to go to coordinates (2450, 700). To find that location, follow the blinking dot on your radar. Main missions are represented by gold-colored dots and secondary missions by silver-colored dots.",
                                       TutorialImage.Radar);
            }

            Vector2 highfenceBeaconPosition = game.stateManager.overworldState.GetBeacon("Highfence Beacon").position;

            if (!hasEnteredHighfenceBeaconArea &&
                Vector2.Distance(game.player.position, highfenceBeaconPosition) < BeaconTutorialActivationRadius)
            {
                hasEnteredHighfenceBeaconArea = true;
                DisplayTutorialMessage("This is a 'beacon'. Beacons are used for traveling quickly between planets, but they need to be activated before use. Activate a beacon by flying close to it!");
            }

            if (!hasEnteredVerticalShooter && GameStateManager.currentState.Equals("ShooterState"))
            {
                tempTimer2 -= gameTime.ElapsedGameTime.Milliseconds;

                if (tempTimer2 < 0)
                {
                    tempTimer2 = 500;

                    hasEnteredVerticalShooter = true;
                    DisplayTutorialMessage(new List <String> {
                        "You can rebind the keys in the options menu.",
                        "Down at the bottom-left you can find information about the current level objective, your active weapons and on your ship's health, energy and shields."
                    },
                                           new List <TutorialImage> {
                        TutorialImage.CombatControls, TutorialImage.CombatBars
                    },
                                           new List <int> {
                        1
                    });
                }
            }

            if (!hasEnteredShooterWithShield && !(ShipInventoryManager.equippedShield is EmptyShield) &&
                GameStateManager.currentState.Equals("ShooterState"))
            {
                tempTimer2 -= gameTime.ElapsedGameTime.Milliseconds;

                if (tempTimer2 < 0)
                {
                    tempTimer2 = 500;

                    hasEnteredShooterWithShield = true;
                    DisplayTutorialMessage("You now have a shield to protect your ship's hull! If you take a hit, the shield will absorb the damage if it has enough power.");
                }
            }

            if (equipShieldTutorial &&
                !equipShieldTutorialFinished)
            {
                game.stateManager.stationState.SubStateManager.ShopMenuState.DisplayBuyAndEquip = false;
                switch (equipShieldProgress)
                {
                case 0:
                    if (GameStateManager.currentState.Equals("StationState") &&
                        game.stateManager.stationState.Station.name.Equals("Highfence Shop"))
                    {
                        string message = "[Alliance Pilot] \"Start by selecting 'Buy/Sell' and pressing 'Enter'.";

                        if (!hasRecievedTutorialMoney)
                        {
                            message += " Here is two hundred Crebits, it should cover the cost for the shield.\"";
                        }

                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, message);

                        if (!hasRecievedTutorialMoney)
                        {
                            StatsManager.Crebits += 200;
                            PopupHandler.DisplayMessage("You recieved 200 Crebits.");
                            hasRecievedTutorialMoney = true;
                        }

                        equipShieldProgress = 1;
                    }
                    break;

                case 1:
                    if (GameStateManager.currentState.Equals("StationState") &&
                        game.stateManager.stationState.Station.name.Equals("Highfence Shop") &&
                        game.stateManager.stationState.SubStateManager.ActiveMenuState.Equals(game.stateManager.stationState.SubStateManager.ShopMenuState))
                    {
                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "[Alliance Pilot] \"Select the 'Basic shield' in the column to the right and select 'Buy'.\"");
                        equipShieldProgress = 2;
                    }
                    break;

                case 2:
                    if (GameStateManager.currentState.Equals("StationState") &&
                        game.stateManager.stationState.Station.name.Equals("Highfence Shop") &&
                        game.stateManager.stationState.SubStateManager.ActiveMenuState.Equals(game.stateManager.stationState.SubStateManager.ShopMenuState) &&
                        ShipInventoryManager.ownedShields.Count > 0)
                    {
                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "[Alliance Pilot] \"Good! Now exit the shop by selecting and pressing 'Go Back' and return to the overworld!\"");
                        equipShieldProgress = 3;
                    }
                    break;

                case 3:
                    if (GameStateManager.currentState.Equals("OverworldState"))
                    {
                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "[Alliance Pilot] \"Now, press 'I' to access your inventory.\"");
                        equipShieldProgress = 4;
                    }
                    break;

                case 4:
                    if (GameStateManager.currentState.Equals("ShipManagerState"))
                    {
                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "[Alliance Pilot] \"To equip your shield, select the shield slot and press 'Enter' to select from your list of available shields.\"");
                        equipShieldProgress = 5;
                    }
                    break;

                case 5:
                    if (GameStateManager.currentState.Equals("ShipManagerState") &&
                        game.stateManager.shipManagerState.IsShieldSlotSelected)
                    {
                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "[Alliance Pilot] \"Now, press 'Enter' again to equip the selected shield.\"");
                        equipShieldProgress = 6;
                    }
                    break;

                case 6:
                    if (!(ShipInventoryManager.equippedShield is EmptyShield))
                    {
                        PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "[Alliance Pilot] \"Good! Now your shield is equipped! What parts you have equipped is crucial for your success. Come back here often and try different combinations of ship parts.\"#\"Now, exit the inventory by pressing 'Escape' and return to me!\"");
                        equipShieldTutorialFinished = true;
                    }
                    break;
                }

                if (equipShieldProgress < 2 &&
                    ShipInventoryManager.OwnedShields.Count > 0)
                {
                    PopupHandler.DisplayPortraitMessage(PortraitID.AlliancePilot, "You already bought a shield? Okay, let me tell you how to equip it! Start by pressing 'I' to access your inventory.");
                    equipShieldProgress = 4;
                }
            }

            if (equipShieldTutorialFinished &&
                game.stateManager.stationState.SubStateManager.ShopMenuState.DisplayBuyAndEquip == false)
            {
                game.stateManager.stationState.SubStateManager.ShopMenuState.DisplayBuyAndEquip = true;
            }

            if (ShipInventoryManager.HasItemOfKind("LongShot") &&
                MissionManager.GetMission(MissionID.Main3_DefendColony).MissionState.Equals(StateOfMission.Unavailable) &&
                GameStateManager.currentState.Equals("OverworldState") && !longShotTutorialActivated)
            {
                tempTimer3 -= gameTime.ElapsedGameTime.Milliseconds;

                if (tempTimer3 <= 0)
                {
                    tempTimer3 = 1000;
                    longShotTutorialActivated = true;
                    DisplayTutorialMessage(new List <string>()
                    {
                        String.Format("You have recieved your first long-range weapon: 'LongShot'. You can have two weapons equipped at a time, and you can toggle between them in combat using '{0}'.", ControlManager.GetKeyName(RebindableKeys.Action2)),
                        "Try accessing your inventory with 'I' and equip LongShot on one slot and SpreadBullet on the other. Then you can vary your strategy in combat depending on which enemies you encounter."
                    });
                }
            }

            if (ShipInventoryManager.OwnedSecondary.Count > 0 && GameStateManager.currentState.Equals("OverworldState") &&
                !secondaryWeaponTutorialDisplayed)
            {
                tempTimer3 -= gameTime.ElapsedGameTime.Milliseconds;

                if (tempTimer3 <= 0)
                {
                    tempTimer3 = 1000;
                    secondaryWeaponTutorialDisplayed = true;
                    DisplayTutorialMessage("You have acquired your first secondary weapon! Don't forget to equip it if you havn't done so already. Secondary weapons are fired automatically and don't use energy, so they are very handy!");
                }
            }

            if (isAMissionFailed && GameStateManager.currentState.Equals("OverworldState") &&
                !hasDisplayedSkipMessage)
            {
                tempTimer2 -= gameTime.ElapsedGameTime.Milliseconds;

                if (tempTimer2 < 0)
                {
                    tempTimer2 = 500;

                    hasDisplayedSkipMessage = true;
                    DisplayTutorialMessage("When you fail a mission, you can replay most of them by going back to where they started. Press 'Escape' to skip dialogs and mission events you have already seen.");
                }
            }
        }
예제 #6
0
        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;
            }
        }
예제 #7
0
        /// <summary>
        /// Updates map zooming
        /// </summary>
        /// <param name="gameObjects">Objects to be scaled up for visibility</param>
        public static void Update(GameTime gameTime, List <GameObjectOverworld> gameObjects, Camera camera)
        {
            ZoomMap.camera = camera;

            if (mapState == MapState.ZoomingOut)
            {
                camera.Zoom *= ZoomRate * gameTime.ElapsedGameTime.Milliseconds;

                if (camera.Zoom <= ZoomedOutValue)
                {
                    Game1.Paused = true;
                    mapState     = MapState.On;
                }
            }
            else if (mapState == MapState.ZoomingIn)
            {
                camera.Zoom *= (1 + (1 - (ZoomRate * gameTime.ElapsedGameTime.Milliseconds)));

                if (camera.Zoom >= 1f)
                {
                    HideMap(camera, gameObjects);
                }
            }

            else if (mapState == MapState.On &&
                     (ControlManager.CheckPress(RebindableKeys.Action2) ||
                      ControlManager.CheckKeyPress(Keys.Escape)))
            {
                mapState = MapState.ZoomingIn;
            }

            // Scale up objects
            foreach (GameObjectOverworld obj in gameObjects)
            {
                if ((obj is Planet ||
                     obj.name.ToLower().Equals("soelara") ||
                     obj.name.ToLower().Equals("lavis") ||
                     obj.name.ToLower().Equals("fortrun")) &&
                    camera.Zoom < PlanetZoomScale)
                {
                    obj.scale = PlanetZoomScale / camera.Zoom;
                }

                else if (obj is SystemStar &&
                         camera.Zoom < StarZoomScale)
                {
                    obj.scale = StarZoomScale / camera.Zoom;
                }

                else if ((obj is Station ||
                          obj.name.ToLower().Equals("fortrun station")) &&
                         camera.Zoom < StationZoomScale)
                {
                    obj.scale = StationZoomScale / camera.Zoom;
                }

                else if (obj is PlayerOverworld &&
                         camera.Zoom < PlayerZoomScale)
                {
                    obj.scale = PlayerZoomScale / camera.Zoom;
                }
            }
        }
예제 #8
0
        public override void Update(PlayTime playTime)
        {
            base.Update(playTime);

            // Updates player direction and speed
            if (!HasAnyShipArrived())
            {
                game.player.Direction.SetDirection(new Vector2(
                                                       Destination.position.X - game.player.position.X,
                                                       Destination.position.Y - game.player.position.Y));

                if (ControlManager.CheckPress(RebindableKeys.Pause) &&
                    GameStateManager.currentState.Equals("OverworldState"))
                {
                    PopupHandler.DisplaySelectionMenu("Do you want to skip travel?",
                                                      new List <string>()
                    {
                        "Yes", "No"
                    },
                                                      new List <System.Action>()
                    {
                        delegate
                        {
                            SkipForward();
                        },
                        delegate {}
                    });
                }
            }
            game.player.speed = speed;

            // Displays timed messages
            if (timedMessages.Keys.Count > 0 &&
                StatsManager.PlayTime.HasOverworldTimePassed(nextMessageTime))
            {
                if (portraits.Count > 0)
                {
                    if (realTime)
                    {
                        PopupHandler.DisplayRealtimePortraitMessage(GetNextMessageDuration(), portraits[0].ToArray(),
                                                                    portraitTriggers[0], timedMessages.Keys.First());
                    }
                    else
                    {
                        realTimeSwitchIndex++;
                        PopupHandler.DisplayPortraitMessage(portraits[0], portraitTriggers[0], timedMessages.Keys.First());
                        if (useRealTimeSwitch &&
                            realTimeSwitchIndex >= activateRealTimeSwitchIndex)
                        {
                            realTime = true;
                        }
                    }

                    portraits.RemoveAt(0);
                    portraitTriggers.RemoveAt(0);
                }
                else
                {
                    if (realTime)
                    {
                        PopupHandler.DisplayRealtimeMessage(GetNextMessageDuration(), timedMessages.Keys.First());
                    }
                    else
                    {
                        realTimeSwitchIndex++;
                        PopupHandler.DisplayMessage(timedMessages.Keys.First());
                        if (useRealTimeSwitch &&
                            realTimeSwitchIndex >= activateRealTimeSwitchIndex)
                        {
                            realTime = true;
                        }
                    }
                }

                timedMessages.Remove(timedMessages.Keys.First());

                if (timedMessages.Keys.Count > 0)
                {
                    nextMessageTime = GetNextMessageStartTime();
                }
            }
        }
        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;
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Draws names of all objects in gameObjects relative to their position
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="gameObjects">objects which names to be displayed</param>
        public static void DrawOverlay(SpriteBatch spriteBatch, List <GameObjectOverworld> gameObjects)
        {
            if (mapState == MapState.On)
            {
                foreach (GameObjectOverworld obj in gameObjects)
                {
                    spriteBatch.DrawString(FontManager.GetFontStatic(14), obj.name,
                                           new Vector2(obj.position.X, obj.position.Y - ((obj.Bounds.Height * obj.scale) / 2) - 300),
                                           Color.White, 0f,
                                           FontManager.GetFontStatic(14).MeasureString(obj.name) / 2,
                                           55, SpriteEffects.None, 1f);
                }

                spriteBatch.DrawString(FontManager.GetFontStatic(14), "Press '" + ControlManager.GetKeyName(RebindableKeys.Map) + "' to hide map..",
                                       new Vector2(camera.cameraPos.X, camera.cameraPos.Y + HelpTextOffset),
                                       Color.White, 0f,
                                       FontManager.GetFontStatic(14).MeasureString("Press '" + ControlManager.GetKeyName(RebindableKeys.Map) + "' to hide map..") / 2,
                                       80, SpriteEffects.None, 1f);
            }
        }
예제 #11
0
 public static bool IsMouseMoving()
 {
     return(ControlManager.GetMousePosition() != ControlManager.GetPreviousMousePosition());
 }
예제 #12
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();
            }
        }
예제 #13
0
        private void MouseControls()
        {
            for (int i = 0; i < menuOptions.Length / 2; i++)
            {
                if (ControlManager.IsMouseOverText(menuOptionFont, menuOptions[i, 0],
                                                   new Vector2((Game1.ScreenSize.X / 9) * 4 + game.fontManager.GetFont(14).MeasureString(menuOptions[i, 0]).X / 2,
                                                               Game1.ScreenSize.Y / 3 + (i * 23) + yOffset) + fontOffset))
                {
                    if (cursorIndex != i)
                    {
                        PlayHoverSound();
                    }

                    if (ControlManager.IsLeftMouseButtonClicked())
                    {
                        ButtonActions();
                    }

                    if (ControlManager.IsMouseMoving())
                    {
                        cursorIndex = i;
                    }

                    continue;
                }

                if (!menuOptions[i, 1].Equals(""))
                {
                    if (ControlManager.IsMouseOverText(menuOptionFont, menuOptions[i, 1],
                                                       new Vector2(Game1.ScreenSize.X - 150 + game.fontManager.GetFont(14).MeasureString(menuOptions[i, 1]).X / 2,
                                                                   Game1.ScreenSize.Y / 3 + (i * 23) + yOffset) + fontOffset))
                    {
                        if (cursorIndex != i)
                        {
                            PlayHoverSound();
                        }

                        if (ControlManager.IsLeftMouseButtonClicked())
                        {
                            ButtonActions();
                        }
                        if (ControlManager.IsMouseMoving())
                        {
                            cursorIndex = i;
                        }
                    }
                }
            }

            for (int i = 0; i < directionalButtons.Count; i++)
            {
                Rectangle dirButtonRect = new Rectangle(
                    (int)directionalButtons[i].Position.X - directionalButtons[i].Passive.SourceRectangle.Value.Width / 2,
                    (int)directionalButtons[i].Position.Y - directionalButtons[i].Passive.SourceRectangle.Value.Height / 2,
                    directionalButtons[i].Passive.SourceRectangle.Value.Width + 10,
                    directionalButtons[i].Passive.SourceRectangle.Value.Height);

                if (ControlManager.IsMouseOverArea(dirButtonRect) &&
                    ControlManager.IsLeftMouseButtonClicked())
                {
                    DirectionalButtonActions(directionalButtons[i].name);
                }
            }
        }
예제 #14
0
        public override void Update(PlayTime playTime)
        {
            base.Update(playTime);

            if (autofollow && started)
            {
                if (!escortDataCapsule.ShipToDefend.HasArrived)
                {
                    game.player.Direction.SetDirection(new Vector2(
                                                           escortDataCapsule.ShipToDefend.destination.X - game.player.position.X,
                                                           escortDataCapsule.ShipToDefend.destination.Y - game.player.position.Y));
                }

                game.player.speed = escortDataCapsule.ShipToDefend.speed;

                if (ControlManager.CheckPress(RebindableKeys.Pause) &&
                    GameStateManager.currentState.Equals("OverworldState"))
                {
                    PopupHandler.DisplaySelectionMenu("Do you want to skip travel?",
                                                      new List <string>()
                    {
                        "Yes", "No"
                    },
                                                      new List <System.Action>()
                    {
                        delegate
                        {
                            SkipForward();
                        },
                        delegate {}
                    });
                }
            }

            if (timedMessageCount >= 0 &&
                timedMessageCount < timedMessages.Count &&
                StatsManager.PlayTime.HasOverworldTimePassed(timedMessageTimes[timedMessageCount]))
            {
                if (timedMessagePortraits[timedMessageCount] != PortraitID.None)
                {
                    PopupHandler.DisplayRealtimePortraitMessage(3000, new [] { timedMessagePortraits[timedMessageCount] },
                                                                new List <int>(), timedMessages[timedMessageCount]);
                }
                else
                {
                    PopupHandler.DisplayRealtimeMessage(3000, timedMessages[timedMessageCount]);
                }
                timedMessageCount++;
            }

            // Player talks to freighter to begin escort
            if (!started &&
                GameStateManager.currentState.Equals("OverworldState") &&
                CollisionDetection.IsRectInRect(game.player.Bounds, escortDataCapsule.ShipToDefend.Bounds) &&
                ((ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter))))
            {
                if (showInventoryTutorial &&
                    ShipInventoryManager.equippedShield is EmptyShield)
                {
                    PopupHandler.DisplayPortraitMessage(introductionPortrait, "[Alliance Pilot] \"You need to equip a shield before we leave. Go to the shop next to Highfence and I will tell you what to do.");
                    game.tutorialManager.EnableEquipTutorial();
                }

                else
                {
                    if (introductionPortrait != PortraitID.None)
                    {
                        PopupHandler.DisplayPortraitMessage(introductionPortrait, introductionText);
                    }
                    else
                    {
                        PopupHandler.DisplayMessage(introductionText);
                    }

                    ((FreighterShip)escortDataCapsule.ShipToDefend).Start();
                    escortDataCapsule.ShipToDefend.speed = escortDataCapsule.FreighterSpeed;

                    started = true;

                    if (autofollow)
                    {
                        game.player.DisableControls();
                    }

                    this.Description = descriptions[0];

                    enemyAttackStartTime = StatsManager.PlayTime.GetFutureOverworldTime(escortDataCapsule.EnemyAttackStartTime);

                    for (int i = 0; i < timedMessages.Count; i++)
                    {
                        timedMessageTimes.Add(StatsManager.PlayTime.GetFutureOverworldTime(escortDataCapsule.TimedMessageTriggers[i]));
                    }
                    timedMessageCount = 0;
                }
            }

            // Escort mission begins
            if (started &&
                GameStateManager.currentState.Equals("OverworldState") &&
                numberOfEnemyShips > 0 &&
                StatsManager.PlayTime.HasOverworldTimePassed(enemyAttackStartTime))
            {
                // Ready to spawn a new enemy ship
                if (StatsManager.PlayTime.HasOverworldTimePassed(enemyNextWaveTime))
                {
                    int i = startingNumberOfEnemyShips - numberOfEnemyShips;

                    if (descriptions.Count > 0)
                    {
                        if (descriptions.Count > 1)
                        {
                            descriptions.RemoveAt(0);
                        }

                        this.Description = descriptions[0];
                    }

                    if (attackStartPortraits[i] != PortraitID.None)
                    {
                        PopupHandler.DisplayPortraitMessage(attackStartPortraits[i], attackStartText[i]);
                    }
                    else
                    {
                        PopupHandler.DisplayMessage(attackStartText[i]);
                    }

                    game.stateManager.overworldState.GetSectorX.shipSpawner.AddOverworldShip(
                        enemies[0],
                        escortDataCapsule.ShipToDefend.position +
                        (650 * escortDataCapsule.ShipToDefend.Direction.GetDirectionAsVector()),
                        levels[levelIndex], escortDataCapsule.ShipToDefend);

                    numberOfEnemyShips--;

                    if (numberOfEnemyShips > 0)
                    {
                        enemyNextWaveTime = StatsManager.PlayTime.GetFutureOverworldTime(escortDataCapsule.EnemyAttackFrequency);
                    }
                }
            }

            // Transfers freigter hp between levels
            for (int i = 0; i < levels.Count; i++)
            {
                if (GameStateManager.currentState.Equals("ShooterState") &&
                    game.stateManager.shooterState.CurrentLevel.Identifier.Equals(levels[i]) &&
                    game.stateManager.shooterState.GetLevel(levels[i]).IsObjectiveCompleted)
                {
                    shipToDefendHP = game.stateManager.shooterState.CurrentLevel.GetFreighterHP();

                    levelCompleted      = true;
                    levelCompletedIndex = i;
                    levelIndex          = i + 1;
                }
            }

            if (GameStateManager.currentState.Equals("OverworldState"))
            {
                if (levelCompleted &&
                    levelCompletedIndex > lastLevelCompletedIndex)
                {
                    levelCompleted          = false;
                    lastLevelCompletedIndex = levelCompletedIndex;

                    if (afterAttackPortraits[levelCompletedIndex] != PortraitID.None)
                    {
                        PopupHandler.DisplayPortraitMessage(afterAttackPortraits[levelCompletedIndex],
                                                            afterAttackMessages[levelCompletedIndex]);
                    }
                    else
                    {
                        PopupHandler.DisplayMessage(afterAttackMessages[levelCompletedIndex]);
                    }
                }
                else
                {
                    levelCompleted = false;
                }
            }

            Collision();
        }
예제 #15
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));
                }
            }
        }
        protected override void SetupObjectives()
        {
            float time = 0;

            objectives.Clear();

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

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

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

                PopupHandler.DisplayPortraitMessage(PortraitID.Ai, "[Ai] \"Talk to the alliance ships waiting outside Fortrun when you're ready to leave.\"#\"Don't forget to stop by the shop and upgrade your equipment if you have not done so already!\"");
            },
                                               delegate
            {
                if (CollisionDetection.IsRectInRect(Game.player.Bounds, allyShipRectangle) &&
                    (ControlManager.CheckPress(RebindableKeys.Action1) ||
                     ControlManager.CheckKeyPress(Keys.Enter)) &&
                    GameStateManager.currentState.Equals("OverworldState"))
                {
                    PopupHandler.DisplaySelectionMenu("[Ai] Ready to go?",
                                                      new List <string>()
                    {
                        "Yes", "No"
                    },
                                                      new List <System.Action>()
                    {
                        delegate { readyToLeave = true; },
                        delegate { readyToLeave = false; }
                    });
                }
            },
                                               delegate { return(readyToLeave); },
                                               delegate { return(false); }));

            AutoPilotObjective autoPilotObjective1 = new AutoPilotObjective(Game, this, ObjectiveDescriptions[1], AutoPilotSpeed,
                                                                            allyShips1, fortrunStation.position,
                                                                            new EventTextCapsule(GetEvent((int)EventID.OutsideNewNorrland), null, EventTextCanvas.MessageBox, PortraitID.Ai));

            autoPilotObjective1.Initialize();
            autoPilotObjective1.SetTimedMessages(new Dictionary <string, List <float> >
            {
                { GetEvent((int)EventID.ToNewNorrland1).Text, new List <float> {
                      3000, 3000
                  } },
                { GetEvent((int)EventID.ToNewNorrland2).Text, new List <float> {
                      20000, 3000
                  } }
            },
                                                 null, null);

            objectives.Add(autoPilotObjective1);

            objectives.Add(new ShootingLevelObjective(Game, this, ObjectiveDescriptions[1],
                                                      "DefendColonyBreak", LevelStartCondition.TextCleared));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0],
                                               new EventTextCapsule(GetEvent((int)EventID.FirstLevelCompleted), null, EventTextCanvas.MessageBox, PortraitID.Ai),
                                               delegate
            {
                Game.stateManager.GotoPlanetSubScreen("New Norrland", "Overview");
            },
                                               delegate { },
                                               delegate { return(true); },
                                               delegate { return(false); }));

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

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[1],
                                               delegate
            {
                RemoveShips(allyShips1);
                SetupAllyShips(allyShips2,
                               new Vector2(newNorrland.position.X + 0, newNorrland.position.Y - 625),
                               fortrunStation);
            },
                                               delegate { },
                                               delegate { return(true); },
                                               delegate { return(false); }));

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[2],
                                               new EventTextCapsule(new EventText("[Ai] \"Let's go\""), null, EventTextCanvas.MessageBox, PortraitID.Ai),
                                               delegate
            {
                allyShipRectangle = new Rectangle(
                    (int)allyShips2[0].position.X - AllyShipRectOffset,
                    (int)allyShips2[0].position.Y - AllyShipRectOffset,
                    AllyShipRectWidth, AllyShipRectHeight);
                readyToLeave = false;

                PopupHandler.DisplayPortraitMessage(PortraitID.Ai, "[Ai] \"Talk to the alliance ships waiting outside New Norrland 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("[Ai] Ready to head back?",
                                                      new List <string>()
                    {
                        "Yes", "No"
                    },
                                                      new List <System.Action>()
                    {
                        delegate { readyToLeave = true; },
                        delegate { readyToLeave = false; }
                    });
                }
            },
                                               delegate { return(readyToLeave); },
                                               delegate { return(false); }));

            AutoPilotObjective autoPilotObjective = new AutoPilotObjective(Game, this, ObjectiveDescriptions[3], AutoPilotSpeed2,
                                                                           allyShips2, newNorrland.position, false);

            autoPilotObjective.Initialize();
            autoPilotObjective.SetActivateRealTimeIndex(2);
            autoPilotObjective.SetTimedMessages(
                new Dictionary <string, List <float> >
            {
                { GetEvent((int)EventID.ToFortrun1).Text, new List <float> {
                      7000, 3000
                  } },
                { GetEvent((int)EventID.ToFortrun2).Text, new List <float> {
                      1000, 3000
                  } },
                { GetEvent((int)EventID.ToFortrun3).Text, new List <float> {
                      4000, 3000
                  } },
            },
                new List <List <PortraitID> >()
            {
                new List <PortraitID> {
                    PortraitID.Sair, PortraitID.CommonCitizen
                },
                new List <PortraitID> {
                    PortraitID.Ai
                },
                new List <PortraitID> {
                    PortraitID.Sair
                }
            },
                new List <List <int> > {
                new List <int> {
                    1
                }, new List <int> {
                }, new List <int> {
                }
            });

            objectives.Add(autoPilotObjective);

            objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[3],
                                               delegate
            {
                RemoveShips(allyShips2);
                Game.stateManager.GotoStationSubScreen("Fortrun Station", "Mission");
            },
                                               delegate { },
                                               delegate { return(true); },
                                               delegate { return(false); }));

            objectives.Add(new ArriveAtLocationObjective(Game, this, ObjectiveDescriptions[3]));
        }
예제 #17
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;
                }
            }
        }