public AirlineAirportFacilityMVVM(AirlineAirportFacility facility, Alliance alliance) { this.Facility = facility; this.Alliance = alliance; this.IsHuman = GameObject.GetInstance().HumanAirline == facility.Airline; this.IsDelivered = facility.FinishedDate < GameObject.GetInstance().GameTime; }
//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); }
//sets the facility for an airline public void addAirportFacility(AirlineAirportFacility facility) { //this.Facilities.RemoveAll(f => f.Airline == facility.Airline && f.Facility.Type == facility.Facility.Type); this.Facilities.Add(facility); }
//adds an airline facility to the airport public void addAirlineFacility(AirportFacility facility) { AirlineAirportFacility nextFacility = new AirlineAirportFacility(GameObject.GetInstance().HumanAirline,this.Airport, facility, GameObject.GetInstance().GameTime.AddDays(facility.BuildingDays)); this.Airport.setAirportFacility(nextFacility); AirlineAirportFacilityMVVM currentFacility = this.AirlineFacilities.Where(f=>f.Facility.Facility.Type == facility.Type).FirstOrDefault(); if (currentFacility != null) this.AirlineFacilities.Remove(currentFacility); Alliance alliance = nextFacility.Airline.Alliances.Count == 0 ? null : nextFacility.Airline.Alliances[0]; this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(nextFacility,alliance)); }
public AirlineAirportFacilityMVVM(AirlineAirportFacility facility, Alliance alliance) { this.Facility = facility; this.Alliance = alliance; }
//removes an airline facility from the airport public void removeAirlineFacility(AirlineAirportFacility facility) { this.Airport.downgradeFacility(facility.Airline, facility.Facility.Type); this.AirlineFacilities.Remove(facility); if (this.Airport.getAirlineAirportFacility(facility.Airline, facility.Facility.Type).Facility.TypeLevel > 0) this.AirlineFacilities.Add(this.Airport.getAirlineAirportFacility(facility.Airline, facility.Facility.Type)); }
//adds an airline facility to the airport public void addAirlineFacility(AirportFacility facility) { AirlineAirportFacility nextFacility = new AirlineAirportFacility(GameObject.GetInstance().HumanAirline,this.Airport, facility, GameObject.GetInstance().GameTime.AddDays(facility.BuildingDays)); this.Airport.addAirportFacility(nextFacility); /* AirlineAirportFacilityMVVM currentFacility = this.AirlineFacilities.Where(f => f.Facility.Facility.Type == facility.Type).FirstOrDefault(); if (currentFacility != null) removeAirlineFacility(currentFacility); Alliance alliance = nextFacility.Airline.Alliances.Count == 0 ? null : nextFacility.Airline.Alliances[0]; this.AirlineFacilities.Add(new AirlineAirportFacilityMVVM(nextFacility,alliance)); * */ this.AirlineFacilities.Clear(); this.BuildingAirlineFacilities.Clear(); foreach (var tFacility in this.Airport.getAirportFacilities().FindAll(f => f.Airline != null)) if (tFacility.Facility.TypeLevel != 0) { Alliance alliance = tFacility.Airline.Alliances.Count == 0 ? null : tFacility.Airline.Alliances[0]; AirlineAirportFacilityMVVM airlineFacility = new AirlineAirportFacilityMVVM(tFacility, alliance); if (airlineFacility.IsDelivered) this.AirlineFacilities.Add(airlineFacility); else this.BuildingAirlineFacilities.Add(airlineFacility); } }