Exemple #1
0
        //returns the next entry after a specific entry
        public RouteTimeTableEntry getNextEntry(RouteTimeTableEntry entry)
        {
            DayOfWeek eDay = entry.Day;

            int counter = 0;

            while (counter < 7)
            {
                List <RouteTimeTableEntry> entries = getEntries(eDay);

                foreach (RouteTimeTableEntry dEntry in (from e in entries orderby e.Time select e))
                {
                    if (!((dEntry.Day == entry.Day && dEntry.Time <= entry.Time)))// && dEntry.Destination != entry.Destination)
                    {
                        return(dEntry);
                    }
                }
                counter++;

                eDay++;

                if (eDay == (DayOfWeek)7)
                {
                    eDay = (DayOfWeek)0;
                }
            }

            return(entry);
        }
Exemple #2
0
        //returns the next entry after a specific date and with a specific airliner
        public RouteTimeTableEntry getNextEntry(DateTime time, FleetAirliner airliner)
        {
            DateTime dt = new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second);

            int counter = 0;

            while (counter < 8)
            {
                List <RouteTimeTableEntry> entries = getEntries(dt.DayOfWeek).FindAll(e => airliner == e.Airliner);

                foreach (RouteTimeTableEntry dEntry in (from e in entries orderby e.Time select e))
                {
                    if (!(dEntry.Time <= dt.TimeOfDay && dt.Day == time.Day))
                    {
                        return(dEntry);
                    }
                }
                dt = dt.AddDays(1);

                counter++;
            }

            RouteTimeTableEntry entry = this.Entries.Find(e => e.Airliner == airliner);

            return(entry);
        }
Exemple #3
0
        public Flight(RouteTimeTableEntry entry)
        {
            this.Entry = entry;

            if (this.Entry.TimeTable.Route.Type == Route.RouteType.Passenger || this.Entry.TimeTable.Route.Type == Route.RouteType.Mixed)
            {
                this.Classes = new List <FlightAirlinerClass>();

                if (this.Entry != null)
                {
                    this.Airliner            = this.Entry.Airliner;
                    this.FlightTime          = MathHelpers.ConvertEntryToDate(this.Entry);
                    this.ScheduledFlightTime = this.FlightTime;
                }

                this.IsOnTime = true;
            }
            if (this.Entry.TimeTable.Route.Type == Route.RouteType.Cargo || this.Entry.TimeTable.Route.Type == Route.RouteType.Mixed)
            {
                if (this.Entry != null)
                {
                    this.Airliner            = this.Entry.Airliner;
                    this.FlightTime          = MathHelpers.ConvertEntryToDate(this.Entry);
                    this.ScheduledFlightTime = this.FlightTime;
                }

                this.IsOnTime = true;
            }

            this.DistanceToDestination = MathHelpers.GetDistance(this.Entry.Destination.Airport.Profile.Coordinates, this.Entry.DepartureAirport.Profile.Coordinates);
        }
Exemple #4
0
        //adds entries for a specific destination and time for each day of the week assigned to an airliner
        public void addDailyEntries(RouteEntryDestination destination, TimeSpan time, FleetAirliner airliner)
        {
            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
            {
                RouteTimeTableEntry entry = new RouteTimeTableEntry(this, day, time, destination);
                entry.Airliner = airliner;

                this.Entries.Add(entry);
            }
        }
Exemple #5
0
        //adds entries for a specific destination and for each weekday of the week assinged to an airliner
        public void addWeekDailyEntries(RouteEntryDestination destination, TimeSpan time)
        {
            foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
            {
                if (day != DayOfWeek.Saturday && day != DayOfWeek.Sunday)
                {
                    RouteTimeTableEntry entry = new RouteTimeTableEntry(this, day, time, destination);
                    entry.Airliner = null;

                    this.Entries.Add(entry);
                }
            }
        }
Exemple #6
0
        //sets the next entry
        public void setNextEntry()
        {
            RouteTimeTableEntry entry = null;

            if (isPassengerFlight())
            {
                entry = this.AllClasses.Keys.ElementAt(CurrentFlight);
            }

            if (isCargoFlight())
            {
                entry = this.AllCargo.Keys.ElementAt(CurrentFlight);
            }

            this.Entry = entry;

            if (entry.TimeTable.Route.Type == Route.RouteType.Mixed || entry.TimeTable.Route.Type == Route.RouteType.Passenger)
            {
                this.Classes = this.AllClasses[entry];
            }

            if (entry.TimeTable.Route.Type == Route.RouteType.Mixed || entry.TimeTable.Route.Type == Route.RouteType.Cargo)
            {
                this.Cargo = this.AllCargo[entry];
            }

            this.Airliner = this.Entry.Airliner;

            if (CurrentFlight == 0)
            {
                this.FlightTime = MathHelpers.ConvertEntryToDate(this.Entry, 0);
            }
            else
            {
                this.FlightTime = GameObject.GetInstance().GameTime.Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(this.Airliner));
            }

            this.IsOnTime = true;

            this.DistanceToDestination = MathHelpers.GetDistance(entry.Destination.Airport.Profile.Coordinates.convertToGeoCoordinate(), entry.DepartureAirport.Profile.Coordinates.convertToGeoCoordinate());

            CurrentFlight++;
        }
