//sets the airport expansion to an airport public static void SetAirportExpansion(Airport airport, AirportExpansion expansion, bool onStartUp = false) { if (expansion.Type == AirportExpansion.ExpansionType.Name) { if (expansion.NotifyOnChange && !onStartUp) { GameObject.GetInstance() .NewsBox.AddNews( new News( News.NewsType.AirportNews, GameObject.GetInstance().GameTime, "Airport Name Changed", $"[LI airport={airport.Profile.IATACode}]({new AirportCodeConverter().Convert(airport)}) has changed its name to {expansion.Name}")); } airport.Profile.Name = expansion.Name; } if (expansion.Type == AirportExpansion.ExpansionType.NewRunway) { var runway = new Runway(expansion.Name, expansion.Length, Runway.RunwayType.Regular, expansion.Surface, expansion.Date, true); airport.Runways.Add(runway); if (expansion.NotifyOnChange && !onStartUp) { GameObject.GetInstance() .NewsBox.AddNews( new News( News.NewsType.AirportNews, GameObject.GetInstance().GameTime, "New Runway", $"[LI airport={airport.Profile.IATACode}]({new AirportCodeConverter().Convert(airport)}) has created a new runway")); } } if (expansion.Type == AirportExpansion.ExpansionType.RunwayLength) { Runway runway = airport.Runways.FirstOrDefault(r => r.Name == expansion.Name); if (runway != null) { if (expansion.NotifyOnChange && !onStartUp) { GameObject.GetInstance() .NewsBox.AddNews( new News( News.NewsType.AirportNews, GameObject.GetInstance().GameTime, "New Terminal", $"[LI airport={airport.Profile.IATACode}]({new AirportCodeConverter().Convert(airport)}) has changed the length of the runway {expansion.Name} to {new SmallDistanceToUnitConverter().Convert(expansion.Length, null, null, null)}")); } } } if (expansion.Type == AirportExpansion.ExpansionType.NewTerminal) { var terminal = new Terminal(airport, expansion.Name, expansion.Gates, expansion.Date, expansion.TerminalType); airport.AddTerminal(terminal); if (expansion.NotifyOnChange && !onStartUp) { GameObject.GetInstance() .NewsBox.AddNews( new News( News.NewsType.AirportNews, GameObject.GetInstance().GameTime, "New Terminal", $"[LI airport={airport.Profile.IATACode}]({new AirportCodeConverter().Convert(airport)}) has created a new terminal with {expansion.Gates} gates")); } } if (expansion.Type == AirportExpansion.ExpansionType.ExtraGates) { Terminal terminal = airport.Terminals.AirportTerminals.FirstOrDefault(t => t.Name == expansion.Name); if (terminal != null) { for (int i = 0; i < expansion.Gates; i++) terminal.Gates.AddGate(new Gate(expansion.Date)); if (expansion.NotifyOnChange && !onStartUp) { GameObject.GetInstance() .NewsBox.AddNews( new News( News.NewsType.AirportNews, GameObject.GetInstance().GameTime, "New Gates at Airport", $"[LI airport={airport.Profile.IATACode}]({new AirportCodeConverter().Convert(airport)}) has created {expansion.Gates} gates in {expansion.Name}")); } } } if (expansion.Type == AirportExpansion.ExpansionType.CloseTerminal) { Terminal terminal = airport.Terminals.AirportTerminals.FirstOrDefault(t => t.Name == expansion.Name); if (terminal != null) { airport.RemoveTerminal(terminal); if (expansion.NotifyOnChange && !onStartUp) { GameObject.GetInstance() .NewsBox.AddNews( new News( News.NewsType.AirportNews, GameObject.GetInstance().GameTime, "Closed Terminal", $"[LI airport={airport.Profile.IATACode}]({new AirportCodeConverter().Convert(airport)}) has closed its terminal {expansion.Name}")); } } } //close terminal }
public static void CheckForExtendGates(Airport airport) { const int minYearsBetweenExpansions = 5; if (airport.Terminals.GetOrdereredGates() == 0 && GameObject.GetInstance().GameTime.AddYears(-minYearsBetweenExpansions) > airport.LastExpansionDate) { Terminal minTerminal = airport.Terminals.AirportTerminals.OrderBy(t => t.Gates.NumberOfGates).First(); bool newTerminal = minTerminal.Gates.NumberOfGates > 50; //extend existing if (!newTerminal) { int numberOfGates = Math.Max(5, minTerminal.Gates.NumberOfGates); int daysToBuild = numberOfGates*10 + (newTerminal ? 60 : 0); long price = numberOfGates*airport.GetTerminalGatePrice() + (newTerminal ? airport.GetTerminalPrice() : 0); price = price/3*4; if (airport.Income > price) { for (int i = 0; i < numberOfGates; i++) { var gate = new Gate(GameObject.GetInstance().GameTime.AddDays(daysToBuild)) {Airline = minTerminal.Airline}; minTerminal.Gates.AddGate(gate); } airport.Income -= price; airport.LastExpansionDate = GameObject.GetInstance().GameTime; } } //build new terminal else { int numberOfGates = airport.Terminals.GetTerminals()[0].Gates.NumberOfDeliveredGates; int daysToBuild = numberOfGates*10 + (newTerminal ? 60 : 0); long price = numberOfGates*airport.GetTerminalGatePrice() + (newTerminal ? airport.GetTerminalPrice() : 0); price = price/3*4; if (airport.Income > price) { var terminal = new Terminal( airport, null, "Terminal", numberOfGates, GameObject.GetInstance().GameTime.AddDays(daysToBuild), Terminal.TerminalType.Passenger); airport.AddTerminal(terminal); airport.Income -= price; airport.LastExpansionDate = GameObject.GetInstance().GameTime; } } } }