private void Awake() { if (tower == null) { tower = this; } }
public Register_A_New_FlightSteps() { var persistenceService = new SQLLitePersistenceService(); persistenceService.InitializeService(@"Data Source=..\..\..\..\Sqlite\TUI.SimulatorFlights.sqlite;Version=3;"); _currentControlTower = new ControlTower(persistenceService); }
public void T08_ControlTowerGives3EmptyRunways1NullIf3PresentAndRequested() { // Given ControlTower tower = new ControlTower(new Runway[] { new Runway("r1"), new Runway("r2"), new Runway("r3") }); // When List <Runway> results = new List <Runway>(); for (int i = 0; i < 4; i++) { Runway r = tower.GetAvailableRunway(); if (r != null) { r.Status = RunwayStatus.Full; } results.Add(r); } // Then Assert.IsTrue(results[0].Name == "r1"); Assert.IsTrue(results[1].Name == "r2"); Assert.IsTrue(results[2].Name == "r3"); Assert.IsTrue(results[3] == null); }
/// <summary> /// Default constructor /// </summary> public Form1() { InitializeComponent(); // Initiate standard variables flights = new List <Flight>(); controlTower = new ControlTower(); controlTower.Name = "CT #1"; controlTower.Airfield = "Schiphol Airport"; terminal = new Terminal(); terminal.Name = "Terminal East #23"; terminal.Number = 23; terminal.OnFlightsUpdated += UpdateFlights; // Create flights for (int i = 1; i <= amountOfFlights; i++) { // Create flights Flight f = new Flight(); f.Name = "Flight #" + i; f.LandingStrip = i; f.Arrival = DateTime.Now; // Subscribe to events f.OnLateArrival += terminal.FlightOnLateArrival; f.OnLateArrival += controlTower.UpdateFlights; // Add to clipboard flights.Add(f); lbFlights.Items.Add(f); } }
public void T18_GoToRunwayAfter3TurnsOnHangar() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Plane plane2 = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Hangar.AddPlaneToHangar(plane); Hangar.AddPlaneToHangar(plane2); Runway runway = new Runway("runway 01", RunwayStatus.Empty); ControlTower tower = new ControlTower(new Runway[] { runway }); runway.AcceptPlane(plane); for (int i = 0; i < 3; i++) // 9 turns have passed { time.AddTurn(); } // When time.AddTurn(); // Then Assert.IsTrue(plane.Location == PlaneLocation.OnRunway); Assert.IsTrue(plane2.Location == PlaneLocation.OnRunway); }
protected override void Initialize() { base.Initialize(); control = ControlTower.instance; canvas = GetComponentInChildren <Canvas>(); _Close(); }
public Calculate_Flight_Distance_And_Fuel_NeededSteps() { var persistenceService = new SQLLitePersistenceService(); persistenceService.InitializeService(@"Data Source=..\..\..\..\Sqlite\TUI.SimulatorFlights.sqlite;Version=3;"); _currentControlTower = new ControlTower(persistenceService); _currentFlight = new Flight("currentFlight"); }
private void Start() { _defender = FindObjectOfType <InfoController>().GetDefenderFromButton(); _currencyController = FindObjectOfType <CurrencyController>(); _controlTower = FindObjectOfType <InfoController>().GetControlTower(); UpdateValues(); }
public ControlTowerTests() { _persistenceServiceMock = new Mock <IPersistenceService>(); _persistenceServiceMock.Setup(x => x.SaveFlight(It.IsAny <IFlight>())) .Callback((IFlight flight) => _flights.Add(flight)); _persistenceServiceMock.Setup(x => x.GetFlight(It.IsAny <string>())) .Returns((string flightName) => _flights.SingleOrDefault(x => x.Name == flightName)); _controlTower = new ControlTower(_persistenceServiceMock.Object); }
public void T06_ControlTowerGivesNullRunwayIfNotPresentAndRequested() { // Given Runway runway = new Runway("runway 01", RunwayStatus.Full); ControlTower tower = new ControlTower(new Runway[] { runway }); // When Runway result = tower.GetAvailableRunway(); // Then Assert.IsTrue(result == null); }
public override void Land() { if (ControlTower.GetIsTrackBusy() == true) { ControlTower.Land(id); flight_altitude = 0; } else { ControlTower.SendMessage(); flight_altitude = flight_altitude; } }
public void T05_ControlTowerGivesEmptyRunwayIfPresentAndRequested() { // Given Runway runway = new Runway("runway 01", RunwayStatus.Empty); ControlTower tower = new ControlTower(new Runway[] { runway }); // When Runway result = tower.GetAvailableRunway(); // Then Assert.IsTrue(result != null); Assert.IsTrue(result.Name == runway.Name); }
public override void TakeOff() { if (ControlTower.GetIsTrackBusy() == true) { ControlTower.TakeOff(this.id); flight_altitude = 4000; ControlTower.ClearTrack(); } else { ControlTower.SendMessage(); flight_altitude = flight_altitude; } }
public void PlaneCanLandOnEmptyAirStrip() { Airport airport = new Airport(new List <AirStrip>() { new AirStrip() }); List <Plane> planes = new List <Plane>() { new Plane() }; ControlTower.Landing(airport, planes); Assert.IsTrue(planes.Any()); }
private GameObject _gameObject; // generic for prefabs that have data dispersed public void SetInfo(GameObject currentGameObject) { _destroyInfoInstances(); if (!currentGameObject) { return; } _gameObject = currentGameObject; var shooter = currentGameObject.GetComponent <Shooter>(); var defender = currentGameObject.GetComponent <Defender>(); var attacker = currentGameObject.GetComponent <Attacker>(); var currencyButton = currentGameObject.GetComponent <CurrencyButton>(); var _currencyProducer = currentGameObject.GetComponent <CurrencyProducer>(); _defenderButton = currentGameObject.GetComponent <DefenderButton>(); _controlTower = currentGameObject.GetComponent <ControlTower>(); if (shooter) { _currentInfoShooter = Instantiate(infoShooter, transform.position, Quaternion.identity); _currentInfoShooter.transform.SetParent(transform); } else if (_controlTower || currencyButton) { _currentInfoResources = Instantiate(infoResources, transform.position, Quaternion.identity); _currentInfoResources.transform.SetParent(transform); } else if (_defenderButton) { _currentInfoDefenderButton = Instantiate(infoDefenderButton, transform.position, Quaternion.identity); _currentInfoDefenderButton.transform.SetParent(transform); } else if (attacker || _currencyProducer) { _currentInfoDamageHealthBar = Instantiate(infoDamageHealthBar, transform.position, Quaternion.identity); _currentInfoDamageHealthBar.transform.SetParent(transform); } else if (defender) // Box { _currentInfoBox = Instantiate(infoBox, transform.position, Quaternion.identity); _currentInfoBox.transform.SetParent(transform); } }
public AirportDataDTO GetAirportData(string name) { ControlTower controlTower = stationTreeBuilder[name]?.ControlTower ?? throw new KeyNotFoundException("No control tower with given name found!"); IEnumerable <FlightDTO> flights = GetFlightDtos(controlTower.Id); IEnumerable <StationDTO> stations = controlTower.Stations.Select(s => StationDTO.FromDBModel(s)); IEnumerable <StationRelationDTO> stationRelations = GetStationRelationDtos(controlTower.Stations); IEnumerable <StationControlTowerRelationDTO> firstStations = controlTower.FirstStations .Select(sctr => StationControlTowerRelationDTO.FromDBModel(sctr)); ControlTowerDTO controlTowerDTO = ControlTowerDTO.FromDBModel(controlTower); logger.LogInformation("Successfully built airport data."); return(new AirportDataDTO { ControlTower = controlTowerDTO, FirstStations = firstStations, Flights = flights, StationRelations = stationRelations, Stations = stations }); }
public void T17_PlaneAddToHangarAfter25TurnsOnRunway() { // Given int initialFuel = 100; int maxFuel = 100; PassingTime time = new PassingTime(); Plane plane = PlaneFactory.Create(location: PlaneLocation.OnRunway, damage: PlaneDamage.None, fuel: initialFuel, maxFuel: maxFuel, passingTime: time); Runway runway = new Runway("runway 01", RunwayStatus.Empty); ControlTower tower = new ControlTower(new Runway[] { runway }); runway.AcceptPlane(plane); for (int i = 0; i < 24; i++) // 9 turns have passed { time.AddTurn(); } // When time.AddTurn(); // Then Assert.IsTrue(Hangar.Planes.Contains(plane)); }
public FlightSimulatorService(IPersistenceService persistenceService) { _controlTower = new ControlTower(persistenceService); }
public void FlightAskToTakeoff(Flight flight) { ControlTower tower = new ControlTower(); tower.FlightsAskToTakeoff(flight); }
public void FlightAskToLand(Flight flight) { ControlTower tower = new ControlTower(); tower.FlightsAskToLand(flight); }