예제 #1
0
        /// <summary>
        /// Gets the list of categories selected through the dropdown
        /// </summary>
        /// <returns>The selected categories list.</returns>
        /// <param name="selectedCategories">Cat.</param>
        private List <LocationPrefabCategories> GetSelectedCategoriesList(LocationPrefabCategories selectedCategories)
        {
            List <LocationPrefabCategories> containingCategories = new List <LocationPrefabCategories>();

            Array eligibleValues = Enum.GetValues(typeof(LocationPrefabCategories));

            if (selectedCategories == LocationPrefabCategories.None)
            {
                return(containingCategories);
            }

            //For any other categories other than None and Any
            foreach (object value in eligibleValues)
            {
                LocationPrefabCategories category = (LocationPrefabCategories)value;

                if (category == LocationPrefabCategories.AnyCategory || category == LocationPrefabCategories.None)
                {
                    continue;
                }

                if ((category & selectedCategories) != 0)                 //to check if category is contained in cat
                {
                    containingCategories.Add(category);
                }
            }

            return(containingCategories);
        }
예제 #2
0
        /// <summary>
        /// Places the prefab for supplied categories.
        /// </summary>
        /// <param name="prefab">GameObject Prefab</param>
        /// <param name="categories"><see cref="LocationPrefabCategories"/> For more than one category separate them by pipe
        /// (eg: LocationPrefabCategories.Food | LocationPrefabCategories.Nightlife)</param>
        /// <param name="density">Density controls the number of POIs on the map.(Integer value between 1 and 30)</param>
        /// <param name="locationItemName">Name of this location prefab item for future reference</param>
        /// <param name="scaleDownWithWorld">Should the prefab scale up/down along with the map game object?</param>
        public virtual void SpawnPrefabByCategory(GameObject prefab,
                                                  LocationPrefabCategories categories = LocationPrefabCategories.AnyCategory,
                                                  int density             = 30, Action <List <GameObject> > callback = null,
                                                  bool scaleDownWithWorld = true,
                                                  string locationItemName = "New Location")
        {
            PrefabItemOptions item = new PrefabItemOptions()
            {
                findByType         = LocationPrefabFindBy.MapboxCategory,
                categories         = categories,
                density            = density,
                prefabItemName     = locationItemName,
                spawnPrefabOptions = new SpawnPrefabOptions()
                {
                    prefab             = prefab,
                    scaleDownWithWorld = scaleDownWithWorld
                }
            };

            if (callback != null)
            {
                item.OnAllPrefabsInstantiated += callback;
            }

            CreatePrefabLayer(item);
        }
        /// <summary>
        /// Gets the maki tags list from a <see cref="LocationPrefabCategories"/> category
        /// </summary>
        /// <returns>The list of maki tags from supplied category.</returns>
        /// <param name="category"><see cref="LocationPrefabCategories"/></param>
        public static List <string> GetMakiListFromCategory(LocationPrefabCategories category)
        {
            List <string> returnList = new List <string>();

            CategoriesToMakiDictionary.TryGetValue(category, out returnList);

            return(returnList);
        }