Inheritance: BaseModel
        public PageShowRoute(Route route)
        {
            Classes = new ObservableCollection<MVVMRouteClass>();

            Route = new HumanRouteMVVM(route);
            DataContext = Route;

            if (Route.Route.Type == Models.Routes.Route.RouteType.Helicopter)
            {

                 RouteAirlinerClass rClass = ((PassengerRoute)Route.Route).GetRouteAirlinerClass(AirlinerClass.ClassType.EconomyClass);
                 var mClass = new MVVMRouteClass(AirlinerClass.ClassType.EconomyClass, rClass.Seating, rClass.FarePrice);

                 Classes.Add(mClass);

            }
            if (Route.Route.Type == Models.Routes.Route.RouteType.Passenger || Route.Route.Type == Models.Routes.Route.RouteType.Mixed)
            {
                 foreach (AirlinerClass.ClassType cType in AirlinerClass.GetAirlinerTypes())
                {
                    if ((int)cType <= GameObject.GetInstance().GameTime.Year)
                    {
                          RouteAirlinerClass rClass = ((PassengerRoute)Route.Route).GetRouteAirlinerClass(cType);
                          var mClass = new MVVMRouteClass(cType, rClass.Seating, rClass.FarePrice);

                          Classes.Add(mClass);
                    }
                }
            }

            InitializeComponent();

            Loaded += PageShowRoute_Loaded;
        }
Ejemplo n.º 2
0
        /*returns the inflight demand score for the route*/
        public static double GetRouteInflightScore(Route route)
        {
            TimeSpan flightTime = MathHelpers.GetFlightTime(route.Destination1, route.Destination2, route.GetAirliners()[0].Airliner.Type);

            AirlinerFacility inflight = route.GetAirliners()[0].Airliner.GetAirlinerClass(AirlinerClass.ClassType.EconomyClass).GetFacility(AirlinerFacility.FacilityType.Video);

            IOrderedEnumerable<AirlinerFacility> videofacilities =
                AirlinerFacilities.GetFacilities(AirlinerFacility.FacilityType.Video).Where(f => f.FromYear >= GameObject.GetInstance().GameTime.Year).OrderBy(f => f.ServiceLevel);

            int facilitynumber = videofacilities.Count() - videofacilities.ToList().IndexOf(inflight) - 1;

            double inflightlevel;

            if (flightTime.Hours < 1)
            {
                inflightlevel = 9 - facilitynumber;
            }
            else if (flightTime.Hours >= 1 && flightTime.Hours < 3)
            {
                inflightlevel = 8 - facilitynumber;
            }
            else if (flightTime.Hours >= 3 && flightTime.Hours < 7)
            {
                inflightlevel = 7 - facilitynumber;
            }
            else
            {
                inflightlevel = 10 - (2*facilitynumber);
            }

            return Math.Min(10, inflightlevel);
        }
Ejemplo n.º 3
0
        /*returns the luggage score for the route*/
        public static double GetRouteLuggageScore(Route route)
        {
            double bagFee = GameObject.GetInstance().HumanAirline.Fees.GetValue(FeeTypes.GetType("1 Bag"));

            if (bagFee.Equals(0))
                return 8;
            return 3;
        }
Ejemplo n.º 4
0
        /*returns the plane age score for the route*/
        public static double GetPlaneAgeScore(Route route)
        {
            FleetAirliner airliner = route.GetAirliners()[0];

            int age = airliner.Airliner.Age;

            double score = 10 - (age/2);

            return Math.Max(1, score);
        }
        public SubsidiaryAirline(
            Airline airline,
            AirlineProfile profile,
            AirlineMentality mentality,
            AirlineFocus market,
            AirlineLicense license,
            Route.RouteType routefocus)
            : base(profile, mentality, market, license, routefocus)
        {
            Airline = airline;

            foreach (AirlineLogo logo in Airline.Profile.Logos)
            {
                Profile.AddLogo(logo);
            }
        }
 public FutureSubsidiaryAirline(
     string name,
     string iata,
     Airport airport,
     Airline.AirlineMentality mentality,
     AirlineFocus market,
     Route.RouteType airlineRouteFocus,
     string logo)
 {
     Name = name;
     IATA = iata;
     PreferedAirport = airport;
     Mentality = mentality;
     Market = market;
     Logo = logo;
     AirlineRouteFocus = airlineRouteFocus;
 }
