public void SetSong(SongConfig songConfig) { // Get info about the song currentSong = songConfig; _songProfiler.Parse(currentSong.songText); _songProfiler.Song.Sort((Note a, Note b) => (a.noteTime - GetHitTime(a)).CompareTo(b.noteTime - GetHitTime(b))); }
public SongBot(SongConfig config) { _instance = this; this._config = config; this._discord = new DiscordShardedClient(this._config.Discord.Build()); this._discord.DebugLogger.LogMessageReceived += (_, e) => { this._log.Log(e.Level.ToNLog(), e.Exception, " ({0}) -> {1}", e.Application, e.Message); }; }
/// <summary> /// 更新本地歌单 /// </summary> private void UpdateLocalSongList(SongConfig config) { if (config == null) { Debug.LogError("update local songList error!!! SongConfig is null"); return; } FileHelper.SafeCreateDictionary(m_localSongListFilePath); File.WriteAllText(m_localSongListFilePath, JsonUtility.ToJson(config)); Debug.Log("update local songList complete!!!"); }
public void Play(SongConfig song) { _audioSource.clip = song.clip; _beats = new List <float>(); _currentBeatIndex = 0; _songFrequencyInverse = 1f / song.clip.frequency; // Converting string time to samples for (int i = 0; i < song.beats.Count; i++) { float beatMilis = SongConfig.StrTimeToMilis(song.beats[i]); _beats.Add(beatMilis); } _audioSource.Play(); }
/// <summary> /// 获取本地歌曲列表 /// </summary> /// <returns></returns> public List <Song> GetLocalSongList() { SongConfig localConfig = null; try { string localSongListTxt = File.ReadAllText(m_localSongListFilePath); localConfig = JsonUtility.FromJson <SongConfig>(localSongListTxt); } catch (Exception) { } return(localConfig != null ? localConfig.songs : null); }
static async Task MainAsync() { Console.CancelKeyPress += (sender, e) => { if (!_cts.IsCancellationRequested) { _cts.Cancel(); } e.Cancel = true; }; var configFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "Config.json")); if (!configFile.Exists) { using (var fs = configFile.CreateText()) { fs.Write(JsonConvert.SerializeObject(SongConfig.Default, Formatting.Indented)); fs.Flush(); } _log.Warn("Default configuration file created."); Environment.Exit(1); } SongConfig config = default; using (var fs = configFile.OpenText()) config = JsonConvert.DeserializeObject <SongConfig>(fs.ReadToEnd()); if (string.IsNullOrEmpty(config.Discord.Token)) { throw new InvalidConfigurationException("Token must be valid."); } var bot = new SongBot(config); await bot.InitializeAsync(); while (!_cts.IsCancellationRequested) { await Task.Delay(1); } await bot.ShutdownAsync(); }
private void Init() { playersMorale = 0.5f; playerNotes = new Queue <InputNote> [NUMBER_OF_PLAYERS]; playerSuccess = new bool[NUMBER_OF_PLAYERS]; playerMiss = new bool[NUMBER_OF_PLAYERS]; _ignoreInput = new bool[NUMBER_OF_PLAYERS]; for (int i = 0; i < NUMBER_OF_PLAYERS; i++) { playerNotes[i] = new Queue <InputNote>(); } song = availableSongs[Random.Range(0, 2)]; ResetIgnoreInput(); }
public void Init(SongConfig config) { for (int i = 0; i < gridLayout.childCount; i++) { Destroy(gridLayout.GetChild(i).gameObject); } _measures = new List <Measure>(); foreach (var measure in config.measures) { var measureObj = Instantiate(measurePrefab, gridLayout); measureObj.Init(measure); _measures.Add(measureObj); } _scoreLength = ((float)_measures.Count) * MusicCore.Instance.measureLength; }
/// <summary> /// 检查歌单版本 /// </summary> private void CheckSongListVersion() { Debug.Log("check update start !!!"); SongConfig localConfig = null; SongConfig tempConfig = null; try { string tempSongListTxt = File.ReadAllText(m_localSongListTempFilePath); tempConfig = JsonUtility.FromJson <SongConfig>(tempSongListTxt); } catch (Exception e) { Debug.Log("check update error !!!" + e.Message); } try { string localSongListTxt = File.ReadAllText(m_localSongListFilePath); localConfig = JsonUtility.FromJson <SongConfig>(localSongListTxt); } catch (Exception e) { Debug.Log("check update error !!!" + e.Message); } if (localConfig != null) { if (tempConfig != null) { if (tempConfig.version > localConfig.version) { UpdateLocalSongList(tempConfig); } else { Debug.Log("dont need update local songList !!!"); } } } else { UpdateLocalSongList(tempConfig); } }
public SongConfig() { _instance = this; }
public EngineAction Run(SongConfig Config) { EngineAction actionResult = new EngineAction() { Target = Target.Me }; PL_BRDCount = PL.Player.GetPlayerInfo().Buffs.Where(b => b == 195 || b == 196 || b == 197 || b == 198 || b == 199 || b == 200 || b == 201 || b == 214 || b == 215 || b == 216 || b == 218 || b == 219 || b == 222).Count(); if (Config.SingingEnabled && PL.Player.Status != 33) { int songs_currently_up = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == 197 || b == 198 || b == 195 || b == 199 || b == 200 || b == 215 || b == 196 || b == 214 || b == 216 || b == 218 || b == 222).Count(); // TODO: Add support for multiple JAs per cast, or else this will never work. // For now we just return the action with only the ability in it. // ie. If N + T were up, this would return once with Troub, then next cycle return Night, // then finally return the song cast. if (Config.TroubadourEnabled && PL.AbilityAvailable(Ability.Troubadour) && songs_currently_up == 0) { actionResult.JobAbility = Ability.Troubadour; return(actionResult); } else if (Config.NightingaleEnabled && PL.AbilityAvailable(Ability.Nightingale) && songs_currently_up == 0) { actionResult.JobAbility = Ability.Nightingale; return(actionResult); } SongData song_1 = SongInfo.Where(c => c.song_position == Config.Song1).FirstOrDefault(); SongData song_2 = SongInfo.Where(c => c.song_position == Config.Song2).FirstOrDefault(); SongData song_3 = SongInfo.Where(c => c.song_position == Config.Song3).FirstOrDefault(); SongData song_4 = SongInfo.Where(c => c.song_position == Config.Song4).FirstOrDefault(); SongData dummy1_song = SongInfo.Where(c => c.song_position == Config.Dummy1).FirstOrDefault(); SongData dummy2_song = SongInfo.Where(c => c.song_position == Config.Dummy2).FirstOrDefault(); // Check the distance of the Monitored player int Monitoreddistance = 50; XiEntity monitoredTarget = PL.Entity.GetEntity((int)Monitored.Player.TargetID); Monitoreddistance = (int)monitoredTarget.Distance; int Songs_Possible = 0; if (song_1.song_name.ToLower() != "blank") { Songs_Possible++; } if (song_2.song_name.ToLower() != "blank") { Songs_Possible++; } if (dummy1_song != null && dummy1_song.song_name.ToLower() != "blank") { Songs_Possible++; } if (dummy2_song != null && dummy2_song.song_name.ToLower() != "blank") { Songs_Possible++; } // List to make it easy to check how many of each buff is needed. List <int> SongDataMax = new List <int> { song_1.buff_id, song_2.buff_id, song_3.buff_id, song_4.buff_id }; // Check Whether e have the songs Currently Up int count1_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_1.buff_id).Count(); int count2_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_2.buff_id).Count(); int count3_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == dummy1_song.buff_id).Count(); int count4_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_3.buff_id).Count(); int count5_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == dummy2_song.buff_id).Count(); int count6_type = PL.Player.GetPlayerInfo().Buffs.Where(b => b == song_4.buff_id).Count(); int MON_count1_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_1.buff_id).Count(); int MON_count2_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_2.buff_id).Count(); int MON_count3_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == dummy1_song.buff_id).Count(); int MON_count4_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_3.buff_id).Count(); int MON_count5_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == dummy2_song.buff_id).Count(); int MON_count6_type = Monitored.Player.GetPlayerInfo().Buffs.Where(b => b == song_4.buff_id).Count(); if (ForceSongRecast == true) { song_casting = 0; ForceSongRecast = false; } // SONG NUMBER #4 if (song_casting == 3 && PL_BRDCount >= 3 && song_4.song_name.ToLower() != "blank" && count6_type < SongDataMax.Where(c => c == song_4.buff_id).Count() && Last_Song_Cast != song_4.song_name) { if (PL_BRDCount == 3) { if (PL.SpellAvailable(dummy2_song.song_name)) { actionResult.Spell = dummy2_song.song_name; } } else { if (PL.SpellAvailable(song_4.song_name)) { actionResult.Spell = song_4.song_name; Last_Song_Cast = song_4.song_name; Last_SongCast_Timer[0] = DateTime.Now; playerSong4[0] = DateTime.Now; song_casting = 0; } } } else if (song_casting == 3 && song_4.song_name.ToLower() != "blank" && count6_type >= SongDataMax.Where(c => c == song_4.buff_id).Count()) { song_casting = 0; } // SONG NUMBER #3 else if (song_casting == 2 && PL_BRDCount >= 2 && song_3.song_name.ToLower() != "blank" && count4_type < SongDataMax.Where(c => c == song_3.buff_id).Count() && Last_Song_Cast != song_3.song_name) { if (PL_BRDCount == 2) { if (PL.SpellAvailable(dummy1_song.song_name)) { actionResult.Spell = dummy1_song.song_name; } } else { if (PL.SpellAvailable(song_3.song_name)) { actionResult.Spell = song_3.song_name; Last_Song_Cast = song_3.song_name; Last_SongCast_Timer[0] = DateTime.Now; playerSong3[0] = DateTime.Now; song_casting = 3; } } } else if (song_casting == 2 && song_3.song_name.ToLower() != "blank" && count4_type >= SongDataMax.Where(c => c == song_3.buff_id).Count()) { song_casting = 3; } // SONG NUMBER #2 else if (song_casting == 1 && song_2.song_name.ToLower() != "blank" && count2_type < SongDataMax.Where(c => c == song_2.buff_id).Count() && Last_Song_Cast != song_4.song_name) { if (PL.SpellAvailable(song_2.song_name)) { actionResult.Spell = song_2.song_name; Last_Song_Cast = song_2.song_name; Last_SongCast_Timer[0] = DateTime.Now; playerSong2[0] = DateTime.Now; song_casting = 2; } } else if (song_casting == 1 && song_2.song_name.ToLower() != "blank" && count2_type >= SongDataMax.Where(c => c == song_2.buff_id).Count()) { song_casting = 2; } // SONG NUMBER #1 else if ((song_casting == 0) && song_1.song_name.ToLower() != "blank" && count1_type < SongDataMax.Where(c => c == song_1.buff_id).Count() && Last_Song_Cast != song_4.song_name) { if (PL.SpellAvailable(song_1.song_name)) { actionResult.Spell = song_1.song_name; Last_Song_Cast = song_1.song_name; Last_SongCast_Timer[0] = DateTime.Now; playerSong1[0] = DateTime.Now; song_casting = 1; } } else if (song_casting == 0 && song_2.song_name.ToLower() != "blank" && count1_type >= SongDataMax.Where(c => c == song_1.buff_id).Count()) { song_casting = 1; } // ONCE ALL SONGS HAVE BEEN CAST ONLY RECAST THEM WHEN THEY MEET THE THRESHOLD SET ON SONG RECAST AND BLOCK IF IT'S SET AT LAUNCH DEFAULTS if (playerSong1[0] != DefaultTime && playerSong1_Span[0].Minutes >= Config.SongRecastMinutes) { if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false) { if (PL.SpellAvailable(song_1.song_name)) { actionResult.Spell = song_1.song_name; playerSong1[0] = DateTime.Now; song_casting = 0; } } } else if (playerSong2[0] != DefaultTime && playerSong2_Span[0].Minutes >= Config.SongRecastMinutes) { if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false) { if (PL.SpellAvailable(song_2.song_name)) { actionResult.Spell = song_2.song_name; playerSong2[0] = DateTime.Now; song_casting = 0; } } } else if (playerSong3[0] != DefaultTime && playerSong3_Span[0].Minutes >= Config.SongRecastMinutes) { if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false) { if (PL.SpellAvailable(song_3.song_name)) { actionResult.Spell = song_3.song_name; playerSong3[0] = DateTime.Now; song_casting = 0; } } } else if (playerSong4[0] != DefaultTime && playerSong4_Span[0].Minutes >= Config.SongRecastMinutes) { if ((Config.SingOnlyWhenNear && Monitoreddistance < 10) || Config.SingOnlyWhenNear == false) { if (PL.SpellAvailable(song_4.song_name)) { actionResult.Spell = song_4.song_name; playerSong4[0] = DateTime.Now; song_casting = 0; } } } } return(actionResult); }
public void InitScore(SongConfig config) { measureLength = config.measureLength; _score.Init(config); }