/// <summary> /// 添加歌曲 /// </summary> /// <param name="song1"></param> /// <returns></returns> public int AddSong(Song1 song1) { int row = 0; try { int singerId = GetSingerIdByName(song1.Singer); StringBuilder sb = new StringBuilder(); sb.Append("insert into tb_songs(name,songName,singerId,playTime,songSize,source,playCount,addTime) values("); sb.AppendFormat("'{0}',", song1.SongName); sb.AppendFormat("'{0}',", song1.getFileName()); sb.AppendFormat("'{0}',", singerId); sb.AppendFormat("CONVERT(VARCHAR(50),{0}/60)+'分'+CONVERT(VARCHAR(50),{1}%60)+'秒',", song1.Duration, song1.Duration); sb.AppendFormat("'{0}MB',", song1.Size); sb.AppendFormat("'{0}',", song1.Source); sb.AppendFormat("'{0}',", 0); sb.AppendFormat("'{0}')", DateTime.Now); row = DatabaseHelper.GetExecuteNonuery(sb.ToString()); } catch (Exception) { throw; } return(row); }
/// <summary> /// 添加歌曲 /// </summary> /// <param name="song1"></param> /// <returns></returns> public int AddSong(Song1 song1) { try { return(newSongService.AddSong(song1)); } catch (Exception) { throw; } }
private void btnStartDownLoad_Click(object sender, EventArgs e) { try { tsState.Value = 0; tsState.Visible = true; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (downloader == null) { downloader = new SongDownloader(provider, path); } foreach (ListViewItem item in lvSongs.CheckedItems) { timer1.Enabled = true; timer1.Interval = 100; MergedSong1 song = (MergedSong1)item.Tag; downloader.AddDownload(song); //若路径更改,则不往库中保存数据 if (txtDownLoadPath.Text.Trim() == Directory.GetCurrentDirectory() + @"\misucs\") { //判断歌手是否已存在,若不存在则添加 if (!isExeitsSinger(song.Singer)) { KtvMSModel.Singer singer = new KtvMSModel.Singer(); singer.Name = song.Singer; singerManager.AddSingerInfo(singer); } //根据歌名判断歌曲是否存在, if (!newSongManager.isExeitsSongByName(song.SongName)) { Song1 song1 = new Song1(); song1.SongName = song.SongName; song1.Singer = song.Singer; song1.Source = song.Source; song1.Duration = song.Duration; //播放时间 song1.Size = Convert.ToDouble((song.Size / (1024 * 1024)).ToString("F2")); //歌曲文件大小 int row = newSongManager.AddSong(song1);//添加歌曲 if (row > 0) { int songId = newSongManager.GetSongIdByName(song.SongName); if (songId != null && songId != 0) { downloadSongManger.AddDownloadSong(songId);//下载记录 } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void PlayDanger(int searchingLevel, int chasingLevel) { // Do nothing if the danger level hasn't changed if (searchingLevel == _prevSearchingLevel && chasingLevel == _prevChasingLevel) { if (_song1FadingIn) { FadeIn(Song1); } else if (_song1FadingOut) { FadeOut(Song1); } if (_song2FadingIn) { FadeIn(Song2); } else if (_song2FadingOut) { FadeOut(Song2); } return; } // TODO: THE CASES COVERED HERE AREN'T ALL THE POSSIBLE CASES? // NO DANGER if (searchingLevel <= 0 && chasingLevel <= 0) { _song1FadingOut = true; _song2FadingOut = true; Song2.Stop(); // ONE ENEMY STARTED SEARCHING } else if (searchingLevel == 1 && chasingLevel == 0) { if (!_song1FadingIn && !Song1.isPlaying) { Song1.Play(); } _song2FadingOut = true; _song1FadingIn = true; // ONE ENEMY STARTED CHASING } else if (searchingLevel == 0 && chasingLevel == 1) { if (!_song2FadingIn && !Song2.isPlaying) { Song2.Play(); } if (!Song1.isPlaying) { Song1.Play(); } Song2.timeSamples = Song1.timeSamples; _song2FadingIn = true; // TWO ENEMIES STARTED SEARCHING } else if (searchingLevel == 2) { Song2.timeSamples = Song1.timeSamples; if (!Song2.isPlaying) { Song2.Play(); } // THREE ENEMIES STARTED SEARCHING } else if (searchingLevel >= 3) { Song3.timeSamples = Song1.timeSamples; Song3.Play(); } // Keep track of transitions _prevSearchingLevel = searchingLevel; _prevChasingLevel = chasingLevel; }
// Use this for initialization void Start() { song = GetComponent <Song1>(); aManager = GetComponent <AudioManager>(); //Get a reference to the audio manager currentBeat = 0; //The current beat of focus nextBeat = 0; //The next beat for spawning //initialize other variables comboCount = 0; beatHit = false; score = 0; //World coordinates of the range for hitting a beat topLeftRange = mainCamera.ViewportToWorldPoint(new Vector3(0.0f, 0.3f)); botRightRange = mainCamera.ViewportToWorldPoint(new Vector3(1.0f, 0.1f)); keySpawns = new Dictionary <int, Vector3>(); //Create a new dictionary for each possible key and it's spawn location song.createSongMap(); // physically puts in the notes into the Lists beatmap = song.LoadandSetNotes(); // return the created lists beatmapTimes = song.LoadandSetTimes(); // return the created lists //For loop to set up key spawn locations for (int i = 0; i < 9; i++) { //1 - 9 keys //ViewPointToWorld of the spawning location //Vector3 spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.091f * (i + 1), 1.1f)); Vector3 spawnPoint; if (i == 0) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.065f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 1) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.16f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 2) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.2555f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 3) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.355f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 4) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.45f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 5) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.55f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 6) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.645f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 7) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.742f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } else if (i == 8) { spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.841f, 1.1f)); keySpawns.Add(i + 1, spawnPoint); } //Add the 0 key if (i == 8) { //increment i for 0 i++; //Change the spawn location to adjust for the new i value spawnPoint = mainCamera.ViewportToWorldPoint(new Vector3(0.935f, 1.1f)); keySpawns.Add(0, spawnPoint); } } aManager.loadAudioFiles("Sounds/Songs"); aManager.setSongToPlay(0); aManager.playSong(); noteFallSpeed = 4.0f; timeOffset = noteFallSpeed * 5.7f; percentPerHit = 100.0f / beatmap.Count; //Set the initial state to InGame currState = gameState.InGame; recorder = GetComponent <NoteRecorder>(); }