Ejemplo n.º 7
0
        public Airline(
            AirlineProfile profile,
            AirlineMentality mentality,
            AirlineFocus marketFocus,
            AirlineLicense license,
            Route.RouteType routeFocus)
        {
            Scores = new AirlineScores();
            Shares = new List<AirlineShare>();
            Airports = new List<Airport>();
            Fleet = new List<FleetAirliner>();
            Routes = new List<Route>();
            FutureAirlines = new List<FutureSubsidiaryAirline>();
            Subsidiaries = new List<SubsidiaryAirline>();
            Advertisements = new Dictionary<AdvertisementType.AirlineAdvertisementType, AdvertisementType>();
            Codeshares = new List<CodeshareAgreement>();
            Statistics = new GeneralStatistics();
            Facilities = new List<AirlineFacility>();
            Invoices = new Invoices();
            Budget = new AirlineBudget();
            BudgetHistory = new Dictionary<DateTime, AirlineBudget>();
            TestBudget = new Dictionary<DateTime, AirlineBudget>();
            Profile = profile;
            AirlineRouteFocus = routeFocus;
            Loans = new List<Loan>();
            Reputation = 50;
            Alliances = new List<Alliance>();
            Mentality = mentality;
            MarketFocus = marketFocus;
            License = license;
            Policies = new List<AirlinePolicy>();
            EventLog = new List<RandomEvent>();
            Ratings = new AirlineRatings();
            OverallScore = CountedScores = 0;
            GameScores = new Dictionary<DateTime, int>();
            InsuranceClaims = new List<InsuranceClaim>();
            InsurancePolicies = new List<AirlineInsurance>();
            SpecialContracts = new List<SpecialContract>();

            CreateStandardAdvertisement();

            Pilots = new List<Pilot>();
            FlightSchools = new List<FlightSchool>();
            Budget = new AirlineBudget();
        }
Ejemplo n.º 8
0
        /*returns the meal score for the route*/
        public static double GetRouteMealScore(Route route)
        {
            TimeSpan flightTime = MathHelpers.GetFlightTime(route.Destination1, route.Destination2, route.GetAirliners()[0].Airliner.Type);

            RouteFacility food = ((PassengerRoute) route).GetRouteAirlinerClass(AirlinerClass.ClassType.EconomyClass).GetFacility(RouteFacility.FacilityType.Food);

            double foodlevel;

            if (flightTime.Hours < 1)
            {
                if (food.ServiceLevel < 0)
                    foodlevel = 5;
                else
                    foodlevel = 5 + (food.ServiceLevel/10);
            }
            else if (flightTime.Hours >= 1 && flightTime.Hours < 3)
            {
                if (food.ServiceLevel < 0)
                    foodlevel = 4;
                else
                    foodlevel = 4 + (food.ServiceLevel/10);
            }
            else if (flightTime.Hours >= 3 && flightTime.Hours < 7)
            {
                if (food.ServiceLevel < 0)
                    foodlevel = 2;
                else
                    foodlevel = 3 + (food.ServiceLevel/10);
            }
            else
            {
                if (food.ServiceLevel < 0)
                    foodlevel = 1;
                else
                    foodlevel = 2 + (food.ServiceLevel/10);
            }

            return Math.Min(10, foodlevel);
        }
        public RoutePlannerItemMVVM(Route route, AirlinerType type)
        {
            Route = route;

            var g2 = new Guid(Route.Id);

            byte[] bytes = g2.ToByteArray();

            byte red = bytes[0];
            byte green = bytes[1];
            byte blue = bytes[2];

            var brush = new SolidColorBrush(Color.FromRgb(red, green, blue));
            brush.Opacity = 0.4;

            Brush = brush;
            FlightTime = MathHelpers.GetFlightTime(Route.Destination1, Route.Destination2, type);

            Airliners = Route.GetAirliners().Count;
        }
        //creates the stop over route based on the main route
        public static StopoverRoute CreateStopoverRoute(Airport dest1, Airport stopover, Airport dest2, Route mainroute, bool oneLegged, Route.RouteType type)
        {
            var stopoverRoute = new StopoverRoute(stopover);

            Guid id = Guid.NewGuid();

            if (!oneLegged)
            {
                if (mainroute.Type == Route.RouteType.Passenger || mainroute.Type == Route.RouteType.Mixed)
                {
                    var routeLegTwo = new PassengerRoute(id.ToString(), dest1, stopover, GameObject.GetInstance().GameTime, 0);

                    foreach (RouteAirlinerClass aClass in ((PassengerRoute) mainroute).Classes)
                    {
                        //routeLegTwo.getRouteAirlinerClass(aClass.Type).FarePrice = aClass.FarePrice;
                        routeLegTwo.GetRouteAirlinerClass(aClass.Type).FarePrice = PassengerHelpers.GetPassengerPrice(dest1, stopover)*GeneralHelpers.ClassToPriceFactor(aClass.Type);

                        foreach (RouteFacility facility in aClass.GetFacilities())
                            routeLegTwo.GetRouteAirlinerClass(aClass.Type).AddFacility(facility);

                        routeLegTwo.GetRouteAirlinerClass(aClass.Type).Seating = aClass.Seating;
                    }


                    stopoverRoute.AddLeg(routeLegTwo);
                }
                if (mainroute.Type == Route.RouteType.Cargo || mainroute.Type == Route.RouteType.Mixed)
                {
                    var routeLegTwo = new CargoRoute(id.ToString(), dest1, stopover, GameObject.GetInstance().GameTime, ((CargoRoute) mainroute).PricePerUnit);

                    stopoverRoute.AddLeg(routeLegTwo);
                }
            }

            if (mainroute.Type == Route.RouteType.Mixed || mainroute.Type == Route.RouteType.Passenger)
            {
                id = Guid.NewGuid();

                var routeLegOne = new PassengerRoute(id.ToString(), stopover, dest2, GameObject.GetInstance().GameTime, 0);

                foreach (RouteAirlinerClass aClass in ((PassengerRoute) mainroute).Classes)
                {
                    //routeLegOne.getRouteAirlinerClass(aClass.Type).FarePrice = aClass.FarePrice;

                    routeLegOne.GetRouteAirlinerClass(aClass.Type).FarePrice = PassengerHelpers.GetPassengerPrice(stopover, dest2)*GeneralHelpers.ClassToPriceFactor(aClass.Type);


                    foreach (RouteFacility facility in aClass.GetFacilities())
                        routeLegOne.GetRouteAirlinerClass(aClass.Type).AddFacility(facility);

                    routeLegOne.GetRouteAirlinerClass(aClass.Type).Seating = aClass.Seating;
                }

                stopoverRoute.AddLeg(routeLegOne);
            }
            if (mainroute.Type == Route.RouteType.Cargo || mainroute.Type == Route.RouteType.Mixed)
            {
                var routeLegOne = new CargoRoute(id.ToString(), stopover, dest2, GameObject.GetInstance().GameTime, ((CargoRoute) mainroute).PricePerUnit);

                stopoverRoute.AddLeg(routeLegOne);
            }


            return stopoverRoute;
        }
