Exemplo n.º 1
0
        private void EnterCheck()
        {
            for (int i = 0; i < gameObjects.Count; i++)
            {
                if (CollisionDetection.IsRectInRect(game.player.Bounds, gameObjects[i].Bounds))
                {
                    // TODO Repair the ship. Temporary solution.
                    StatsManager.RepairShip(StatsManager.Armor());

                    if (gameObjects[i] is Planet)
                    {
                        if (gameObjects[i].name.Equals("Highfence"))
                        {
                            Mission mission = MissionManager.GetMission(MissionID.Main8_1_BeginningOfTheEnd);

                            if (mission.MissionState == StateOfMission.Active)
                            {
                                if (mission.ObjectiveIndex != 0)
                                {
                                    game.stateManager.planetState.LoadPlanetData((Planet)gameObjects[i]);
                                    game.stateManager.ChangeState("PlanetState");
                                }
                            }
                            else
                            {
                                game.stateManager.planetState.LoadPlanetData((Planet)gameObjects[i]);
                                game.stateManager.ChangeState("PlanetState");
                            }
                        }

                        else
                        {
                            game.stateManager.planetState.LoadPlanetData((Planet)gameObjects[i]);
                            game.stateManager.ChangeState("PlanetState");
                        }
                    }

                    else if (gameObjects[i] is Station)
                    {
                        game.stateManager.stationState.LoadStationData((Station)gameObjects[i]);
                        game.stateManager.ChangeState("StationState");
                    }

                    else if (gameObjects[i] is Beacon)
                    {
                        ((Beacon)gameObjects[i]).Interact();
                    }

                    else if (gameObjects[i] is SubInteractiveObject)
                    {
                        ((SubInteractiveObject)gameObjects[i]).Interact();
                    }

                    else if (gameObjects[i] is OverworldShip)
                    {
                        ((OverworldShip)gameObjects[i]).Interact();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override bool Completed()
        {
            if (isOnCompletedCalled)
            {
                return(true);
            }

            if (Destination is Planet)
            {
                return(mission.MissionHelper.IsPlayerOnPlanet(Destination.name));
            }
            else if (Destination is Station)
            {
                return(mission.MissionHelper.IsPlayerOnStation(Destination.name));
            }
            else if (Destination is SubInteractiveObject)
            {
                return(CollisionDetection.IsRectInRect(game.player.Bounds, Destination.Bounds) &&
                       (ControlManager.CheckPress(RebindableKeys.Action1) || ControlManager.CheckKeyPress(Keys.Enter)) &&
                       !PopupHandler.IsMenuOpen);
            }
            else
            {
                return(CollisionDetection.IsRectInRect(game.player.Bounds, Destination.Bounds));
            }
        }
Exemplo n.º 3
0
        private void DrawDeepSpaceObjects(SpriteBatch spriteBatch)
        {
            foreach (GameObjectOverworld obj in deepSpaceGameObjects)
            {
                obj.Draw(spriteBatch);
            }

            for (int i = 0; i < deepSpaceGameObjects.Count; i++)
            {
                if (CollisionDetection.IsRectInRect(Game.player.Bounds, deepSpaceGameObjects[i].Bounds))
                {
                    if (!burnOutEnding.Activated)
                    {
                        if (deepSpaceGameObjects[i].Class == "Planet")
                        {
                            CollisionHandlingOverWorld.DrawRectAroundObject(Game, spriteBatch, deepSpaceGameObjects[i].Bounds);
                            Game.helper.DisplayText("Press 'Enter' to enter planetary orbit.");
                        }

                        else if (deepSpaceGameObjects[i].Class == "Station")
                        {
                            CollisionHandlingOverWorld.DrawRectAroundObject(Game, spriteBatch, deepSpaceGameObjects[i].Bounds);
                            Game.helper.DisplayText("Press 'Enter' to dock with station.");
                        }
                    }
                }

                foreach (GameObjectOverworld obj in effectsObjects)
                {
                    obj.Draw(spriteBatch);
                }
            }
        }
Exemplo n.º 4
0
        // Collision-Detection for entering stations and planets located in deepspaceobjects
        private void EnterCheck()
        {
            for (int i = 0; i < deepSpaceGameObjects.Count; i++)
            {
                if (CollisionDetection.IsRectInRect(Game.player.Bounds, deepSpaceGameObjects[i].Bounds))
                {
                    if (deepSpaceGameObjects[i] is Planet)
                    {
                        Game.stateManager.planetState.LoadPlanetData((Planet)deepSpaceGameObjects[i]);
                        Game.stateManager.ChangeState("PlanetState");
                    }

                    else if (deepSpaceGameObjects[i] is Station)
                    {
                        Game.stateManager.stationState.LoadStationData((Station)deepSpaceGameObjects[i]);
                        Game.stateManager.ChangeState("StationState");
                    }

                    else if (deepSpaceGameObjects[i] is OverworldShip)
                    {
                        ((OverworldShip)deepSpaceGameObjects[i]).Interact();
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void UpdateDeepSpaceObjects(GameTime gameTime)
        {
            foreach (GameObjectOverworld obj in deepSpaceGameObjects)
            {
                obj.Update(gameTime);

                if (!Game.player.HyperspeedOn && OverworldShip.FollowPlayer && !Game.player.IsInvincible)
                {
                    if (obj is OverworldShip && ((OverworldShip)obj).collisionEvent != null)
                    {
                        if (CollisionDetection.IsRectInRect(obj.Bounds, ((OverworldShip)obj).collisionEvent.target.Bounds))
                        {
                            ((OverworldShip)obj).collisionEvent.Invoke();
                        }
                    }
                }
            }

            if (PlanetState.PreviousPlanet != "" ||
                StationState.PreviousStation != "")
            {
                foreach (GameObjectOverworld obj in deepSpaceGameObjects)
                {
                    if (obj is Planet)
                    {
                        Planet planet = (Planet)obj;

                        if (obj.name == PlanetState.PreviousPlanet)
                        {
                            Game.player.position       = planet.position;
                            Game.player.speed          = 0;
                            PlanetState.PreviousPlanet = "";
                            break;
                        }
                    }

                    else if (obj is Station)
                    {
                        Station station = (Station)obj;

                        if (station.name == StationState.PreviousStation)
                        {
                            Game.player.position         = station.position;
                            Game.player.speed            = 0;
                            StationState.PreviousStation = "";
                            break;
                        }
                    }
                }
            }

            foreach (GameObjectOverworld obj in effectsObjects)
            {
                obj.Update(gameTime);
                if (obj.IsDead)
                {
                    RemoveEffectsObject(obj);
                }
            }
        }
Exemplo n.º 6
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            if ((ObjectiveIndex == 2) &&
                CollisionDetection.IsRectInRect(Game.player.Bounds, allyShipRectangle))
            {
                CollisionHandlingOverWorld.DrawRectAroundObject(Game, spriteBatch, allyShipRectangle);
                Game.helper.DisplayText("Press 'Enter' to speak with the Rebel fleet");
            }
        }
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);

            if (!started 
                && GameStateManager.currentState.Equals("OverworldState") 
                && CollisionDetection.IsRectInRect(game.player.Bounds, escortDataCapsule.ShipToDefend.Bounds))
            {
                CollisionHandlingOverWorld.DrawRectAroundObject(game, spriteBatch, escortDataCapsule.ShipToDefend.Bounds);
                game.helper.DisplayText("Press 'Enter' to talk to freighter captain..");
            }
        }
Exemplo n.º 8
0
 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;
     }
 }
Exemplo n.º 9
0
        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.");
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        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 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));
            }
        }
        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]));
        }
Exemplo n.º 14
0
        protected override void SetupObjectives()
        {
            objectives.Clear();

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

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

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

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

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

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

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

            objectives.Add(autoPilotObjective);

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

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

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

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

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

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

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

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

            objectives.Add(new ArriveAtLocationObjective(Game, this, ObjectiveDescriptions[1]));
        }
        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]));
        }
Exemplo n.º 16
0
        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();
            }
        }
Exemplo n.º 17
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();
        }
Exemplo n.º 18
0
        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;
                }
            }
        }