private void AddWord(string word) { char c = word[0]; if (c == '=') { SetWordTypes(WordMap.GetEncodedWordTypes(word.Substring(1))); } else { WordMap m; if (_map == null) { _map = new Dictionary <char, WordMap>(); } if (!_map.TryGetValue(c, out m)) { m = new WordMap(); _map.Add(c, m); } if (word.Length > 1) { m.AddWord(word.Substring(1)); } else { m.SetWordTypes((int)WordType.None); } } }
public static void Initialize() { WordMap.Initialize(); GameConfig.Initialize(); UserInput.Initialize(); SetState(State.MainMenu, null); }
private static IEnumerator LoadWords_Coroutine(System.Action <WordMap> callback) { WordMap wordMap = new WordMap(); TextAsset wordFile = Resources.Load <TextAsset>("words"); string[] lines = wordFile.text.Split('\n'); int numLines = lines.Length; Resources.UnloadAsset(wordFile); Logger.LogEditor("Found words: " + numLines); int count = 0; float startTime = Time.time; for (int i = 0; i < numLines; i++) { var line = lines[i]; var length = line.Length; if (length < 2) { continue; } wordMap.AddWord(line); count++; if (count % 5000 == 0) { yield return(null); } } Logger.LogEditor($"Added {count} words to the WordMap. ({(Time.time - startTime)}s)"); callback(wordMap); }
public static void Initialize() { CoroutineRunner.Run(LoadWords_Coroutine((wm) => { Words = wm; })); }