Ejemplo n.º 11
0
 //removes a pilot from the airliner
 //adds a route to the airliner
 public void AddRoute(Route route)
 {
     Routes.Add(route);
 }
Ejemplo n.º 12
0
        public void RemoveRoute(Route route)
        {
            lock (_Routes)
            {
                _Routes.Remove(route);

                /*
                foreach (string flightCode in route.TimeTable.Entries.Select(e => e.Destination.FlightCode).Distinct())
                    this.FlightCodes.Add(flightCode);*/
            }
        }
        //loads a route
        private static Route LoadRoute(
            XmlElement routeNode,
            Airline airline,
            Route.RouteType routetype = Route.RouteType.Passenger)
        {
            string id = routeNode.Attributes["id"].Value;
            Airport dest1 = Airports.GetAirport(routeNode.Attributes["destination1"].Value);
            Airport dest2 = Airports.GetAirport(routeNode.Attributes["destination2"].Value);
            Boolean isBanned = Convert.ToBoolean(routeNode.Attributes["isbanned"].Value);

            if (routeNode.HasAttribute("type"))
            {
                routetype = (Route.RouteType) Enum.Parse(typeof (Route.RouteType), routeNode.Attributes["type"].Value);
            }

            Route route;

            if (routetype == Route.RouteType.Passenger || routetype == Route.RouteType.Mixed)
            {
                route = new PassengerRoute(id, dest1, dest2, DateTime.Now, 0);
            }
            else
            {
                route = new CargoRoute(id, dest1, dest2, DateTime.Now, 0);
            }

            route.Banned = isBanned;

            /* foreach (StopoverRoute stopover in route.Stopovers)
            {
                XmlElement routeStopoverNode = xmlDoc.CreateElement("stopover");
                routeStopoverNode.SetAttribute("airport", stopover.Stopover.Profile.ID);

                XmlElement stopoverLegsNode = xmlDoc.CreateElement("legs");
                foreach (Route leg in stopover.Legs)
                {
                    XmlElement stopoverLegNode = xmlDoc.CreateElement("leg");

                    stopoverLegNode.AppendChild(SaveRoute(xmlDoc, leg));

                    stopoverLegsNode.AppendChild(stopoverLegNode);
                }
                routeStopoverNode.AppendChild(stopoverLegsNode);
                routeStopoversNode.AppendChild(routeStopoverNode);*/

            XmlNodeList routeStopoverList = routeNode.SelectNodes("stopovers/stopover");

            if (routeStopoverList != null)
                foreach (XmlElement routeStopoverNode in routeStopoverList)
                {
                    Airport stopoverAirport = Airports.GetAirportFromID(routeStopoverNode.Attributes["airport"].Value);

                    var stopoverRoute = new StopoverRoute(stopoverAirport);

                    XmlNodeList legsList = routeStopoverNode.SelectNodes("legs/leg");

                    if (legsList != null)
                        foreach (XmlElement legNode in legsList)
                        {
                            stopoverRoute.AddLeg(LoadRoute((XmlElement) legNode.SelectSingleNode("route"), airline, routetype));
                        }

                    route.AddStopover(stopoverRoute);
                }

            if (routetype == Route.RouteType.Passenger || routetype == Route.RouteType.Mixed)
            {
                ((PassengerRoute) route).Classes.Clear();

                XmlNodeList routeClassList = routeNode.SelectNodes("routeclasses/routeclass");

                if (routeClassList != null)
                    foreach (XmlElement routeClassNode in routeClassList)
                    {
                        var airlinerClassType =
                            (AirlinerClass.ClassType)
                            Enum.Parse(typeof (AirlinerClass.ClassType), routeClassNode.Attributes["type"].Value);
                        double fareprice = Convert.ToDouble(
                            routeClassNode.Attributes["fareprice"].Value,
                            new CultureInfo("de-DE", false));
                        var seatingType =
                            (RouteAirlinerClass.SeatingType)
                            Enum.Parse(
                                typeof (RouteAirlinerClass.SeatingType),
                                routeClassNode.Attributes["seating"].Value);

                        var rClass = new RouteAirlinerClass(
                            airlinerClassType,
                            RouteAirlinerClass.SeatingType.ReservedSeating,
                            fareprice) {Seating = seatingType};

                        foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof (RouteFacility.FacilityType)))
                        {
                            if (routeClassNode.HasAttribute(ftype.ToString()))
                            {
                                RouteFacility facility =
                                    RouteFacilities.GetFacility(routeClassNode.Attributes[ftype.ToString()].Value);
                                rClass.AddFacility(facility);
                            }
                        }

                        ((PassengerRoute) route).AddRouteAirlinerClass(rClass);
                    }
            }
            if (routetype == Route.RouteType.Mixed || routetype == Route.RouteType.Cargo)
            {
                var routeCargoNode = (XmlElement) routeNode.SelectSingleNode("cargo");
                if (routeCargoNode != null)
                {
                    double unitPrice = Convert.ToDouble(
                        routeCargoNode.Attributes["priceperunit"].Value,
                        new CultureInfo("de-DE", false));

                    ((CargoRoute) route).PricePerUnit = unitPrice;
                }
            }

            var timeTable = new RouteTimeTable(route);

            XmlNodeList timetableList = routeNode.SelectNodes("timetable/timetableentry");

            if (timetableList != null)
                foreach (XmlElement entryNode in timetableList)
                {
                    Airport entryDest = Airports.GetAirport(entryNode.Attributes["destination"].Value);
                    string flightCode = entryNode.Attributes["flightcode"].Value;
                    var day = (DayOfWeek) Enum.Parse(typeof (DayOfWeek), entryNode.Attributes["day"].Value);
                    TimeSpan time = TimeSpan.Parse(entryNode.Attributes["time"].Value);
                    FleetAirliner airliner = entryNode.Attributes["airliner"].Value == "-"
                                                 ? null
                                                 : airline.Fleet.Find(a => a.Airliner.ID == entryNode.Attributes["airliner"].Value);

                    var entry = new RouteTimeTableEntry(
                        timeTable,
                        day,
                        time,
                        new RouteEntryDestination(entryDest, flightCode, null),
                        null);

                    if (entryNode.HasAttribute("id"))
                    {
                        entry.ID = entryNode.Attributes["id"].Value;
                    }

                    if (entryNode.HasAttribute("mainentry"))
                    {
                        entry.MainEntry =
                            airline.Routes.SelectMany(r => r.TimeTable.Entries)
                                   .ToList()
                                   .Find(e => e.ID == entryNode.Attributes["mainentry"].Value);
                    }

                    entry.Airliner = airliner;

                    if (airliner != null && !airliner.Routes.Contains(route))
                    {
                        airliner.Routes.Add(route);
                    }

                    timeTable.AddEntry(entry);
                }
            route.TimeTable = timeTable;

            XmlNodeList routeInvoiceList = routeNode.SelectNodes("invoices/invoice");

            if (routeInvoiceList != null)
                foreach (XmlElement routeInvoiceNode in routeInvoiceList)
                {
                    var type =
                        (Invoice.InvoiceType)
                        Enum.Parse(typeof (Invoice.InvoiceType), routeInvoiceNode.Attributes["type"].Value);
                    int invoiceYear = Convert.ToInt16(routeInvoiceNode.Attributes["year"].Value);
                    int invoiceMonth = Convert.ToInt16(routeInvoiceNode.Attributes["month"].Value);
                    double invoiceAmount = Convert.ToDouble(
                        routeInvoiceNode.Attributes["amount"].Value,
                        new CultureInfo("de-DE", false));

                    route.SetRouteInvoice(type, invoiceYear, invoiceMonth, 1, invoiceAmount);
                }

            return route;
        }
