void towplane_Stopped(object sender, EventArgs e) { if (towplane != null) { towplane.Dispose(); towplane = null; } }
/// <summary> /// Clean up. /// </summary> public void Dispose() { if (recordedFlight != null) { recordedFlight.Dispose(); recordedFlight = null; } }
public void OnFrameMove(Microsoft.DirectX.Direct3D.Device device, double totalTime, float elapsedTime) { for (int i = 0; i < recordedFlights.Count; i++) { RecordedFlight flight = recordedFlights[i]; flight.OnFrameMove(device, totalTime, elapsedTime); } }
private void RemovePilot() { RecordedFlight recordedFlight = recordedFlights[recordedFlights.Count - 1]; recordedFlights.Remove(recordedFlight); recordedFlight.Stopped -= new EventHandler(recordedFlight_Stopped); recordedFlight.Dispose(); }
public void Dispose() { if (towplane != null) { towplane.Playing = false; } if (towplane != null) { towplane.Dispose(); towplane = null; } }
public void Start() { if (towplane != null) { towplane.Playing = false; } if (towplane == null) { towplane = new RecordedFlight(Program.Instance); towplane.FileName = "towing.dat"; towplane.Stopped += new EventHandler(towplane_Stopped); towplane.Playing = true; } }
/// <summary> /// Handles the Stopped event of a recorded flight /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void recordedFlight_Stopped(object sender, EventArgs e) { RecordedFlight flight = sender as RecordedFlight; if (flight != null) { int index = recordedFlights.IndexOf(flight); if (index >= 0) { recordedFlights[index] = CreateFlight(); } DisposeFlight(flight); } }
private void NextScene() { if (recordedFlight != null) { recordedFlight.Dispose(); recordedFlight = null; } currentScene = (currentScene + 1) % nScenes; recordedFlight = new RecordedFlight(owner); scheduledMessages.Clear(); switch (currentScene) { case 0: //Program.Instance.SetWaterCamera(true); recordedFlight.FileName = "flight0.dat"; //AddScheduledMessage(3, "BMI Beaver 1300 with floats", 160f); break; case 1: //Program.Instance.SetWaterCamera(false); //AddScheduledMessage(3, "BMI Allegro 1500", 160f); recordedFlight.FileName = "flight1.dat"; break; case 2: //AddScheduledMessage(3, "BMI Beaver 1300", 160f); recordedFlight.FileName = "flight2.dat"; break; case 3: //AddScheduledMessage(3, "BMI Arrow 1400", 160f); recordedFlight.FileName = "flight3.dat"; break; } Program.Instance.CenterHud.ShowCaption("Flip a switch on the controller\nor press space bar to take control", 100000); recordedFlight.Stopped += new EventHandler(recordedFlight_Stopped); recordedFlight.Playing = true; Program.Instance.SetCameraTarget(recordedFlight.AirplaneModel); }
private RecordedFlight CreateFlight() { RecordedFlight recordedFlight = new RecordedFlight(owner); string filename = ""; bool done = false; while (!done) { filename = string.Format("flight{0}.dat", random.Next(4).ToString()); done = true; foreach (RecordedFlight flight in recordedFlights) { if (flight.FileName.Equals(filename)) { done = false; } } } recordedFlight.FileName = filename; recordedFlight.Stopped += new EventHandler(recordedFlight_Stopped); recordedFlight.Playing = true; return(recordedFlight); }
private void DisposeFlight(RecordedFlight flight) { flight.Stopped -= new EventHandler(recordedFlight_Stopped); flight.Dispose(); }
private void AddPilot() { RecordedFlight recordedFlight = CreateFlight(); recordedFlights.Add(recordedFlight); }
private void RemovePilot(RecordedFlight flight) { recordedFlights.Remove(flight); DisposeFlight(flight); }