public void RemoveOnWinPerfectEvent(OnWinPerfect perfectEvent) { OnWinPerfect -= perfectEvent; }
public void ParseKanji(string userstrokeCount, string path) { if (path == "") { return; } string results = ""; Kanji firstResult = null; foreach (Kanji kanji in KanjiManager.GetMatchingKanji(path)) { if (firstResult == null) { firstResult = kanji; results += kanji.Name; } else { results += kanji.Name;// + " " + kanji.Meaning; } } if (IsDebug) { DebugString = results; } if (path == SeekingKanji.Strokes) { OnWinPerfect?.Invoke(); } else { List <string> diff; string[] set1 = Regex.Matches(path, @"\(.+?(?=\))+.").Cast <Match>().Select(match => match.Value).ToArray(); string[] set2 = Regex.Matches(SeekingKanji.Strokes, @"\(.+?(?=\))+.").Cast <Match>().Select(match => match.Value).ToArray(); if (set1.Count() > set2.Count()) { diff = getDifferences(set1, set2); } else { diff = getDifferences(set2, set1); } if (diff.Count == 0 && userstrokeCount == SeekingKanji.strokeCount) { OnWinAlmost?.Invoke(); return; } if (set2.Count() > set1.Count()) { diff = set2.Except(set1).ToList(); } else { diff = set1.Except(set2).ToList(); } List <string> diffCopy = diff; for (int i = 0; i < diffCopy.Count; i++) { if (diffCopy[i].Replace("-", "") == "(0.5, 0.5)") { diff.RemoveAt(i); } } if (diff.Count == 0 && userstrokeCount == SeekingKanji.strokeCount) { OnWinPoor?.Invoke(); } else if (IsDebug) { string res = ""; foreach (var item in diff) { res += item; } if (res != "") { Debug.Log(res); } } } }
public void AddOnWinPerfectEvent(OnWinPerfect perfectEvent) { OnWinPerfect += perfectEvent; }