Ejemplo n.º 14
0
        /*returns the wifi score for the route*/
        public static double GetRouteWifiScore(Route route)
        {
            RouteFacility wifi = ((PassengerRoute) route).GetRouteAirlinerClass(AirlinerClass.ClassType.EconomyClass).GetFacility(RouteFacility.FacilityType.WiFi);

            if (wifi.Name == "None")
                return 3;
            return wifi.Name == "Buyable" ? 6 : 9;
        }
Ejemplo n.º 15
0
        /*returns the total score of the route*/
        public static double GetRouteTotalScore(Route route)
        {
            double score = GetPlaneAgeScore(route) + GetRouteInflightScore(route) + GetRouteMealScore(route) + GetRoutePlaneTypeScore(route) + GetRoutePriceScore(route) + GetRouteSeatsScore(route) +
                           GetRouteLuggageScore(route);

            if ((int) RouteFacility.FacilityType.WiFi <= GameObject.GetInstance().GameTime.Year)
            {
                double wifiScore = GetRouteWifiScore(route);
                score += wifiScore;

                return score/8;
            }

            return score/7;
        }
 public StartDataRoute(
     string destination1,
     string destination2,
     int opened,
     int closed,
     Route.RouteType routetype)
 {
     Opened = opened;
     Closed = closed;
     Destination1 = destination1;
     Destination2 = destination2;
     RouteType = routetype;
 }
 public StartDataRoutes(
     string origin,
     int destinations,
     GeneralHelpers.Size minimumsize,
     Route.RouteType routetype)
 {
     Countries = new List<Country>();
     Origin = origin;
     Destinations = destinations;
     MinimumSize = minimumsize;
     RouteType = routetype;
 }
