Пример #1
0
        //downgrades the facility for a specific type for an airline
        public void downgradeFacility(Airline airline, AirportFacility.FacilityType type)
        {
            AirportFacility        currentFacility = getAirportFacility(airline, type);
            AirlineAirportFacility aaf             = getAirlineAirportFacility(airline, type);

            List <AirportFacility> facilities = AirportFacilities.GetFacilities(type);

            facilities.Sort((delegate(AirportFacility f1, AirportFacility f2) { return(f1.TypeLevel.CompareTo(f2.TypeLevel)); }));

            int index = facilities.IndexOf(getAirportFacility(airline, type));

            addAirportFacility(airline, facilities[index - 1], GameObject.GetInstance().GameTime);

            this.Facilities.Remove(aaf);
        }
Пример #2
0
        //returns the airport facility for a specific type for an airline
        public AirlineAirportFacility getAirlineAirportFacility(Airline airline, AirportFacility.FacilityType type)
        {
            List <AirlineAirportFacility> facilities = new List <AirlineAirportFacility>();

            lock (this.Facilities)
            {
                facilities = (from f in this.Facilities where f.Airline == airline && f.Facility.Type == type && GameObject.GetInstance().GameTime >= f.FinishedDate orderby f.FinishedDate descending select f).ToList();

                if (facilities.Count() == 0)
                {
                    AirportFacility noneFacility = AirportFacilities.GetFacilities(type).Find(f => f.TypeLevel == 0);
                    this.addAirportFacility(airline, noneFacility, GameObject.GetInstance().GameTime);

                    facilities.Add(getAirlineAirportFacility(airline, type));
                }
            }
            return(facilities.FirstOrDefault());
        }
Пример #3
0
        //returns the current airport facility of a specific type for an airlines
        public AirportFacility getCurrentAirportFacility(Airline airline, AirportFacility.FacilityType type)
        {
            List <AirportFacility> facilities = new List <AirportFacility>();

            var tFacilities = new List <AirlineAirportFacility>(this.Facilities);

            lock (this.Facilities)
            {
                facilities = (from f in tFacilities where f.Airline == airline && f.Facility.Type == type && f.FinishedDate <= GameObject.GetInstance().GameTime orderby f.FinishedDate descending select f.Facility).ToList();
                int numberOfFacilities = facilities.Count();

                if (numberOfFacilities == 0 && airline != null)
                {
                    var noneFacility = AirportFacilities.GetFacilities(type).Find(f => f.TypeLevel == 0);
                    this.addAirportFacility(airline, noneFacility, GameObject.GetInstance().GameTime);

                    facilities.Add(noneFacility);
                }
            }
            return(facilities.FirstOrDefault());
        }