Exemple #7
0
        public StopoverFlight(RouteTimeTableEntry entry)
            : base(entry)
        {
            this.CurrentFlight = 0;
            this.AllClasses    = new Dictionary <RouteTimeTableEntry, List <FlightAirlinerClass> >();
            this.AllCargo      = new Dictionary <RouteTimeTableEntry, double>();

            List <Route> legs = entry.TimeTable.Route.Stopovers.SelectMany(s => s.Legs).ToList();

            Boolean isInbound = entry.DepartureAirport == entry.TimeTable.Route.Destination2;

            if (isInbound)
            {
                legs.Reverse();
            }

            createEntries(entry);

            /*
             * foreach (Route route in legs)
             * {
             *  List<FlightAirlinerClass> classes = new List<FlightAirlinerClass>();
             *  foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
             *  {
             *      FlightAirlinerClass faClass;
             *       if (isInbound)
             *           faClass = new FlightAirlinerClass(route.getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner,aClass.Type,route.Destination2,route.Destination1));
             *       else
             *           faClass = new FlightAirlinerClass(route.getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner,aClass.Type,route.Destination1,route.Destination2));
             *
             *       classes.Add(faClass);
             *  }
             *  this.AllClasses.Add(route, classes);
             * }
             * */
        }
Exemple #8
0
        //creates the entries for the stopoverflight
        private void createEntries(RouteTimeTableEntry mainEntry)
        {
            List <Route> routes = mainEntry.TimeTable.Route.Stopovers.SelectMany(s => s.Legs).ToList();

            TimeSpan time = mainEntry.Time;

            Boolean isInbound = mainEntry.DepartureAirport == mainEntry.TimeTable.Route.Destination2;

            if (isInbound)
            {
                routes.Reverse();
            }

            foreach (Route route in routes)
            {
                RouteTimeTable timetable = new RouteTimeTable(route);

                RouteTimeTableEntry entry;
                //inbound
                if (isInbound)
                {
                    entry = new RouteTimeTableEntry(timetable, mainEntry.Day, time, new RouteEntryDestination(route.Destination1, mainEntry.Destination.FlightCode));

                    time            = time.Add(entry.TimeTable.Route.getFlightTime(mainEntry.Airliner.Airliner.Type)).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(mainEntry.Airliner));
                    entry.Airliner  = mainEntry.Airliner;
                    entry.MainEntry = mainEntry;
                }
                //outbound
                else
                {
                    entry           = new RouteTimeTableEntry(timetable, mainEntry.Day, time, new RouteEntryDestination(route.Destination2, mainEntry.Destination.FlightCode));
                    entry.Airliner  = mainEntry.Airliner;
                    entry.MainEntry = mainEntry;

                    time = time.Add(entry.TimeTable.Route.getFlightTime(mainEntry.Airliner.Airliner.Type)).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(mainEntry.Airliner));
                }

                if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed)
                {
                    List <FlightAirlinerClass> classes = new List <FlightAirlinerClass>();
                    foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
                    {
                        FlightAirlinerClass faClass;
                        if (isInbound)
                        {
                            faClass = new FlightAirlinerClass(((PassengerRoute)route).getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner, aClass.Type, route.Destination2, route.Destination1, routes, isInbound));
                        }
                        else
                        {
                            faClass = new FlightAirlinerClass(((PassengerRoute)route).getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner, aClass.Type, route.Destination1, route.Destination2, routes, isInbound));
                        }

                        classes.Add(faClass);
                    }

                    this.AllClasses.Add(entry, classes);
                }
                if (route.Type == Route.RouteType.Cargo || route.Type == Route.RouteType.Mixed)
                {
                    if (isInbound)
                    {
                        this.AllCargo.Add(entry, PassengerHelpers.GetStopoverFlightCargo(this.Airliner, route.Destination2, route.Destination1, routes, isInbound));
                    }
                    else
                    {
                        this.AllCargo.Add(entry, PassengerHelpers.GetStopoverFlightCargo(this.Airliner, route.Destination1, route.Destination2, routes, isInbound));
                    }
                }
            }
        }
Exemple #9
0
 //removes an entry from the time table
 public void removeEntry(RouteTimeTableEntry entry)
 {
     this.Entries.Remove(entry);
 }
Exemple #10
0
 //adds an entry to the timetable
 public void addEntry(RouteTimeTableEntry entry)
 {
     this.Entries.Add(entry);
 }