Ejemplo n.º 18
0
        //creates a subsidiary airline for an airline
        public static SubsidiaryAirline CreateSubsidiaryAirline(Airline airline, double money, string name, string iata, Airline.AirlineMentality mentality, AirlineFocus market,
                                                                Route.RouteType routefocus, Airport homebase)
        {
            var profile = new AirlineProfile(name, iata, airline.Profile.Color, airline.Profile.CEO, true, GameObject.GetInstance().GameTime.Year, 2199) {Country = homebase.Profile.Country};

            var sAirline = new SubsidiaryAirline(airline, profile, mentality, market, airline.License, routefocus);

            AddSubsidiaryAirline(airline, sAirline, money, homebase);

            return sAirline;
        }
        //saves a route
        private static XmlElement SaveRoute(XmlDocument xmlDoc, Route route)
        {
            XmlElement routeNode = xmlDoc.CreateElement("route");
            routeNode.SetAttribute("id", route.Id);
            routeNode.SetAttribute("destination1", route.Destination1.Profile.IATACode);
            routeNode.SetAttribute("destination2", route.Destination2.Profile.IATACode);
            routeNode.SetAttribute("isbanned", route.Banned.ToString());
            routeNode.SetAttribute("type", route.Type.ToString());

            XmlElement routeStopoversNode = xmlDoc.CreateElement("stopovers");

            foreach (StopoverRoute stopover in route.Stopovers)
            {
                XmlElement routeStopoverNode = xmlDoc.CreateElement("stopover");
                routeStopoverNode.SetAttribute("airport", stopover.Stopover.Profile.ID);

                XmlElement stopoverLegsNode = xmlDoc.CreateElement("legs");
                foreach (Route leg in stopover.Legs)
                {
                    XmlElement stopoverLegNode = xmlDoc.CreateElement("leg");

                    stopoverLegNode.AppendChild(SaveRoute(xmlDoc, leg));

                    stopoverLegsNode.AppendChild(stopoverLegNode);
                }
                routeStopoverNode.AppendChild(stopoverLegsNode);
                routeStopoversNode.AppendChild(routeStopoverNode);
            }

            routeNode.AppendChild(routeStopoversNode);

            if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed)
            {
                XmlElement routeClassesNode = xmlDoc.CreateElement("routeclasses");

                foreach (RouteAirlinerClass aClass in ((PassengerRoute) route).Classes)
                {
                    XmlElement routeClassNode = xmlDoc.CreateElement("routeclass");
                    routeClassNode.SetAttribute("type", aClass.Type.ToString());
                    routeClassNode.SetAttribute("fareprice", aClass.FarePrice.ToString(new CultureInfo("de-DE", false)));

                    foreach (RouteFacility facility in aClass.GetFacilities())
                    {
                        routeClassNode.SetAttribute(facility.Type.ToString(), facility.Uid);
                    }
                    // chs, 2011-18-10 added for saving of type of seating
                    routeClassNode.SetAttribute("seating", aClass.Seating.ToString());

                    routeClassesNode.AppendChild(routeClassNode);
                }
                routeNode.AppendChild(routeClassesNode);
            }

            if (route.Type == Route.RouteType.Mixed || route.Type == Route.RouteType.Cargo)
            {
                XmlElement routeCargoNode = xmlDoc.CreateElement("cargo");
                routeCargoNode.SetAttribute(
                    "priceperunit",
                    ((CargoRoute) route).PricePerUnit.ToString(new CultureInfo("de-DE", false)));

                routeNode.AppendChild(routeCargoNode);
            }

            XmlElement timetableNode = xmlDoc.CreateElement("timetable");

            foreach (RouteTimeTableEntry entry in route.TimeTable.Entries)
            {
                XmlElement ttEntryNode = xmlDoc.CreateElement("timetableentry");
                ttEntryNode.SetAttribute("destination", entry.Destination.Airport.Profile.IATACode);
                ttEntryNode.SetAttribute("flightcode", entry.Destination.FlightCode);
                ttEntryNode.SetAttribute("day", entry.Day.ToString());
                ttEntryNode.SetAttribute("time", entry.Time.ToString());
                ttEntryNode.SetAttribute("airliner", entry.Airliner != null ? entry.Airliner.Airliner.ID : "-");
                ttEntryNode.SetAttribute("id", entry.ID);
                if (entry.MainEntry != null)
                {
                    ttEntryNode.SetAttribute("mainentry", entry.MainEntry.ID);
                }

                timetableNode.AppendChild(ttEntryNode);
            }

            routeNode.AppendChild(timetableNode);

            XmlElement routeInvoicesNode = xmlDoc.CreateElement("invoices");
            foreach (MonthlyInvoice invoice in route.GetInvoices().MonthlyInvoices)
            {
                XmlElement routeInvoiceNode = xmlDoc.CreateElement("invoice");
                routeInvoiceNode.SetAttribute("type", invoice.Type.ToString());
                routeInvoiceNode.SetAttribute("year", invoice.Year.ToString(CultureInfo.InvariantCulture));
                routeInvoiceNode.SetAttribute("month", invoice.Month.ToString(CultureInfo.InvariantCulture));
                routeInvoiceNode.SetAttribute("amount", invoice.Amount.ToString(new CultureInfo("de-DE", false)));

                routeInvoicesNode.AppendChild(routeInvoiceNode);
            }
            routeNode.AppendChild(routeInvoicesNode);

            return routeNode;
        }
