public void Handle(GameClient session, ClientMessage message) { List <Soundtrack> tracks = new List <Soundtrack>(); int count = message.PopWiredInt32(); for (int i = 0; i < count; i++) { Soundtrack track = Skylight.GetGame().GetItemManager().TryGetSoundtrack(message.PopWiredInt32()); if (track != null) { tracks.Add(track); } } ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108); message_.Init(r63aOutgoing.SongInfo); message_.AppendInt32(count); foreach (Soundtrack track in tracks) { message_.AppendInt32(track.Id); message_.AppendString(track.Name); message_.AppendString(track.Track); message_.AppendInt32(track.LengthInMS); message_.AppendString(track.Author); } session.SendMessage(message_); }
public ActionResult Create([Bind(Include = "ID_Song,SongName,Duration,MusicalFK")] Soundtrack soundtrack) { int idnewSong; try { idnewSong = db.Song.Max(s => s.ID_Song) + 1; } catch (Exception) { idnewSong = 1; } soundtrack.ID_Song = idnewSong; if (ModelState.IsValid) { try { db.Song.Add(soundtrack); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { ModelState.AddModelError("", "An Error occurred with the addition of the new Song"); } } ViewBag.MusicalFK = new SelectList(db.Musical, "ID_Musical", "Title", soundtrack.MusicalFK); return(View(soundtrack)); }
private void Window_KeyDown(object sender, KeyEventArgs e) { BooleanToVisibilityConverter visibilityConverter = new BooleanToVisibilityConverter(); if (e.Key == Key.Escape) { if ((bool)visibilityConverter.ConvertBack(grGame.Visibility, null, null, null) && !(bool)visibilityConverter.ConvertBack(dlgDefeat.Visibility, null, null, null) && !(bool)visibilityConverter.ConvertBack(dlgVictory.Visibility, null, null, null) && !(bool)visibilityConverter.ConvertBack(grStats.Visibility, null, null, null) && GameModel.isLoadTimerEnd) { GameModel.Pause = !GameModel.Pause; } } if (e.Key == Key.R) { if (!GameModel.isModelReady) { return; } Rifle.Reload(Scope.isZoomIn, Rifle.isBoltAnimation || Rifle.isShootAnimation || Rifle.isReloadAnimation || Scope.isScopeAnimation); } if (e.Key == Key.S) { Soundtrack.NextTrack(); } }
public void SetSoundtrack(Soundtrack s) { AudioClip current = Primary.clip; AudioClip next = null; RefreshVolume(); if ((current == null) || (current.name.ToLower() != s.ToString().ToLower())) { foreach (AudioClip clip in Soundtracks) { if (clip.name.ToLower() == s.ToString().ToLower()) { next = clip; break; } } if (next != null) { this.Secondary.clip = next; this.Secondary.volume = 0f; this.Secondary.Play(); this.isCrossFading = true; this.currentCrossFadeTime = 0f; } } }
public static void PlaySound(Soundtrack sound) { string path; switch (sound) { case Soundtrack.Pop: path = @"\Data\sounds\eat_food.mp3"; break; case Soundtrack.LevelUp: path = @"\Data\sounds\level_up.mp3"; break; case Soundtrack.GameOver: path = @"\Data\sounds\death.mp3"; break; default: path = ""; break; } Sound.Open(new Uri(Environment.CurrentDirectory + path, UriKind.Relative)); Sound.Volume = Volume; Sound.Play(); }
/// <summary> /// Exports and shows obtained track names. /// </summary> private void showSoundtrackNamesMenuItem_Click(object sender, RoutedEventArgs e) { try { //obtain track list var tracks = Soundtrack.GetTrackNames(); //export to file using (var tracklistFile = new StreamWriter(File.Open(Cache.OutputDirectory + "tracknames.csv", FileMode.Create))) { //write headers tracklistFile.WriteLine("File Id,Name"); foreach (var track in tracks) { tracklistFile.WriteLine($"{track.Key},\"{track.Value}\""); } } //show file Process.Start(Cache.OutputDirectory + "tracknames.csv"); } catch (Exception ex) { DisplayError(ex, "Could not create track list."); } }
public void SetMusic(Soundtrack track) { if (soundtracks.ContainsKey(track)) { SetMusic(soundtracks[track]); } }
void Start() { soundtrack = FindObjectOfType <Soundtrack>(); checklist = FindObjectOfType <ChecklistManager>(); horizontalItemManager = FindObjectOfType <HorizontalItemManager>(); soundtrack.Play(audio); }
private IEnumerator BeginMusicFade(Soundtrack newMusic, float fadeTime) { AudioSource currentSource = gameObject.GetComponent <AudioSource>(); AudioSource newSource = gameObject.AddComponent <AudioSource>(); newSource.clip = newMusic.clip; newSource.volume = 0; newSource.outputAudioMixerGroup = musicMixerGroup; newSource.ignoreListenerPause = true; newSource.playOnAwake = false; newSource.loop = true; newSource.Play(); float currentSourceVolume = currentSource.volume; float progress = 0f; while (progress < 1) { progress += Time.unscaledDeltaTime / fadeTime; newSource.volume = Mathf.Lerp(0, newMusic.volume, progress); currentSource.volume = Mathf.Lerp(currentSourceVolume, 0f, progress); yield return(null); } Destroy(currentSource); }
private void grGame_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if ((bool)e.NewValue) { Soundtrack.PlayGameTrack(); } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
public TestCacheFixture() { this.RuneTek5Cache = new RuneTek5Cache("testdata/runetek5", false); this.DownloaderCache = new DownloaderCache(); this.FlatFileCache = new FlatFileCache("testdata/flatfile"); this.Soundtrack = new Soundtrack(this.RuneTek5Cache, "soundtrack"); }
/// <summary> /// Called whenever another soundtrack is stopped. /// </summary> /// <param name="other"></param> private void OnStopped(Soundtrack other) { --fadeout_counter; if (fadeout_counter == 0) { FadeIn(); // No other soundtrack playing: fade in right away! } }
public void StartMusic(Soundtrack track) { AudioSource soundtrack = musicPool[(int)track]; if (!soundtrack.isPlaying) { soundtrack.Play(); } }
public void RestartGame() { // Prevent double soundtrack playing! Soundtrack ost = GameObject.FindObjectOfType <Soundtrack>(); DestroyImmediate(ost.gameObject); SceneManager.LoadScene(0); // Go all the way back to the beginning! }
public void Put(int id, [FromBody] Soundtrack obj) { var oldObj = _soundData.Get(id); if (oldObj == null) { return; } var newObj = _soundData.Update(obj); } // Might break
public SoundtrackModel Create(Soundtrack soundtrack) { SoundtrackModel model = new SoundtrackModel(); model.Id = soundtrack.soundtrack_id; model.Musician = soundtrack.musician; model.Song = soundtrack.song; model.Duration = soundtrack.duration; return(model); }
private void CombineSoundtrack() { var soundtrack = new Soundtrack(this._cache, this._argumentParser.OutputDirectory + "soundtrack/"); if (this._argumentParser.TemporaryDirectory != null) { soundtrack.TemporaryDirectory = this._argumentParser.TemporaryDirectory; } soundtrack.Extract(this._argumentParser.Overwrite, this._argumentParser.Lossless, this._argumentParser.IncludeUnnamedSoundtracks, this._argumentParser.SoundtrackNameFilter?.ToArray() ?? new string[0]); }
public MainWindow() { InitializeComponent(); startGameTimer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 0, 0, 200) }; startGameTimer.Tick += new EventHandler(StartGameTimerTick); soundtrack = new Soundtrack(); }
private void Start() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
// GET: Soundtracks/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(RedirectToAction("Index", "Musicals", null)); } Soundtrack soundtrack = db.Song.Find(id); if (soundtrack == null) { return(RedirectToAction("Index", "Musicals", null)); } return(RedirectToAction("Edit", "Musicals", new { id = soundtrack.MusicalFK }));; }
// GET: Soundtracks/Details/5 public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index")); } Soundtrack soundtrack = db.Song.Find(id); if (soundtrack == null) { return(RedirectToAction("Index")); } return(View(soundtrack)); }
public async Task <IActionResult> Create([Bind("Id, GenreId, SingerId, Title, ServerFilename, ClientFilename")] Soundtrack soundtrack) { if (ModelState.IsValid) { _context.Add(soundtrack); System.IO.File.Move(Path.Combine(TmpFileDir, soundtrack.ServerFilename), Path.Combine(WorkFileDir, soundtrack.ServerFilename)); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["GenreId"] = new SelectList(_context.Genre.OrderBy(e => e.Name), "Id", "Name", soundtrack.GenreId); ViewData["SingerId"] = new SelectList(_context.Singer.OrderBy(e => e.Name), "Id", "Name", soundtrack.SingerId); return(View(soundtrack)); }
// GET: Soundtracks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index")); } Soundtrack soundtrack = db.Song.Find(id); if (soundtrack == null) { return(RedirectToAction("Index")); } ViewBag.MusicalFK = new SelectList(db.Musical, "ID_Musical", "Title", soundtrack.MusicalFK); return(View(soundtrack)); }
public ActionResult DeleteConfirmed(int id) { Soundtrack soundtrack = db.Song.Find(id); try { db.Song.Remove(soundtrack); db.SaveChanges(); return(RedirectToAction("Index")); } catch (Exception) { ModelState.AddModelError("", string.Format("It's not possible to remove the Song nÂș {0}-{1}", id, soundtrack.SongName)); } return(View(soundtrack)); }
/// <summary> /// Initialize component /// </summary> private void Start() { if (!PlayerPrefs.HasKey("soundOff")) { PlayerPrefs.SetInt("soundOff", 1); PlayerPrefs.Save(); } audioSource = gameObject.GetComponent <AudioSource>(); if (PlayerObject != null) { Player.OnPlayerDead += GameOver; Player.OnScoreSet += OnScoreUpdate; Player.OnHealthsSet += OnHealthsUpdate; Player.OnBuyBonus += OnBuyBonus; PlayerObject.SetActive(false); } if (Spawner != null) { Spawner.GetComponent <EnemySpawner>().SetLevelSettings(LevelOptions); Spawner.SetActive(false); } if (GameOverUI != null) { GameOverUI.SetActive(false); } if (WinnerUI != null) { WinnerUI.SetActive(false); } if (MusicToggleUI != null) { musicToggleUI.GetComponent <Toggle>().isOn = PlayerPrefs.GetInt("soundOff") == 1; if (!musicToggleUI.GetComponent <Toggle>().isOn) { var clip = Soundtrack.ElementAt(0); audioSource.clip = clip; audioSource.loop = true; audioSource.Play(); } } }
public ActionResult Edit([Bind(Include = "ID_Song,SongName,Duration,MusicalFK")] Soundtrack soundtrack) { try { if (ModelState.IsValid) { db.Entry(soundtrack).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } catch (Exception) { ModelState.AddModelError("", string.Format("An error occurred with the addition of the song {0}", soundtrack.SongName)); } ViewBag.MusicalFK = new SelectList(db.Musical, "ID_Musical", "Title", soundtrack.MusicalFK); return(View(soundtrack)); }
private void showMissingSoundtrackNamesMenuItem_Click(object sender, RoutedEventArgs e) { if (!Directory.Exists(Cache.OutputDirectory + "soundtrack/")) { MessageBox.Show("Soundtrack directory hasn't been created yet."); return; } try { var soundtrackDir = Cache.OutputDirectory + "soundtrack/"; var tracks = Soundtrack.GetTrackNames(); var missingTracks = new Dictionary <int, string>(); foreach (var track in tracks) { if (!Directory.EnumerateFiles(soundtrackDir, track.Value + ".*").Any()) { missingTracks.Add(track.Key, track.Value); } } //export to file using ( var missingTracklistFile = new StreamWriter(File.Open(Cache.OutputDirectory + "missingtracknames.csv", FileMode.Create))) { //write headers missingTracklistFile.WriteLine("File Id,Name"); foreach (var track in missingTracks) { missingTracklistFile.WriteLine($"{track.Key},\"{track.Value}\""); } } //show file Process.Start(Cache.OutputDirectory + "missingtracknames.csv"); } catch (Exception ex) { DisplayError(ex, "Could not create missing track list."); } }
public void PlayMusic(Soundtrack newMusic) { AudioSource currentSource = gameObject.GetComponent <AudioSource>(); if (currentSource == null) { currentSource = gameObject.AddComponent <AudioSource>(); } currentSource.clip = newMusic.clip; currentSource.volume = newMusic.volume; currentSource.outputAudioMixerGroup = musicMixerGroup; currentSource.ignoreListenerPause = true; currentSource.playOnAwake = false; currentSource.loop = true; //Delay a bit to bypass audio initalization pop sound. StartCoroutine(BeginMusic(currentSource)); }
private void updateSoundtrackNamesMenuItem_Click(object sender, RoutedEventArgs e) { if (!Directory.Exists(Cache.OutputDirectory + "soundtrack/")) { MessageBox.Show("Soundtrack directory hasn't been created yet."); return; } try { var soundtrackDir = Cache.OutputDirectory + "soundtrack/"; var tracks = Soundtrack.GetTrackNames(); var namedTracks = 0; foreach (var trackPair in tracks) { var foundFiles = Directory.GetFiles(soundtrackDir, trackPair.Key + ".*"); if (foundFiles.Length > 0) { var extension = Path.GetExtension(foundFiles[0]); var destination = soundtrackDir + trackPair.Value + extension; //delete destination if it exists if (File.Exists(destination)) { File.Delete(destination); } File.Move(foundFiles[0], destination); namedTracks++; } } MessageBox.Show($"Named {namedTracks} tracks."); } catch (Exception ex) { DisplayError(ex, "Could not update all track names."); } }
public async Task <IActionResult> Edit(int id, [Bind("Id, GenreId, SingerId, Title, ServerFilename, ClientFilename")] Soundtrack soundtrack) { if (id != soundtrack.Id) { return(NotFound()); } if (ModelState.IsValid) { Soundtrack existingSoundtrack = _context.Soundtrack.FirstOrDefault(e => e.Id == soundtrack.Id); _context.Entry <Soundtrack>(existingSoundtrack).State = EntityState.Detached; try { _context.Update(soundtrack); if (System.IO.File.Exists(Path.Combine(TmpFileDir, soundtrack.ServerFilename))) { if (existingSoundtrack != null) { System.IO.File.Delete(Path.Combine(WorkFileDir, existingSoundtrack.ServerFilename)); } System.IO.File.Move(Path.Combine(TmpFileDir, soundtrack.ServerFilename), Path.Combine(WorkFileDir, soundtrack.ServerFilename)); } await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SoundtrackExists(soundtrack.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["GenreId"] = new SelectList(_context.Genre.OrderBy(e => e.Name), "Id", "Name", soundtrack.GenreId); ViewData["SingerId"] = new SelectList(_context.Singer.OrderBy(e => e.Name), "Id", "Name", soundtrack.SingerId); return(View(soundtrack)); }
// Used to inititalize any variables or game state before the game starts void Awake() { if (instance == null) { instance = this; } else if (instance != this && instance != this && Application.loadedLevelName != "Main menu") { Destroy(instance.gameObject); instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(gameObject); source = GetComponent<AudioSource>(); }