Esempio n. 1
0
        public void Search()
        {
            PrefabInfo current = null;

            UIScrollPanelItem.ItemData selected = null;
            if (scrollPanel.selectedItem != null)
            {
                current = scrollPanel.selectedItem.asset.prefab;
            }

            string text = "";

            Asset.AssetType type = Asset.AssetType.All;

            if (input != null)
            {
                text = input.text;
                type = (Asset.AssetType)typeFilter.selectedIndex;

                if (!FindIt.isRicoEnabled && type >= Asset.AssetType.Rico)
                {
                    type++;
                }
            }

            List <Asset> matches = AssetTagList.instance.Find(text, type);

            scrollPanel.Clear();
            foreach (Asset asset in matches)
            {
                if (asset.prefab != null)
                {
                    UIScrollPanelItem.ItemData data = new UIScrollPanelItem.ItemData();
                    data.name    = asset.title;
                    data.tooltip = Asset.GetLocalizedTooltip(asset.prefab, data.name);

                    data.tooltipBox = GeneratedPanel.GetTooltipBox(TooltipHelper.GetHashCode(data.tooltip));
                    data.asset      = asset;

                    scrollPanel.itemsData.Add(data);

                    if (asset.prefab == current)
                    {
                        selected = data;
                    }
                }
            }

            scrollPanel.DisplayAt(0);
            scrollPanel.selectedItem = selected;

            if (scrollPanel.selectedItem != null)
            {
                FindIt.SelectPrefab(scrollPanel.selectedItem.asset.prefab);
            }
            else
            {
                ToolsModifierControl.SetTool <DefaultTool>();
            }
        }
Esempio n. 2
0
        public Asset[] GetAssets(Asset.AssetType type)
        {
            List <Asset> assets = new List <Asset>();

            for (int i = 0; i < Assets.Count; ++i)
            {
                if (Assets[i].Type == type)
                {
                    assets.Add(Assets[i]);
                }
            }

            return(assets.ToArray());
        }
 public ContainerAsset(string name, Asset.AssetType type)
     : base(name, type)
 {
 }
 public SpawnableAsset(string name, Asset.AssetType type)
     : base(name, type)
 {
 }
