Exemplo n.º 1
0
 void towplane_Stopped(object sender, EventArgs e)
 {
     if (towplane != null)
     {
         towplane.Dispose();
         towplane = null;
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Clean up.
 /// </summary>
 public void Dispose()
 {
     if (recordedFlight != null)
     {
         recordedFlight.Dispose();
         recordedFlight = null;
     }
 }
Exemplo n.º 3
0
 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);
     }
 }
Exemplo n.º 4
0
        private void RemovePilot()
        {
            RecordedFlight recordedFlight = recordedFlights[recordedFlights.Count - 1];

            recordedFlights.Remove(recordedFlight);
            recordedFlight.Stopped -= new EventHandler(recordedFlight_Stopped);
            recordedFlight.Dispose();
        }
Exemplo n.º 5
0
 public void Dispose()
 {
     if (towplane != null)
     {
         towplane.Playing = false;
     }
     if (towplane != null)
     {
         towplane.Dispose();
         towplane = null;
     }
 }
Exemplo n.º 6
0
 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;
     }
 }
Exemplo n.º 7
0
        /// <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);
            }
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 private void DisposeFlight(RecordedFlight flight)
 {
     flight.Stopped -= new EventHandler(recordedFlight_Stopped);
     flight.Dispose();
 }
Exemplo n.º 11
0
        private void AddPilot()
        {
            RecordedFlight recordedFlight = CreateFlight();

            recordedFlights.Add(recordedFlight);
        }
Exemplo n.º 12
0
 private void RemovePilot(RecordedFlight flight)
 {
     recordedFlights.Remove(flight);
     DisposeFlight(flight);
 }