void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } if (charInit == null) { charInit = new CharacterInitializer(); } DontDestroyOnLoad(gameObject); blacklist = GameObject.FindObjectOfType <CharacterBlacklist>(); InitializeCharacters(); }
//////////////////////////////// string GenerateName() { blacklist = GameObject.FindObjectOfType <CharacterBlacklist>(); for (int i = 0; i < nameBits.Length; i++) { if (nameBits[i] == "A" || nameBits[i] == "E" || nameBits[i] == "I" || nameBits[i] == "O" || nameBits[i] == "U") { vowels.Add(nameBits[i]); } else { consonants.Add(nameBits[i]); } } string newName; newName = consonants[Random.Range(0, consonants.Count)] + vowels[Random.Range(0, vowels.Count)] + consonants[Random.Range(0, consonants.Count)] + consonants[Random.Range(0, consonants.Count)].ToUpper(); if (names.Contains(newName)) { Debug.LogError("retry"); GenerateName(); } else if (blacklist.nameBlacklist.Contains(newName)) { Debug.LogError("cannot contain " + newName); GenerateName(); } else { names.Add(newName); return(newName); } if (names.Contains("MEMM")) { Debug.Log("It's MEMM!"); } return(null); }