Esempio n. 5
0
        public List <Asset> Find(string text, Asset.AssetType filter)
        {
            matches.Clear();

            text = text.ToLower().Trim();

            if (!text.IsNullOrWhiteSpace())
            {
                string[] keywords = Regex.Split(text, @"([^\w]|[_-]|\s)+", RegexOptions.IgnoreCase);

                foreach (Asset asset in assets.Values)
                {
                    asset.RefreshRico();
                    if (asset.prefab != null && (filter == Asset.AssetType.All || asset.assetType == filter))
                    {
                        if (filter == Asset.AssetType.Growable || filter == Asset.AssetType.Rico)
                        {
                            BuildingInfo buildingInfo = asset.prefab as BuildingInfo;

                            // Level
                            ItemClass.Level level = UISearchBox.instance.buildingLevel;
                            if (level != ItemClass.Level.None && buildingInfo.m_class.m_level != level)
                            {
                                continue;
                            }

                            // size
                            Vector2 buildingSize = UISearchBox.instance.buildingSize;
                            if (buildingSize != Vector2.zero && asset.size != buildingSize)
                            {
                                continue;
                            }

                            // zone
                            if (!UIFilterGrowable.instance.IsAllSelected())
                            {
                                UIFilterGrowable.Category category = UIFilterGrowable.GetCategory(buildingInfo.m_class);
                                if (category == UIFilterGrowable.Category.None || !UIFilterGrowable.instance.IsSelected(category))
                                {
                                    continue;
                                }
                            }
                        }
                        else if (filter == Asset.AssetType.Ploppable)
                        {
                            BuildingInfo buildingInfo = asset.prefab as BuildingInfo;

                            if (!UIFilterPloppable.instance.IsAllSelected())
                            {
                                UIFilterPloppable.Category category = UIFilterPloppable.GetCategory(buildingInfo.m_class);
                                if (category == UIFilterPloppable.Category.None || !UIFilterPloppable.instance.IsSelected(category))
                                {
                                    continue;
                                }
                            }
                        }

                        foreach (string keyword in keywords)
                        {
                            if (!keyword.IsNullOrWhiteSpace())
                            {
                                float score = 0;

                                if (!asset.author.IsNullOrWhiteSpace())
                                {
                                    score += 10 * GetScore(keyword, asset.author.ToLower(), null);
                                }

                                if (filter == Asset.AssetType.All && asset.assetType != Asset.AssetType.Invalid)
                                {
                                    score += 10 * GetScore(keyword, asset.assetType.ToString().ToLower(), null);
                                }

                                if (asset.service != ItemClass.Service.None)
                                {
                                    score += 10 * GetScore(keyword, asset.service.ToString().ToLower(), null);
                                }

                                if (asset.subService != ItemClass.SubService.None)
                                {
                                    score += 10 * GetScore(keyword, asset.subService.ToString().ToLower(), null);
                                }

                                if (asset.size != Vector2.zero)
                                {
                                    score += 10 * GetScore(keyword, asset.size.x + "x" + asset.size.y, null);
                                }

                                foreach (string tag in asset.tagsCustom)
                                {
                                    score += 20 * GetScore(keyword, tag, tagsCustomDictionary);
                                }

                                foreach (string tag in asset.tagsTitle)
                                {
                                    score += 5 * GetScore(keyword, tag, tagsTitleDictionary);
                                }

                                foreach (string tag in asset.tagsDesc)
                                {
                                    score += GetScore(keyword, tag, tagsDescDictionary);
                                }

                                if (score > 0)
                                {
                                    asset.score += score;
                                }
                                else
                                {
                                    asset.score = 0;
                                    break;
                                }
                            }
                        }

                        if (asset.score > 0)
                        {
                            matches.Add(asset);
                        }
                    }
                }
                matches = matches.OrderByDescending(s => s.score).ToList();
            }
            else
            {
                foreach (Asset asset in assets.Values)
                {
                    asset.RefreshRico();
                    if (asset.prefab != null && (filter == Asset.AssetType.All || asset.assetType == filter))
                    {
                        if (filter == Asset.AssetType.Growable || filter == Asset.AssetType.Rico)
                        {
                            BuildingInfo buildingInfo = asset.prefab as BuildingInfo;

                            // Level
                            ItemClass.Level level = UISearchBox.instance.buildingLevel;
                            if (level != ItemClass.Level.None && buildingInfo.m_class.m_level != level)
                            {
                                continue;
                            }

                            // size
                            Vector2 buildingSize = UISearchBox.instance.buildingSize;
                            if (buildingSize != Vector2.zero && asset.size != buildingSize)
                            {
                                continue;
                            }

                            // zone
                            if (!UIFilterGrowable.instance.IsAllSelected())
                            {
                                UIFilterGrowable.Category category = UIFilterGrowable.GetCategory(buildingInfo.m_class);
                                if (category == UIFilterGrowable.Category.None || !UIFilterGrowable.instance.IsSelected(category))
                                {
                                    continue;
                                }
                            }
                        }
                        else if (filter == Asset.AssetType.Ploppable)
                        {
                            BuildingInfo buildingInfo = asset.prefab as BuildingInfo;

                            if (!UIFilterPloppable.instance.IsAllSelected())
                            {
                                UIFilterPloppable.Category category = UIFilterPloppable.GetCategory(buildingInfo.m_class);
                                if (category == UIFilterPloppable.Category.None || !UIFilterPloppable.instance.IsSelected(category))
                                {
                                    continue;
                                }
                            }
                        }

                        matches.Add(asset);
                    }
                }
                matches = matches.OrderBy(s => s.title).ToList();
            }

            return(matches);
        }
Esempio n. 6
0
 public ItemAsset(string name, Asset.AssetType type)
     : base(name, type)
 {
 }
Esempio n. 7
0
 public AssetQueueCtrl(Asset.AssetType assetType)
 {
     AssetType    = assetType;
     ReadyLoaders = new List <Asset>();
 }