Ejemplo n.º 20
0
        //returns if a route can be created
        public static bool IsRouteDestinationsOk(Airline airline, Airport destination1, Airport destination2, Route.RouteType routeType, Airport stopover1 = null, Airport stopover2 = null)
        {
            Terminal.TerminalType type = routeType == Route.RouteType.Cargo ? Terminal.TerminalType.Cargo : Terminal.TerminalType.Passenger;

            var distances = new List<double>();

            bool stopoverOk = (stopover1 == null || routeType == Route.RouteType.Cargo || AirportHelpers.HasFreeGates(stopover1, airline, type)) &&
                                 (stopover2 == null || routeType == Route.RouteType.Cargo || AirportHelpers.HasFreeGates(stopover2, airline, type));

            if ((AirportHelpers.HasFreeGates(destination1, airline, type) && AirportHelpers.HasFreeGates(destination2, airline, type) && stopoverOk) || routeType == Route.RouteType.Cargo)
            {
                var routeOkStatus = RouteOkStatus.Ok;

                if (stopover1 == null && stopover2 == null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, destination2));
                    routeOkStatus = GetRouteStatus(destination1, destination2, routeType);
                }

                if (stopover1 == null && stopover2 != null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, stopover2));
                    distances.Add(MathHelpers.GetDistance(stopover2, destination2));
                    routeOkStatus = GetRouteStatus(destination1, stopover2, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover2, destination2, routeType);
                }

                if (stopover1 != null && stopover2 == null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, stopover1));
                    distances.Add(MathHelpers.GetDistance(stopover1, destination2));
                    routeOkStatus = GetRouteStatus(destination1, stopover1, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover1, destination2, routeType);
                }

                if (stopover1 != null && stopover2 != null)
                {
                    distances.Add(MathHelpers.GetDistance(destination1, stopover1));
                    distances.Add(MathHelpers.GetDistance(stopover1, stopover2));
                    distances.Add(MathHelpers.GetDistance(stopover2, destination2));
                    routeOkStatus = GetRouteStatus(destination1, stopover1, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover1, stopover2, routeType);

                    if (routeOkStatus == RouteOkStatus.Ok)
                        routeOkStatus = GetRouteStatus(stopover2, destination2, routeType);
                }

                double maxDistance = distances.Max();
                double minDistance = distances.Min();

                IEnumerable<long> query = from a in AirlinerTypes.GetTypes(t => t.Produced.From < GameObject.GetInstance().GameTime)
                                          select a.Range;

                double maxFlightDistance = query.Max();

                if (minDistance <= Route.MinRouteDistance || maxDistance > maxFlightDistance)
                    routeOkStatus = RouteOkStatus.WrongDistance;

                if (routeOkStatus == RouteOkStatus.Ok)
                    return true;
                if (routeOkStatus == RouteOkStatus.AppropriateType)
                    throw new Exception("3002");
                if (routeOkStatus == RouteOkStatus.WrongDistance)
                    throw new Exception("3001");
                if (routeOkStatus == RouteOkStatus.MissingCargo)
                    throw new Exception("3003");
                if (routeOkStatus == RouteOkStatus.Restrictions)
                    throw new Exception("3005");
                if (routeOkStatus == RouteOkStatus.MissingLicense)
                    throw new Exception("3004");
                throw new Exception("3000");
            }
            throw new Exception("3000");
        }
