public static bool IsMouseOverText(SpriteFont font, String text, Vector2 textPosition, bool textCentered = true) { Vector2 textOrigin; Vector2 textDimension; Rectangle textRect; textOrigin = textCentered ? font.MeasureString(text) / 2 : Vector2.Zero; textDimension = font.MeasureString(text); textRect = new Rectangle((int)(textPosition.X - textOrigin.X), (int)(textPosition.Y - textOrigin.Y), (int)textDimension.X, (int)textDimension.Y); return(showMouse && CollisionDetection.IsPointInsideRectangle(ControlManager.GetMousePosition(), textRect)); }
public override void Update(GameTime gameTime) { // Check if arrived at destination if (CollisionDetection.IsRectInRect(ship.Bounds, target.Bounds)) { ship.HasArrived = true; Finished = true; } else { ship.destination = target.position; Finished = false; } }
public virtual void Draw(SpriteBatch spriteBatch) { foreach (GameObjectOverworld obj in gameObjects) { obj.Draw(spriteBatch); } for (int i = 0; i < gameObjects.Count; i++) { if (CollisionDetection.IsRectInRect(game.player.Bounds, gameObjects[i].Bounds)) { if (!game.stateManager.overworldState.IsBurnOutEndingActivated) { if (gameObjects[i].Class == "Planet") { CollisionHandlingOverWorld.DrawRectAroundObject(game, spriteBatch, gameObjects[i].Bounds); game.helper.DisplayText("Press 'Enter' to enter planetary orbit."); } else if (gameObjects[i].Class == "Station") { CollisionHandlingOverWorld.DrawRectAroundObject(game, spriteBatch, gameObjects[i].Bounds); game.helper.DisplayText("Press 'Enter' to dock with station."); } else if (gameObjects[i] is Beacon && !game.player.HyperspeedOn) { CollisionHandlingOverWorld.DrawRectAroundObject(game, spriteBatch, gameObjects[i].Bounds); if (!((Beacon)gameObjects[i]).IsActivated) { game.helper.DisplayText("Press 'Enter' to activate beacon."); } else { game.helper.DisplayText("Press 'Enter' to interact with beacon."); } } else if (gameObjects[i] is SubInteractiveObject) { CollisionHandlingOverWorld.DrawRectAroundObject(game, spriteBatch, gameObjects[i].Bounds); game.helper.DisplayText("Press 'Enter' to investigate."); } } } } }
private void Collision() { messageTimer--; if (numberOfEnemyShips < startingNumberOfEnemyShips) { for (int i = 0; i < enemies.Count; i++) { if (CollisionDetection.IsRectInRect(escortDataCapsule.ShipToDefend.Bounds, enemies[i].Bounds)) { game.stateManager.overworldState.RemoveOverworldObject(enemies[i]); StartEnemyLevel(i, enemies[i].Level); } } } }
public override void Update(PlayTime playTime) { base.Update(playTime); if (GameStateManager.currentState == "OverworldState" && !startMessageDisplayed) { startMessageDisplayed = true; PopupHandler.DisplayMessage(startMessage); } if (!deviationAllowed && !CollisionDetection.IsPointInsideCircle(game.player.position, shipsToFollow[0].position, deviationRadius) && outOfRangeTimer <= 0) { outOfRangeTimer = 150; PopupHandler.DisplayMessage(deviationMessage); foreach (OverworldShip ship in shipsToFollow) { ship.Wait(); } } if (!deviationAllowed && outOfRangeTimer > 0) { outOfRangeTimer--; if (outOfRangeTimer == 149) { game.player.InitializeHyperSpeedJump(shipsToFollow[0].position, false); } if (outOfRangeTimer < 1) { outOfRangeTimer = -100; foreach (OverworldShip ship in shipsToFollow) { ship.Start(); } } } }
public void Update(GameTime gameTime, List <GameObjectOverworld> objectsInOverworld, Vector2 cameraPos) { objectsVisibleOnRadar.Clear(); missionArrows.Clear(); availableMainMissionArrows.Clear(); availableMainMissionLocationNames.Clear(); availableMainMissionLocationNames = MissionManager.GetAvailableMainMissionLocationNames(); colorSwapCounter += 1 * MathFunctions.FPSSyncFactor(gameTime); foreach (GameObjectOverworld obj in objectsInOverworld) { // Adds visible game objects if (CollisionDetection.IsPointInsideCircle(obj.position, game.player.position, viewRadius)) { objectsVisibleOnRadar.Add(obj); } // Adds mission arrows for non-visible mission coordinates else if (MissionManager.IsCurrentObjectiveDestination(obj) || MissionManager.IsFailedMissionDestination(obj)) { Boolean isMain = MissionManager.IsMainMissionDestination(obj); missionArrows.Add(new DirectionArrow(spriteSheet, obj.position, playerpos, isMain)); } else if (MissionManager.IsNoMainMissionActive()) { foreach (String str in availableMainMissionLocationNames) { if (obj.name.ToLower().Equals(str.ToLower())) { availableMainMissionArrows.Add(new DirectionArrow(spriteSheet, obj.position, playerpos, true)); break; } } } } playerpos = game.player.position; Origin = new Vector2(cameraPos.X + Game1.ScreenSize.X / 2 - background.SourceRectangle.Value.Width, cameraPos.Y + Game1.ScreenSize.Y / 2 - background.SourceRectangle.Value.Height); }
public override bool Failed() { if (Destination is Planet && mission.MissionHelper.IsPlayerOnPlanet(Destination.name)) { return(!PlayerHasItem()); } else if (Destination is Station && mission.MissionHelper.IsPlayerOnStation(Destination.name)) { return(!PlayerHasItem()); } else if (CollisionDetection.IsRectInRect(game.player.Bounds, Destination.Bounds)) { return(!PlayerHasItem()); } return(false); }
public override bool Completed() { if (isOnCompletedCalled) { return(true); } if (Destination is Planet) { return(PlayerHasItem() && mission.MissionHelper.IsPlayerOnPlanet(Destination.name)); } else if (Destination is Station) { return(PlayerHasItem() && mission.MissionHelper.IsPlayerOnStation(Destination.name)); } else { return(PlayerHasItem() && CollisionDetection.IsRectInRect(game.player.Bounds, Destination.Bounds)); } }
public override void Action() { if (ai.ClosestObject != null && CollisionDetection.IsPointInsideCircle(ai.ClosestObject.Position, Ship.Position, ai.AvoidRadius)) { aIAction = AIAction.Avoid; } else if (ai.FormationArea != null && !Ship.Bounding.Intersects(ai.FormationArea)) { aIAction = AIAction.Formation; } else { aIAction = AIAction.Idle; } base.Action(); }
public override void MissionLogic() { base.MissionLogic(); if (StatsManager.gameMode != GameMode.Develop && !CollisionDetection.IsPointInsideCircle(Game.player.position, MissionArea, MissionAreaRadius) && !Game.player.HyperspeedOn) { PopupHandler.DisplayPortraitMessage(PortraitID.Berr, "Where are you going? Follow the blinking gold dot on you radar to get to the mining station."); Game.player.BounceBack(); } if (downedShips == -1 && Game.stateManager.shooterState.GetLevel("RebelsInTheMeteors").IsMapCompleted) { downedShips = Game.stateManager.shooterState.GetLevel("RebelsInTheMeteors").enemiesKilledByPlayer; int bonus = downedShips * DownedShipsMultiplier; ReplaceObjectiveText(TextType.Completed, MoneyID, MoneyReward); ReplaceObjectiveText(TextType.Completed, BonusID, bonus); moneyReward += bonus; } }
//Checks if the systemsprites in a list should be drawn to the screen public static void CheckObjectUsage(Game1 Game, List <GameObjectOverworld> list) { for (int i = 0; i < list.Count; i++) { Nullable <Rectangle> cameraView = CollisionDetection.CurrentViewRectangle(Game.camera.cameraPos, Game); if (list[i].position.X - list[i].sprite.SourceRectangle.Value.Width / 2 <= cameraView.Value.Width && list[i].position.X + list[i].sprite.SourceRectangle.Value.Width / 2 >= cameraView.Value.X && list[i].position.Y - list[i].sprite.SourceRectangle.Value.Height / 2 <= cameraView.Value.Height && list[i].position.Y + list[i].sprite.SourceRectangle.Value.Height / 2 >= cameraView.Value.Y) { list[i].IsUsed = true; } else { list[i].IsUsed = false; } } }
//Kontrollerar "shooting" private void UpdateShooting(GameTime gameTime) { //Slutar skjuta mot objekt utanfor SightRange if (ShootObject != null) { if (!CollisionDetection.IsPointInsideCircle(ShootObject.Position, Position, SightRange)) { ShootObject = null; } } //Styr via prioritetsordningen i CheckPriority vilket objekt som ska laggas in i ShootObject. foreach (GameObjectVertical obj in Game.stateManager.shooterState.gameObjects) { if (!this.IsKilled && obj.ObjectName.Equals("Player")) { if (CollisionDetection.IsPointInsideCircle(obj.Position, Position, SightRange)) { ShootObject = obj; gunAngle = (float)Math.Atan2((double)(ShootObject.Position.Y - PositionY), (double)(ShootObject.Position.X - PositionX)); } } } //Skjuter om det finns att skjuta pa if (ShootObject != null) { HandleShooting(gameTime); } else { IdleMovement(); } }
public List <GameObjectVertical> GetTargetsWithinRange(float range) { var allGameObjects = Game.stateManager.shooterState.gameObjects; var targetsWithinRange = new List <GameObjectVertical>(); foreach (String type in ShootObjectTypes) { foreach (GameObjectVertical obj in allGameObjects) { if (obj.ObjectClass.Equals(type)) { if (CollisionDetection.IsPointInsideCircle(obj.Position, Position, range)) { if (CheckIfValidAimTarget(obj)) { targetsWithinRange.Add(obj); } } } } } return(targetsWithinRange); }
public void Avoid() { foreach (GameObjectVertical obj in Game.stateManager.shooterState.gameObjects) { if (obj.ObjectClass == "enemy" || obj.ObjectClass == "enemyBullet") { if (CollisionDetection.IsPointInsideCircle(obj.Position, ship.Position, AvoidRadius)) { AvoidList.Add(obj); } } } if (AvoidList.Count > 0) { objToAvoid = MathFunctions.ReturnClosestObject(ship, AvoidRadius, AvoidList); } if (objToAvoid == target) { Behaviour.GarbageIgnoreList.Add(target); Behaviour.UpdateIgnoreList(); target = null; } if (AvoidList.Count > 0 && objToAvoid != null) { //enemy is to the right on AI-ship's center if (objToAvoid.BoundingX + objToAvoid.BoundingWidth >= ship.PositionX && objToAvoid.BoundingX - 20 < ship.PositionX + ship.CenterPointX) { if (ship.BoundingX > (Game1.ScreenSize.X - Game.stateManager.shooterState.CurrentLevel.LevelWidth) / 2 + 20) { ship.Move(new Vector2(-1, ship.DirectionY)); } } else if (objToAvoid.BoundingX < ship.PositionX && objToAvoid.BoundingX + objToAvoid.BoundingWidth + 20 > ship.BoundingX) { if (ship.BoundingX + ship.BoundingWidth < Game.stateManager.shooterState.CurrentLevel.LevelWidth - 20) { ship.Move(new Vector2(1, ship.DirectionY)); } } else { ship.Stop("x"); } } for (int i = 0; i < AvoidList.Count; i++) { if (AvoidList[i].IsKilled || AvoidList[i].IsOutside || !CollisionDetection.IsPointInsideCircle(AvoidList[i].Position, ship.Position, AvoidRadius)) { GarbageAvoidList.Add(AvoidList[i]); if (objToAvoid == AvoidList[i]) { objToAvoid = null; } } } foreach (GameObjectVertical obj in GarbageAvoidList) { AvoidList.Remove(obj); } GarbageAvoidList.Clear(); }
public static bool IsMouseOverArea(Rectangle area) { return(showMouse && CollisionDetection.IsPointInsideRectangle(new Vector2(currentMouseState.X, currentMouseState.Y), area)); }
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])); }
protected override void SetupObjectives() { objectives.Clear(); Objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0], new EventTextCapsule(GetEvent((int)EventID.ToMeetingPoint), null, EventTextCanvas.MessageBox, PortraitID.Ai), delegate { }, delegate { }, delegate { return(GameStateManager.currentState.ToLower().Equals("overworldstate")); }, delegate { return(false); })); Objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0], delegate { foreach (OverworldShip ship in rebelShips) { Game.stateManager.overworldState.AddOverworldObject(ship); } }, delegate { }, delegate { return(true); }, delegate { return(false); })); Objectives.Add(new CloseInOnLocationObjective(Game, this, ObjectiveDescriptions[0], 400)); Objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0], new EventTextCapsule(GetEvent((int)EventID.AtMeetingPoint1), null, EventTextCanvas.MessageBox, PortraitID.RebelPilot), delegate { OverworldShip.FollowPlayer = false; StartFreighter(); }, delegate { }, delegate { return(true); }, delegate { return(false); })); Objectives.Add(new TimedMessageObjective(Game, this, ObjectiveDescriptions[0], 3000, 10000, PortraitID.RebelPilot, GetEvent((int)EventID.AtMeetingPoint2).Text)); TimedMessageObjective timedMessageObjective = new TimedMessageObjective(Game, this, ObjectiveDescriptions[0], 3000, 10000, PortraitID.RebelPilot, GetEvent((int)EventID.AtMeetingPoint3).Text); timedMessageObjective.SetEventText( new EventTextCapsule(GetEvent((int)EventID.AtMeetingPoint4), null, EventTextCanvas.MessageBox, PortraitID.RebelPilot)); Objectives.Add(timedMessageObjective); Objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0], new EventTextCapsule(GetEvent((int)EventID.AttackFreighter), null, EventTextCanvas.MessageBox, PortraitID.RebelPilot), delegate { }, delegate { }, delegate { return(Vector2.Distance(rebelShips[0].position, freighter.position) < 500); }, delegate { return(false); })); Objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[0], delegate { }, delegate { }, delegate { return(CollisionDetection.IsRectInRect(rebelShips[0].Bounds, freighter.Bounds)); }, delegate { return(false); })); objectives.Add(new ShootingLevelObjective(Game, this, ObjectiveDescriptions[0], "Retribution1", LevelStartCondition.Immediately, new EventTextCapsule(GetEvent((int)EventID.AfterLevel), null, EventTextCanvas.MessageBox, PortraitID.RebelPilot))); objectives.Add(new CustomObjective(Game, this, ObjectiveDescriptions[1], delegate { freighter.Explode(); freighter.Destroy(); Game.stateManager.overworldState.GetSectorX.shipSpawner.AddOverworldShip( alliance1, Game.player.position + new Vector2(-900, 0), "Retribution2", Game.player); OverworldShip.FollowPlayer = true; }, delegate { }, delegate { return(true); }, delegate { return(false); })); CustomObjective chaseObjective = new CustomObjective(Game, this, ObjectiveDescriptions[1], delegate { }, delegate { }, delegate { if (Game.stateManager.shooterState.CurrentLevel != null && Game.stateManager.shooterState.CurrentLevel.Identifier.Equals("Retribution2")) { return(Game.stateManager.shooterState.CurrentLevel.IsObjectiveCompleted && GameStateManager.currentState.Equals("OverworldState")); } return(Game.stateManager.overworldState.GetCurrentSpaceRegion is RebelOutpost); }, delegate { if (Game.stateManager.shooterState.CurrentLevel != null && Game.stateManager.shooterState.CurrentLevel.Identifier.Equals("Retribution2")) { return(Game.stateManager.shooterState.CurrentLevel.IsObjectiveFailed && GameStateManager.currentState.Equals("OverworldState")); } return(false); }); chaseObjective.SetCompletedLogic( delegate { alliance1.AIManager = new PatrolAction(alliance1, Game.stateManager.overworldState.GetSectorX); }); objectives.Add(chaseObjective); objectives.Add(new ArriveAtLocationObjective(Game, this, ObjectiveDescriptions[1])); }
public void UpdateProgressionConditions() { // Screening off player from certain locations if (StatsManager.gameMode != GameMode.Develop && mainInfiltration.MissionState != StateOfMission.CompletedDead && mainInfiltration.ObjectiveIndex < 9) { if (!game.player.HyperspeedOn) { if (CollisionDetection.IsRectInRect(game.player.Bounds, game.stateManager.overworldState.GetRebelOutpost.SpaceRegionArea) && PopupHandler.MessageQueueCount <= 0) { PopupHandler.DisplayMessage("A large group of rebels prevents you from entering this area."); game.player.BounceBack(); } } } // Unlock missions if (mainNewFirstMission.MissionState == StateOfMission.CompletedDead && mainHighfence.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main1_2_ToHighfence); UnlockMission(MissionID.Side_FlightTraining); } if (mainHighfence.MissionState == StateOfMission.CompletedDead && mainRebels.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main2_1_TheConvoy); askRebelMission = true; } if (mainRebels.MissionState == StateOfMission.Available && game.stateManager.planetState.SubStateManager.ButtonControl == ButtonControl.Menu && askRebelMission) { askRebelMission = false; game.stateManager.planetState.SubStateManager.ChangeMenuSubState("Mission"); game.stateManager.planetState.SubStateManager.MissionMenuState.SelectedMission = mainRebels; game.stateManager.planetState.SubStateManager.MissionMenuState.DisplayMissionIntroduction(); } if (mainRebels.MissionState == StateOfMission.CompletedDead && mainToPhaseTwo.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main2_2_ToFortrun); MarkMissionAsActive(MissionID.Main2_2_ToFortrun); } if (mainToPhaseTwo.MissionState == StateOfMission.CompletedDead && mainDefendColony.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main3_DefendColony); MarkMissionAsActive(MissionID.Main3_DefendColony); } if (mainDefendColony.ObjectiveIndex > 6 && astroDodger.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Side_AstroDodger); } if (mainDefendColony.MissionState == StateOfMission.CompletedDead && mainInfiltration.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main4_Infiltration); } if (mainInfiltration.MissionState == StateOfMission.CompletedDead && mainRetaliation.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main5_Retribution); MarkMissionAsActive(MissionID.Main5_Retribution); } if (mainRetaliation.MissionState == StateOfMission.CompletedDead && mainInTheNameOfScience.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main6_InTheNameOfScience); } if (mainInTheNameOfScience.MissionState == StateOfMission.CompletedDead && mainInformation.MissionState == StateOfMission.Unavailable) { UnlockMission(MissionID.Main7_Information); MarkMissionAsActive(MissionID.Main7_Information); } if (mainInformation.MissionState == StateOfMission.Completed && mainBeginningOfTheEnd.MissionState == StateOfMission.Unavailable) { mainInformation.MissionState = StateOfMission.CompletedDead; UnlockMission(MissionID.Main8_1_BeginningOfTheEnd); MarkMissionAsActive(MissionID.Main8_1_BeginningOfTheEnd); game.AutoSave(); } // Start second mission after first is completed if (mainNewFirstMission.MissionState == StateOfMission.CompletedDead && mainHighfence.MissionState == StateOfMission.Available && mainHighfence.MissionHelper.IsPlayerOnStation("Border Station")) { MarkMissionAsActive(MissionID.Main1_2_ToHighfence); } // Start part 2 of final mission if (mainBeginningOfTheEnd.MissionState == StateOfMission.Completed && mainTheEnd.MissionState == StateOfMission.Unavailable) { mainBeginningOfTheEnd.MissionState = StateOfMission.CompletedDead; UnlockMission(MissionID.Main8_2_TheEnd); MarkMissionAsActive(MissionID.Main8_2_TheEnd); game.AutoSave(); } // Final mission stuff if ((mainTheEnd.MissionState == StateOfMission.Completed || (mainTheEnd.MissionState == StateOfMission.CompletedDead && !RebelFleet.IsShown)) && GameStateManager.currentState.Equals("OverworldState")) { UnlockMission(MissionID.Main9_C_OnYourOwnArc); mainTheEnd.MissionState = StateOfMission.CompletedDead; RebelFleet rebelFleet = new RebelFleet(game, game.stateManager.overworldState.GetSectorX.GetSpriteSheet(), Vector2.Zero); AllianceFleet allianceFleet = new AllianceFleet(game, game.stateManager.overworldState.GetSectorX.GetSpriteSheet(), Vector2.Zero); RebelFleet.IsShown = true; rebelFleet.Initialize(); allianceFleet.Initialize(); game.stateManager.overworldState.AddOverworldObject(rebelFleet); game.stateManager.overworldState.AddOverworldObject(allianceFleet); game.AutoSave(); } if (mainRebelArc.MissionState == StateOfMission.Completed) { mainRebelArc.MissionState = StateOfMission.CompletedDead; game.stateManager.outroState.SetOutroType(OutroType.RebelEnd); game.stateManager.ChangeState("OutroState"); } else if (mainAllianceArc.MissionState == StateOfMission.Completed) { mainAllianceArc.MissionState = StateOfMission.CompletedDead; game.stateManager.outroState.SetOutroType(OutroType.AllianceEnd); game.stateManager.ChangeState("OutroState"); } else if (mainOnYourOwnArc.MissionState == StateOfMission.Completed) { mainOnYourOwnArc.MissionState = StateOfMission.CompletedDead; game.stateManager.ChangeState("OverworldState"); game.stateManager.overworldState.ActivateBurnOutEnding(); } }
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(); }
private void DetermineCurrentRegion() { if (CollisionDetection.IsRectInRect(Game.player.Bounds, highFenceOrbit.SpaceRegionArea)) { if (currentSpaceRegion != highFenceOrbit) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = highFenceOrbit; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, fortrunOrbit.SpaceRegionArea)) { if (currentSpaceRegion != fortrunOrbit) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = fortrunOrbit; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, newNorrlandOrbit.SpaceRegionArea)) { if (currentSpaceRegion != newNorrlandOrbit) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = newNorrlandOrbit; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, soelaraOrbit.SpaceRegionArea)) { if (currentSpaceRegion != soelaraOrbit) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = soelaraOrbit; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, lavisOrbit.SpaceRegionArea)) { if (currentSpaceRegion != lavisOrbit) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = lavisOrbit; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, peyeOrbit.SpaceRegionArea)) { if (currentSpaceRegion != peyeOrbit) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = peyeOrbit; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, sectorX.SpaceRegionArea)) { if (currentSpaceRegion != sectorX) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = sectorX; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, outpostX.SpaceRegionArea)) { if (currentSpaceRegion != outpostX) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = outpostX; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, borderXOutpost.SpaceRegionArea)) { if (currentSpaceRegion != borderXOutpost) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = borderXOutpost; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, miningOutpost.SpaceRegionArea)) { if (currentSpaceRegion != miningOutpost) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = miningOutpost; currentSpaceRegion.OnEnter(); } } else if (CollisionDetection.IsRectInRect(Game.player.Bounds, rebelOutpost.SpaceRegionArea)) { if (currentSpaceRegion != rebelOutpost) { previousSpaceRegion = currentSpaceRegion; currentSpaceRegion = rebelOutpost; currentSpaceRegion.OnEnter(); } } else { if (currentSpaceRegion != null) { previousSpaceRegion = currentSpaceRegion; previousSpaceRegion.OnLeave(); currentSpaceRegion = null; } } }
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])); }