Exemplo n.º 1
0
 /// <summary>
 /// Clean up.
 /// </summary>
 public override void Dispose()
 {
     if (crashSound != null)
     {
         crashSound.Stop();
         crashSound.Dispose();
         crashSound = null;
     }
     if (engineSound != null)
     {
         engineSound.Stop();
         engineSound.Dispose();
         engineSound = null;
     }
     if (rotorSound != null)
     {
         rotorSound.Stop();
         rotorSound.Dispose();
         rotorSound = null;
     }
     if (Mesh != null)
     {
         Mesh.Dispose();
         Mesh = null;
     }
     base.Dispose();
 }
Exemplo n.º 2
0
 private void CheckSound()
 {
     if ((Convert.ToBoolean(Bonsai.Utils.Settings.GetValue("EnableWindSound", "true"))) &&
         (ConstantWindSpeed > 0 || GustSpeed > 0))
     {
         if (sound == null)
         {
             sound = new SoundControllable("data/wind.wav");
             UpdateSound();
             sound.Play(true);
         }
         else
         {
             UpdateSound();
         }
     }
     else
     {
         if (sound != null)
         {
             sound.Stop();
             sound.Dispose();
             sound = null;
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Clean up.
 /// </summary>
 public void Dispose()
 {
     Bonsai.Utils.Settings.SettingsChanged -= new Bonsai.Utils.Settings.SettingsEventHandler(Settings_SettingsChanged);
     if (sound != null)
     {
         sound.Stop();
         sound.Dispose();
         sound = null;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Clean up.
        /// </summary>
        public void Dispose()
        {
            Bonsai.Utils.Settings.SettingsChanged -= new Bonsai.Utils.Settings.SettingsEventHandler(Settings_SettingsChanged);

            if (iFlightModel != null)
            {
                iFlightModel.Dispose();
                iFlightModel = null;
            }
            if (modelApi != null)
            {
                modelApi.Dispose();
                modelApi = null;
            }
            if (smoke != null)
            {
                smoke.Dispose();
                smoke = null;
            }
            if (airplane != null)
            {
                airplane.Dispose();
                airplane = null;
            }
            if (variometer != null)
            {
                variometer.Dispose();
                variometer = null;
            }
            if (towLine != null)
            {
                towLine.Dispose();
                towLine = null;
            }
            if (windVector != null)
            {
                windVector.Dispose();
                windVector = null;
            }
            if (ripples != null)
            {
                ripples.Dispose();
                ripples = null;
            }
            if (reflection != null)
            {
                reflection.Dispose();
                reflection = null;
            }
        }
Exemplo n.º 5
0
        public Race(Program owner)
        {
            this.owner = owner;

            passSound        = new SoundControllable("data\\gate.wav");
            passSound.Volume = 100;

            // Load the racing pylons
            LoadGates();

            arrow          = new GameObject();
            arrow.Mesh     = new XMesh("data\\arrow.x");
            arrow.Position = new Vector3(gates[0].Position.X, gates[0].Position.Y + 6f, gates[0].Position.Z);

            owner.CenterHud.ShowGameText("Fly through the first gate to start the clock", 1000);
        }
Exemplo n.º 6
0
 private void UpdateVariometer()
 {
     if (variometer != null)
     {
         variometer.Dispose();
         variometer = null;
     }
     if (Convert.ToBoolean(Bonsai.Utils.Settings.GetValue("EnableVariometer", "false")))
     {
         if ((iFlightModel != null) && (iFlightModel.AircraftParameters.HasVariometer))
         {
             variometer        = new SoundControllable("data/variometer.wav");
             variometer.Volume = 10;
             variometer.Play(true);
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Clean up.
        /// </summary>
        public void Dispose()
        {
            foreach (Gate gate in gates)
            {
                gate.Dispose();
            }
            gates.Clear();

            if (arrow != null)
            {
                arrow.Dispose();
                arrow = null;
            }
            if (passSound != null)
            {
                passSound.Dispose();
                passSound = null;
            }
            owner.CenterHud.ShowGameText("", 0);
        }
Exemplo n.º 8
0
        public AirplaneModel(IAirplaneControl airplaneControl)
        {
            this.airplaneControl = airplaneControl;
            if (!string.IsNullOrEmpty(airplaneControl.AircraftParameters.FixedMesh))
            {
                this.Mesh = new XMesh(airplaneControl.AircraftParameters.FixedMesh, airplaneControl.AircraftParameters.FolderName);
                XMesh xMesh = (XMesh)(this.Mesh);
                xMesh.ComputeBoundingBox();
            }
            this.Scale    = new Vector3(airplaneControl.AircraftParameters.Scale, airplaneControl.AircraftParameters.Scale, airplaneControl.AircraftParameters.Scale);
            this.Position = new Vector3(0.0f, 10.0f, 0.0f);

            foreach (AircraftParameters.ControlSurface controlSurfaceDef in airplaneControl.AircraftParameters.ControlSurfaces)
            {
                ControlSurface surface = new ControlSurface(controlSurfaceDef, airplaneControl);
                AddChild(surface);
            }

            engineMinFreq = airplaneControl.AircraftParameters.EngineMinFrequency;
            engineMaxFreq = airplaneControl.AircraftParameters.EngineMaxFrequency;
            if (!string.IsNullOrEmpty(airplaneControl.AircraftParameters.EngineSound))
            {
                engineSound = new SoundControllable(airplaneControl.AircraftParameters.EngineSound, airplaneControl.AircraftParameters.FolderName);
            }
            if ((airplaneControl.AircraftParameters.FlightModelType == AircraftParameters.FlightModelTypeEnum.Helicopter) &&
                (airplaneControl.AircraftParameters.RotorSound != null))
            {
                if (!string.IsNullOrEmpty(airplaneControl.AircraftParameters.RotorSound))
                {
                    rotorSound = new SoundControllable(airplaneControl.AircraftParameters.RotorSound, airplaneControl.AircraftParameters.FolderName);
                }
            }

            crashSound = new SoundControllable("data\\crash.wav");

            if (!(airplaneControl is RecordedFlight))
            {
                Birds.ScareCrow = this;
            }
        }
Exemplo n.º 9
0
        public void LoadModel(string fileName)
        {
            // First clean up
            if (iFlightModel != null)
            {
                iFlightModel.Dispose();
                iFlightModel = null;
            }
            if (modelApi != null)
            {
                modelApi.Dispose();
                modelApi = null;
            }
            if (airplane != null)
            {
                airplane.Dispose();
                airplane = null;
            }
            if (variometer != null)
            {
                variometer.Dispose();
                variometer = null;
            }

            // Now load the actual model
            //model = new FlightModelWind();
            AircraftParameters parameters = new RCSim.DataClasses.AircraftParameters();

            parameters.File = fileName;

            if (!string.IsNullOrEmpty(Bonsai.Utils.Settings.GetValue("ApiFlightModel")))
            {
                try
                {
                    string   assemblyInfo  = Bonsai.Utils.Settings.GetValue("ApiFlightModel");
                    string[] assemblyParts = assemblyInfo.Split(',', ';');
                    Assembly assembly      = Assembly.LoadFrom(assemblyParts[0]);
                    RCDeskPilot.API.FlightModelSimple flightModelSimple =
                        assembly.CreateInstance(assemblyParts[1]) as RCDeskPilot.API.FlightModelSimple;
                    modelApi          = new FlightModelApi();
                    modelApi.ApiModel = flightModelSimple;
                    iFlightModel      = modelApi;
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(
                        string.Format("Failed to load the flightmodel plugin : {0}", ex.ToString()));
                }
            }
            else
            {
                if (parameters.Version == 2)
                {
                    iFlightModel = new FlightModelWind2();
                }
                else
                {
                    iFlightModel = new FlightModelWind();
                }
            }

            iFlightModel.AircraftParameters = parameters;
            iFlightModel.Initialize();
            iFlightModel.Reset();
            iFlightModel.Wind      = new Vector3(0, 0, 0);
            iFlightModel.Heightmap = Heightmap;
            iFlightModel.Water     = Program.Instance.Scenery.Water;
            airplane = new AirplaneModel(iFlightModel);

            CurrentModel = fileName;

            if (smoke != null)
            {
                smoke.Dispose();
                smoke = null;
            }
            smoke = new Smoke(owner, iFlightModel);

            UpdateVariometer();

            this.owner.UpdateCameras();
            this.Reset();
        }