Ejemplo n.º 21
0
        public void AddRoute(Route route)
        {
            var routes = new List<Route>(Routes);

            lock (_Routes)
            {
                _Routes.Add(route);
                route.Airline = this;
            }
            /*
                foreach (string flightCode in route.TimeTable.Entries.Select(e => e.Destination.FlightCode).Distinct())
                    this.FlightCodes.Remove(flightCode);

             */
        }
Ejemplo n.º 22
0
        //returns if two airports can have route between them and if the airline has license for the route
        private static bool CheckRouteOk(Airport airport1, Airport airport2, Route.RouteType routeType)
        {
            bool isCargoRouteOk = true;
            if (routeType == Route.RouteType.Cargo)
                isCargoRouteOk = AIHelpers.IsCargoRouteDestinationsCorrect(airport1, airport2, GameObject.GetInstance().HumanAirline);

            return isCargoRouteOk && HasAirlineLicens(GameObject.GetInstance().HumanAirline, airport1, airport2) && AIHelpers.IsRouteInCorrectArea(airport1, airport2) &&
                   !FlightRestrictions.HasRestriction(airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) &&
                   !FlightRestrictions.HasRestriction(airport2.Profile.Country, airport1.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) &&
                   !FlightRestrictions.HasRestriction(GameObject.GetInstance().HumanAirline, airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime);
        }
 public SpecialContractRoute(Airport destination1, Airport destination2, long passengers, Route.RouteType routetype, bool bothways)
 {
     Departure = destination1;
     Destination = destination2;
     BothWays = bothways;
     PassengersPerDay = passengers;
     RouteType = routetype;
 }
Ejemplo n.º 24
0
        private static RouteOkStatus GetRouteStatus(Airport airport1, Airport airport2, Route.RouteType routeType)
        {
            var status = RouteOkStatus.Ok;

            if (routeType == Route.RouteType.Cargo || routeType == Route.RouteType.Mixed)
                if (!AIHelpers.IsCargoRouteDestinationsCorrect(airport1, airport2, GameObject.GetInstance().HumanAirline))
                    status = RouteOkStatus.MissingCargo;

            if (status == RouteOkStatus.Ok)
            {
                if (HasAirlineLicens(GameObject.GetInstance().HumanAirline, airport1, airport2))
                {
                    if (AIHelpers.IsRouteInCorrectArea(airport1, airport2))
                    {
                        if (!FlightRestrictions.HasRestriction(airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) &&
                            !FlightRestrictions.HasRestriction(airport2.Profile.Country, airport1.Profile.Country, GameObject.GetInstance().GameTime, FlightRestriction.RestrictionType.Flights) &&
                            !FlightRestrictions.HasRestriction(GameObject.GetInstance().HumanAirline, airport1.Profile.Country, airport2.Profile.Country, GameObject.GetInstance().GameTime))
                            status = RouteOkStatus.Ok;
                        else
                            status = RouteOkStatus.Restrictions;
                    }
                    else
                        status = RouteOkStatus.AppropriateType;
                }
                else
                    status = RouteOkStatus.MissingLicense;
            }

            return status;
        }
