Skip to content

AircraftController

Paulius Imbrasas edited this page Jan 23, 2014 · 2 revisions

This class is responsible for the creation and removal of aircraft from the airspace, observing interactions between aircraft and passing user input to selected aircraft. It also controls the initialisation of certain variables dependent on selected difficulty. It conducts this by use of the following methods: (also fulfils SR)

Creation of aircraft: update()generateAircraft().

Creates an aircraft of random aircraft type, with a flight plan generated by call to FlightPlanComponent.generate(). The rate of aircraft generation is controlled within Update(), which includes tests checking if the maximum number of aircraft is reached and a predefined time period has elapsed since an aircraft was last generated. A sound is played to inform the player of the creation and entry of the aircraft into the airspace.

Removal of aircraft: update()removeAircraft().

Update method checks if aircraft.isActive() is false. If that is the case, the aircraft instance is removed from aircraftList[].

Interactions between aircraft: update(). (SR12, SR17, SR19, SR25, SR26, )

The check for both collisions between aircraft and breaching of separation rules is done within update(). Both test if horizontal and vertical distance between two aircraft is less than either the separationRadius of the ‘primary’ aircraft (for breach of separation), or against the radius (for collision detection) of the two aircraft. This is done iteratively, testing each aircraft against every other aircraft excluding itself. While this is inelegant, the performance implications are inconsequential having tested this with non-typically large number of aircraft present in the airspace at once (>20).

Sounds for the notification of both collisions and separation rule breach are played here during their respective cases.

Selecting an aircraft: ClickListener.click()selectAircraft().

Using the built-in listeners for actors, we simply add a ClickListener to each and every aircraft. As soon as the user clicks the aircraft, it is automatically detected and the clicked() method of the listener is called, where the selectAircraft() method is called. It also makes sure that the previously selected aircraft (if there is one) is no longer turning and informs it is no longer selected. Finally, using the aircraft.selected(true) function of the aircraft, the newly selected aircraft is informed it is selected.

Handling user interaction with an aircraft : keyUp(), keyDown(), touchDown().

Dependent on key press and if an aircraft is currently selected, calls functions from the selected aircraft instance e.g. selectedAircraft.increaseAltitude().

Clone this wiki locally