public static void PlayWeatherSound(string FileName, bool Looped = false) { if (!(E_Types.Options.Sound == 1) || !File.Exists(Application.StartupPath + E_Globals.SOUND_PATH + FileName)) { return; } if (CurWeatherMusic == FileName) { return; } SoundBuffer buffer = default(SoundBuffer); if (ReferenceEquals(WeatherSoundPlayer, null)) { WeatherSoundPlayer = new Sound(); } else { WeatherSoundPlayer.Stop(); } buffer = new SoundBuffer(Application.StartupPath + E_Globals.SOUND_PATH + FileName); WeatherSoundPlayer.SoundBuffer = buffer; WeatherSoundPlayer.Loop = Looped; WeatherSoundPlayer.Volume = E_Sound.MaxVolume; WeatherSoundPlayer.Play(); CurWeatherMusic = FileName; }
public override void OnUserUpdate(float fElapsedTime) { gCanvas.Clear(Color.Black); if (Input.KeyPressed(MouseButtons.Left)) { maxspeed *= 3f; } if (Input.KeyReleased(MouseButtons.Left)) { maxspeed /= 3f; } Vector desire = (Input.MousePos() - pos).Normalize(); Vector steering = desire - vel; vel += steering.Limit(maxsteer); float distance = (Input.MousePos() - pos).Magnitude(); float speed = Utility.Map(distance, 1f, 100f, 0f, maxspeed); pos += vel * speed * fElapsedTime; float angle = vel.AngleFromVector(); Bitmap pspriteship = Utility.RotateImage(spriteship, Utility.Degrees(angle)); gCanvas.DrawImage(pspriteship, pos.x - pspriteship.Width * 0.5f, pos.y - pspriteship.Height * 0.5f); pspriteship.Dispose(); if (speed > 10f && Focused()) { enginesound.PlayLoop(); } else { enginesound.Stop(); } }
public static void PlayExtraSound(string FileName, bool Looped = false) { if (!(E_Types.Options.Sound == 1) || !File.Exists(Application.StartupPath + E_Globals.SOUND_PATH + FileName)) { return; } //If FileName = CurExtraSound Then Exit Sub SoundBuffer buffer = default(SoundBuffer); if (ReferenceEquals(ExtraSoundPlayer, null)) { ExtraSoundPlayer = new Sound(); buffer = new SoundBuffer(Application.StartupPath + E_Globals.SOUND_PATH + FileName); ExtraSoundPlayer.SoundBuffer = buffer; if (Looped == true) { ExtraSoundPlayer.Loop = true; } else { ExtraSoundPlayer.Loop = false; } ExtraSoundPlayer.Volume = MaxVolume; ExtraSoundPlayer.Play(); } else { ExtraSoundPlayer.Stop(); buffer = new SoundBuffer(Application.StartupPath + E_Globals.SOUND_PATH + FileName); ExtraSoundPlayer.SoundBuffer = buffer; if (Looped == true) { ExtraSoundPlayer.Loop = true; } else { ExtraSoundPlayer.Loop = false; } ExtraSoundPlayer.Volume = MaxVolume; ExtraSoundPlayer.Play(); } }
public static void PlayExtraSound(string fileName, bool looped = false) { if (C_Types.Options.Sound == 0 || !File.Exists(Application.StartupPath + C_Constants.SoundPath + fileName)) { return; } SoundBuffer buffer = default(SoundBuffer); if (ReferenceEquals(ExtraSoundPlayer, null)) { ExtraSoundPlayer = new Sound(); buffer = new SoundBuffer(Application.StartupPath + C_Constants.SoundPath + fileName); ExtraSoundPlayer.SoundBuffer = buffer; if (looped == true) { ExtraSoundPlayer.Loop = true; } else { ExtraSoundPlayer.Loop = false; } ExtraSoundPlayer.Volume = MaxVolume; ExtraSoundPlayer.Play(); } else { ExtraSoundPlayer.Stop(); buffer = new SoundBuffer(Application.StartupPath + C_Constants.SoundPath + fileName); ExtraSoundPlayer.SoundBuffer = buffer; if (looped == true) { ExtraSoundPlayer.Loop = true; } else { ExtraSoundPlayer.Loop = false; } ExtraSoundPlayer.Volume = MaxVolume; ExtraSoundPlayer.Play(); } }
public static void PlayWeatherSound(string fileName, bool looped = false) { if (!(C_Types.Options.Sound == 1) || !File.Exists(Application.StartupPath + C_Constants.SoundPath + fileName)) { return; } if (CurWeatherMusic == fileName) { return; } SoundBuffer buffer = default(SoundBuffer); if (ReferenceEquals(WeatherSoundPlayer, null)) { WeatherSoundPlayer = new Sound(); } else { WeatherSoundPlayer.Stop(); } buffer = new SoundBuffer(Application.StartupPath + C_Constants.SoundPath + fileName); WeatherSoundPlayer.SoundBuffer = buffer; if (looped == true) { WeatherSoundPlayer.Loop = true; } else { WeatherSoundPlayer.Loop = false; } WeatherSoundPlayer.Volume = C_Sound.MaxVolume; WeatherSoundPlayer.Play(); CurWeatherMusic = fileName; }