Ejemplo n.º 1
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;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles the GatePassed event for the gates.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void gate_GatePassed(object sender, EventArgs e)
        {
            Gate gate = sender as Gate;

            if (gate != null)
            {
                if (gate.SequenceNumber == 0)
                {
                    if (passSound != null)
                    {
                        passSound.Play(false);
                    }
                    // Start counting
                    startTime = owner.CurrentTime;
                    racing    = true;
                    // set the proper gates
                    Gate oldGate = GetGate(currentGateNr);
                    oldGate.Active = false;
                    currentGateNr  = 1;
                    Gate newGate = GetGate(currentGateNr);
                    newGate.Active = true;
                    arrow.Position = new Vector3(newGate.Position.X, newGate.Position.Y + newGate.Height, newGate.Position.Z);
                }
                else if (gate.SequenceNumber == currentGateNr)
                {
                    gate.Active = false;
                    if (passSound != null)
                    {
                        passSound.Play(false);
                    }
                    if (currentGateNr == gates.Count - 1)
                    {
                        // Finished!!
                        racing = false;
                        TimeSpan ts = TimeSpan.FromSeconds(owner.CurrentTime - startTime);
//                            new TimeSpan(0, 0, 0, (int)Math.Floor(owner.CurrentTime - startTime), (int)(1000 * (owner.CurrentTime - startTime)) % 1000);
                        owner.CenterHud.ShowGameText(string.Format("You finished in {0}:{1}.{2}", (int)(Math.Floor(ts.TotalMinutes)), ts.Seconds.ToString("00"), ts.Milliseconds.ToString("000")), 1000);
                    }
                    // next gate
                    currentGateNr  = (currentGateNr + 1) % gates.Count;
                    gate           = GetGate(currentGateNr);
                    gate.Active    = true;
                    arrow.Position = new Vector3(gate.Position.X, gate.Position.Y + gate.Height, gate.Position.Z);
                }
            }
        }
Ejemplo n.º 3
0
 public void StartEngine()
 {
     if (engineSound != null)
     {
         engineSound.Volume = 1;
         engineSound.Play(true);
     }
     if (rotorSound != null)
     {
         rotorSound.Volume = 1;
         rotorSound.Play(true);
     }
 }
Ejemplo n.º 4
0
        public void Crash()
        {
            Vector3 posDiff  = this.Position - Framework.Instance.CurrentCamera.LookFrom;
            float   distance = posDiff.Length();

            crashSound.Volume = Math.Max(100 - (int)(distance / 5), 0);
            crashSound.Play(false);
            if (engineSound != null)
            {
                engineSound.Stop();
            }
            if (rotorSound != null)
            {
                rotorSound.Stop();
            }
        }
Ejemplo n.º 5
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);
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Resets the position of the airplane
        /// </summary>
        public void Reset()
        {
            iFlightModel.Reset();
            iFlightModel.Throttle     = 0;
            iFlightModel.CableEnabled = false;
            crashTime = 0;
            if (AircraftParameters.HandLaunched)
            {
                if (variometer != null)
                {
                    variometer.Play(true);
                }
                iFlightModel.HandLaunch(-owner.PilotPosition.Z, -owner.PilotPosition.X, -owner.PilotPosition.Y);
            }
            else if (AircraftParameters.HasFloats && TakeOffFromWater)
            {
                iFlightModel.X = -waterStartPosition.Z;
                iFlightModel.Y = -waterStartPosition.X;
                iFlightModel.Z = -waterStartPosition.Y;
                if (AircraftParameters.HasRetracts)
                {
                    iFlightModel.GearExtended = false;
                }
            }
            else
            {
                iFlightModel.X = -defaultStartPosition.Z;
                iFlightModel.Y = -defaultStartPosition.X;
                iFlightModel.Z = -defaultStartPosition.Y;
            }
            if ((owner != null) && (owner.InputManager != null))
            {
                prevFlapsChannel = owner.InputManager.GetAxisValue("flaps");
                prevGearChannel  = owner.InputManager.GetAxisValue("gear");
            }

            airplane.StartEngine();

            prevPos = new Vector3(-iFlightModel.Y, -iFlightModel.Z, -iFlightModel.X);
        }