Ejemplo n.º 25
0
 //removes a route from the airliner
 public void RemoveRoute(Route route)
 {
     Routes.Remove(route);
     route.TimeTable.Entries.RemoveAll(e => e.Airliner == this);
 }
Ejemplo n.º 26
0
        public static void ShowPopUp(Route route)
        {
            List<Route> routes = new List<Route>();
            routes.Add(route);

            ShowPopUp(routes);
        }
        public static void CreateStopoverRoute(Route route, Airport stopover1, Airport stopover2 = null)
        {
            if (stopover1 != null)
            {
                if (stopover2 != null)
                {
                    route.AddStopover(CreateStopoverRoute(route.Destination1, stopover1, stopover2, route, false, route.Type));
                    route.AddStopover(CreateStopoverRoute(stopover1, stopover2, route.Destination2, route, true, route.Type));
                }
                else
                    route.AddStopover(CreateStopoverRoute(route.Destination1, stopover1, route.Destination2, route, false, route.Type));
            }

            /*
            if (stopover1 != null)
            {
                if (stopover2 != null)
                    route.addStopover(FleetAirlinerHelpers.CreateStopoverRoute(route.Destination1, stopover1, stopover2, route, false, route.Type));
                else
                    route.addStopover(FleetAirlinerHelpers.CreateStopoverRoute(route.Destination1, stopover1, route.Destination2, route, false, route.Type));
            }

            if (stopover2 != null && stopover1!=null)
            {
               route.addStopover(FleetAirlinerHelpers.CreateStopoverRoute(stopover1, stopover2, route.Destination2, route, true, route.Type));
              
            }
             * */
        }
Ejemplo n.º 28
0
        //shows a route
        private void showRoute(Route route, Panel panelMap, int zoom, Point margin, Boolean isStopoverRoute=false, Airline airline = null)
        {
            if (route.HasStopovers)
            {
                foreach (Route leg in route.Stopovers.SelectMany(s => s.Legs))
                    showRoute(leg, panelMap, zoom, margin,true,route.Airline);
            }
            else
            {
                Point pos = UIHelpers.WorldToTilePos(route.Destination1.Profile.Coordinates.ConvertToGeoCoordinate(), zoom);

                Point p = new Point(pos.X * ImageSize - margin.X * ImageSize, pos.Y * ImageSize - margin.Y * ImageSize);

                if (p.X < panelMap.Width)
                    panelMap.Children.Add(createPin(p, route.Destination1));

                pos = UIHelpers.WorldToTilePos(route.Destination2.Profile.Coordinates.ConvertToGeoCoordinate(), zoom);

                p = new Point(pos.X * ImageSize - margin.X * ImageSize, pos.Y * ImageSize - margin.Y * ImageSize);

                if (p.X < panelMap.Width)
                    panelMap.Children.Add(createPin(p, route.Destination2));

                if (airline == null)
                    airline = route.Airline;

                createRouteLine(route.Destination1, route.Destination2, panelMap, zoom, margin, airline,isStopoverRoute);
            }
        }
 public RouteEntryVVM(Route route, DayOfWeek day, TimeSpan departure)
 {
     Route = route;
     Day = day;
     DepartureTime = departure;
 }
Ejemplo n.º 30
0
        public AirlineRouteMVVM(Route route)
        {
            Route = route;

            if (Route.Type == Route.RouteType.Passenger)
            {
                PriceIndex =
                    ((PassengerRoute)Route).GetRouteAirlinerClass(AirlinerClass.ClassType.EconomyClass).FarePrice;
            }
            else if (Route.Type == Route.RouteType.Cargo)
            {
                PriceIndex = ((CargoRoute)Route).PricePerUnit;
            }
            else if (Route.Type == Route.RouteType.Mixed)
            {
                PriceIndex =
                    ((CombiRoute)Route).GetRouteAirlinerClass(AirlinerClass.ClassType.EconomyClass).FarePrice
                    + ((CombiRoute)Route).PricePerUnit;
            }
            else if (Route.Type == Route.RouteType.Helicopter)
            {
                PriceIndex =
                ((HelicopterRoute)Route).GetRouteAirlinerClass(AirlinerClass.ClassType.EconomyClass).FarePrice;

            }
        }