/// <summary> /// Constructor for the Flight class that allows creation with explicit X and Y values /// </summary> /// <param name="name">Flight Name</param> /// <param name="model">Aircraft Model</param> /// <param name="type">Flight Type</param> /// <param name="dest">Destination Navpoint</param> /// <param name="altitude">Current altitude</param> /// <param name="speed">Current speed</param> /// <param name="heading">Current heading</param> /// <param name="x">Current Location on the X-axis</param> /// <param name="y">Current Location on the Y-axis</param> public Flight(string name, AircraftModel model, FlightPhase type, ref Waypoint dest, int altitude = 0, int speed = 0, int heading = 0, double x = 0, double y = 0) { this._name = name; this._model = model; this._type = type; this._destination = dest; this._altitude = altitude; this._speed = speed; this._heading = heading; this._location = new Location(x, y); this._targetAltitude = 0; }
/// <summary> /// Sets destination change information for this command /// </summary> /// <param name="destination">New destination</param> public void ChangeDestination(Waypoint destination) { this._action = Instruction.DESTINATION.ToString(); this._value = destination.Name; }
/// <summary> /// Sets takeoff information for this command /// </summary> /// <param name="runway">Takeoff Runway Waypoint</param> public void Takeoff(Waypoint runway) { this._action = Instruction.TAKEOFF.ToString(); this._value = runway.Name; }
/// <summary> /// Sets landing information for this command /// </summary> /// <param name="runway">Landing Runway Waypoint</param> public void Land(Waypoint runway) { this._action = Instruction.LAND.ToString(); this._value = runway.Name; }
/// <summary> /// Updates the information about this flight /// </summary> /// <param name="dest">Destination Navpoint</param> /// <param name="altitude">Current altitude</param> /// <param name="speed">Current speed</param> /// <param name="location">Current location</param> public void Update(ref Waypoint dest, int altitude, int speed, Location location) { this._destination = dest; this._altitude = altitude; this._location = location; this._speed = speed; }
/// <summary> /// Updates the information about this flight /// </summary> /// <param name="data">Flight object to update from</param> public void Update(Flight data) { if(data.Name == this._name) { this._destination = data._destination; this._altitude = data._altitude; this._location = data._location; this._speed = data._speed; } else { throw new Exception("FATAL: Flight objects do not match."); } }
/// <summary> /// Returns the waypoint specified, if it exists /// </summary> /// <param name="name">Name of the Waypoint</param> /// <returns>Waypoint object</returns> public Waypoint GetWaypoint(string name) { Waypoint wpt = new Waypoint(null, 1, 0, 0); this._waypointDict.TryGetValue(name, out wpt); return wpt; }