예제 #1
0
 static void InitializeLookups()
 {
     if (aliasLookup == null)
     {
         aliasLookup = new Dictionary <string, LocationKey>();
         List <LocationAliases> allAliases = GameSettings.GetSettingsOfType <LocationAliases>();
         for (int i = 0; i < allAliases.Count; i++)
         {
             LocationAliases collection = allAliases[i];
             for (int j = 0; j < collection.aliases.Length; j++)
             {
                 string alias = collection.aliases[j].alias;
                 if (!string.IsNullOrEmpty(alias))
                 {
                     if (aliasLookup.ContainsKey(alias))
                     {
                         Debug.LogError("Multiple Location Aliases: '" + alias + "', using first defined [Scene/Location]: " + aliasLookup[alias].scene + "/" + aliasLookup[alias].name);
                     }
                     else
                     {
                         aliasLookup.Add(alias, collection.aliases[j].key);
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        public static List <string> GetAliasList()
        {
            // during editor, just search by for loop
            if (!Application.isPlaying)
            {
                List <string> r = new List <string>();

                List <LocationAliases> allAliases = GameSettings.GetSettingsOfType <LocationAliases>();
                for (int i = 0; i < allAliases.Count; i++)
                {
                    LocationAliases collection = allAliases[i];
                    for (int j = 0; j < collection.aliases.Length; j++)
                    {
                        string alias = collection.aliases[j].alias;
                        if (!string.IsNullOrEmpty(alias))
                        {
                            if (!r.Contains(alias))
                            {
                                r.Add(alias);
                            }
                        }
                    }
                }

                return(r);
            }
            else
            {
                InitializeLookups();
                return(aliasLookup.Keys.ToList());
            }
        }
예제 #3
0
        public static LocationKey GetLocationKey(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(null);
            }

            // during editor, just search by for loop
            if (!Application.isPlaying)
            {
                List <LocationAliases> allAliases = GameSettings.GetSettingsOfType <LocationAliases>();

                for (int i = 0; i < allAliases.Count; i++)
                {
                    LocationAliases collection = allAliases[i];
                    for (int j = 0; j < collection.aliases.Length; j++)
                    {
                        string cAlias = collection.aliases[j].alias;
                        if (!string.IsNullOrEmpty(cAlias))
                        {
                            if (cAlias == name)
                            {
                                return(collection.aliases[j].key);
                            }
                        }
                    }
                }
            }
            else
            {
                InitializeLookups();
                if (aliasLookup.TryGetValue(name, out LocationKey key))
                {
                    return(key);
                }
            }

            Debug.LogError("Couldnt find Location Alias: " + name);
            return(null);
        }