public static void RemoveSentence(string sentence) { if (sentence.Contains("space")) { return; } string rhythm = RhythmLibrary.GetRhythmID(sentence); int length = sentence.Length; if (!s_library.ContainsKey(rhythm)) { return; } if (!s_library[rhythm].ContainsKey(length)) { return; } if (s_library[rhythm][length].Contains(sentence)) { s_library[rhythm][length].Remove(sentence); s_outSentenceList.Add(sentence); } }
public override void OnEnterStatus() { if (!isInit) { RhythmLibrary.Init(); PuzzleService.Init(); } OpenUI <CountDownWindow>(); }
/// <summary> /// 优先给出韵脚相同并且字数相同的答案, /// 否则再给字数相同的答案, /// 否则再给韵脚相同的答案, /// 否则再给一个随机答案 /// </summary> /// <param name="content"></param> public static string GetErrorAnswer(string content) { string rhythm = RhythmLibrary.GetRhythmID(content); int length = content.Length; if (s_library.ContainsKey(rhythm)) { //韵脚相同,字数相同 if (s_library[rhythm].ContainsKey(length) && s_library[rhythm][length].Count > 0) { return(GetRandomAnswer(s_library[rhythm][length])); } //返回一个字数相同的 else { string sameLengthID = GetSameContentLengthRhythmID(length); if (sameLengthID != null && s_library[sameLengthID][length].Count > 0) { return(GetRandomAnswer(s_library[sameLengthID][length])); } //如果没有与它字数相同的,返回一个韵脚相同的 else { return(GetRandomContent(s_library[rhythm])); } } } //没有与他韵脚相同的诗句 else { //先找有没有字数相同的字句 string sameLengthID = GetSameContentLengthRhythmID(length); if (sameLengthID != null) { return(GetRandomAnswer(s_library[sameLengthID][length])); } //如果没有与它字数相同的,就随机返回一个结果 else { return(GetRandomContent(s_library[GetRandomRhythm()])); } } }
static void PutSentence(string sentence) { string rhythm = RhythmLibrary.GetRhythmID(sentence); int length = sentence.Length; if (!s_library.ContainsKey(rhythm)) { s_library.Add(rhythm, new Dictionary <int, List <string> >()); } if (!s_library[rhythm].ContainsKey(length)) { s_library[rhythm].Add(length, new List <string>()); } if (s_library[rhythm][length].Contains(sentence)) { //Debug.LogError("有重复诗句! " + poem.m_content[i]); } else { s_library[rhythm][length].Add(sentence); } }
/// <summary> /// 获取一个随机韵脚 /// </summary> /// <returns></returns> static string GetRandomRhythm() { int random = RandomService.GetRand(0, RhythmLibrary.GetRhythmList().Count); return(RhythmLibrary.GetRhythmList()[random]); }