Ejemplo n.º 1
0
        IEnumerator GenerateList()
        {
            Loading.SetActive(true);
            Layout.enabled     = true;
            SizeFitter.enabled = true;

            int GenerateCount = 0;

            for (int i = 0; i < FoundUnits.Count; i++)
            {
                GetGamedataFile.UnitDB UnitDB = GetGamedataFile.LoadUnitBlueprintPreview(FoundUnits[i]);

                GameObject NewButton = Instantiate(Prefab) as GameObject;
                NewButton.transform.SetParent(Pivot, false);
                ResourceObject NewResObject = NewButton.GetComponent <ResourceObject>();
                NewResObject.RawImages[0].texture = IconBackgrounds[UnitDB.Icon];
                NewResObject.RawImages[1].texture = GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/" + UnitDB.CodeName + "_icon.dds", false, true, true);
                if (NewResObject.RawImages[1].texture == Texture2D.whiteTexture)
                {
                    NewResObject.RawImages[1].enabled = false;
                }
                NewResObject.InstanceId          = i;
                NewResObject.NameField.text      = UnitDB.CodeName;
                NewResObject.CustomTexts[0].text = SortDescription(UnitDB);
                NewResObject.CustomTexts[1].text = UnitDB.Name;
                NewButton.SetActive(CheckSorting(UnitDB));

                LoadedButtons.Add(NewResObject);
                LoadedUnits.Add(UnitDB);

                GenerateCount++;

                if (GenerateCount >= 7)
                {
                    GenerateCount = 0;
                    yield return(null);
                }
            }

            IsGenerated = true;

            yield return(null);

            Loading.SetActive(false);
            Layout.enabled     = false;
            SizeFitter.enabled = false;
            GeneratingList     = null;
            SortUnits();
        }
Ejemplo n.º 2
0
        public void OnDropUnit()
        {
            if (ResourceBrowser.DragedObject == null || ResourceBrowser.DragedObject.ContentType != ResourceObject.ContentTypes.Unit)
            {
                return;
            }

            SelectedUnit            = UnitBrowser.GetDragUnit();
            SelectedUnitSource      = new SaveLua.Army.Unit();
            SelectedUnitSource.Name = SelectedUnit.CodeName;
            SelectedUnitSource.type = SelectedUnit.CodeName;

            UnitTitle.text = SelectedUnit.CodeName;
            UnitDesc.text  = UnitBrowser.SortDescription(SelectedUnit);

            UnitBg.texture   = UnitBrowser.IconBackgrounds[SelectedUnit.Icon];
            UnitIcon.texture = UnitBrowser.GetDragUnitIcon();
            UnitIcon.enabled = UnitIcon.texture != Texture2D.whiteTexture;
        }
Ejemplo n.º 3
0
        bool CheckSorting(GetGamedataFile.UnitDB UnitDB)
        {
            bool FactionCorrect = false;

            switch (Faction.value)
            {
            case 0:
                FactionCorrect = true;
                break;

            case 1:
                FactionCorrect = UnitDB.FactionName == "UEF";
                break;

            case 2:
                FactionCorrect = UnitDB.FactionName == "Aeon";
                break;

            case 3:
                FactionCorrect = UnitDB.FactionName == "Cybran";
                break;

            case 4:
                FactionCorrect = UnitDB.FactionName == "Seraphim";
                break;

            case 5:
                FactionCorrect = UnitDB.FactionName != "UEF" && UnitDB.FactionName != "Aeon" && UnitDB.FactionName != "Cybran" && UnitDB.FactionName != "Seraphim";
                break;
            }

            if (!FactionCorrect)
            {
                return(false);
            }


            // UnitDB categories
            // https://github.com/FAForever/UnitDB/blob/master/res/scripts/functions.php#L15
            //

            for (int i = 0; i < SearchTags.Length; i++)
            {
                string SearchValue = SearchTags[i].ToUpper();
                switch (SearchValue)
                {
                // Category
                case "COMMAND":
                    if (UnitDB.Category != "Command")
                    {
                        return(false);
                    }
                    break;

                case "DEFENSE":
                    if (UnitDB.Category != "Defense")
                    {
                        return(false);
                    }
                    break;

                case "STRATEGIC":
                    if (UnitDB.Category != "Strategic")
                    {
                        return(false);
                    }
                    break;

                case "UTILITY":
                    if (UnitDB.Category != "Utility")
                    {
                        return(false);
                    }
                    break;

                case "SHIP":
                    if (UnitDB.Category != "Ship")
                    {
                        return(false);
                    }
                    break;

                case "ECONOMY":
                    if (UnitDB.Category != "Economy")
                    {
                        return(false);
                    }
                    break;

                case "INTELLIGENCE":
                    if (UnitDB.Category != "Intelligence")
                    {
                        return(false);
                    }
                    break;

                //TechLevel
                case "T1":
                case "TECH1":
                    if (UnitDB.TechLevel != "TECH1")
                    {
                        return(false);
                    }
                    break;

                case "T2":
                case "TECH2":
                    if (UnitDB.TechLevel != "TECH2")
                    {
                        return(false);
                    }
                    break;

                case "T3":
                case "TECH3":
                    if (UnitDB.TechLevel != "TECH3")
                    {
                        return(false);
                    }
                    break;

                case "T4":
                case "TECH4":
                    if (UnitDB.TechLevel != "EXPERIMENTAL")
                    {
                        return(false);
                    }
                    break;

                // Tags
                case "EXPERIMENTAL":
                case "EXP":
                    if (!UnitDB.CategoriesHash.Contains("EXPERIMENTAL"))
                    {
                        return(false);
                    }
                    break;

                case "LAND":
                    if (!UnitDB.CategoriesHash.Contains("LAND"))
                    {
                        return(false);
                    }
                    break;

                case "AIR":
                    if (!UnitDB.CategoriesHash.Contains("AIR"))
                    {
                        return(false);
                    }
                    break;

                case "NAVAL":
                    if (!UnitDB.CategoriesHash.Contains("NAVAL"))
                    {
                        return(false);
                    }
                    break;

                case "CIVILIAN":
                    if (!UnitDB.CategoriesHash.Contains("CIVILIAN"))
                    {
                        return(false);
                    }
                    break;

                case "MOBILE":
                    if (!UnitDB.CategoriesHash.Contains("MOBILE"))
                    {
                        return(false);
                    }
                    break;

                case "STRUCTURE":
                case "BUILDING":
                    if (!UnitDB.CategoriesHash.Contains("STRUCTURE"))
                    {
                        return(false);
                    }
                    break;

                case "CONSTRUCTION":
                    if (!UnitDB.CategoriesHash.Contains("CONSTRUCTION"))
                    {
                        return(false);
                    }
                    break;

                case "FACTORY":
                    if (!UnitDB.CategoriesHash.Contains("FACTORY"))
                    {
                        return(false);
                    }
                    break;

                case "PRODUCTSC1":
                case "SC1":
                    if (!UnitDB.CategoriesHash.Contains("PRODUCTSC1"))
                    {
                        return(false);
                    }
                    break;

                case "BUILTBYTIER1ENGINEER":
                    if (!UnitDB.CategoriesHash.Contains("BUILTBYTIER1ENGINEER"))
                    {
                        return(false);
                    }
                    break;

                case "BUILTBYTIER2ENGINEER":
                    if (!UnitDB.CategoriesHash.Contains("BUILTBYTIER2ENGINEER"))
                    {
                        return(false);
                    }
                    break;

                case "BUILTBYTIER3ENGINEER":
                    if (!UnitDB.CategoriesHash.Contains("BUILTBYTIER3ENGINEER"))
                    {
                        return(false);
                    }
                    break;

                case "BUILTBYCOMMANDER":
                    if (!UnitDB.CategoriesHash.Contains("BUILTBYTIER3ENGINEER"))
                    {
                        return(false);
                    }
                    break;

                case "DIRECTFIRE":
                    if (!UnitDB.CategoriesHash.Contains("DIRECTFIRE"))
                    {
                        return(false);
                    }
                    break;

                case "INDIRECTFIRE":
                    if (!UnitDB.CategoriesHash.Contains("INDIRECTFIRE"))
                    {
                        return(false);
                    }
                    break;

                case "ARTILLERY":
                    if (!UnitDB.CategoriesHash.Contains("ARTILLERY"))
                    {
                        return(false);
                    }
                    break;

                case "ANTIAIR":
                    if (!UnitDB.CategoriesHash.Contains("ANTIAIR"))
                    {
                        return(false);
                    }
                    break;

                case "ANTISUB":
                    if (!UnitDB.CategoriesHash.Contains("ANTISUB"))
                    {
                        return(false);
                    }
                    break;

                case "RADAR":
                    if (!UnitDB.CategoriesHash.Contains("RADAR"))
                    {
                        return(false);
                    }
                    break;

                case "SONAR":
                    if (!UnitDB.CategoriesHash.Contains("SONAR"))
                    {
                        return(false);
                    }
                    break;

                case "PLAYABLE":
                case "MULTIPLAYER":
                    if (UnitDB.CategoriesHash.Contains("OPERATION") || UnitDB.CategoriesHash.Contains("CIVILIAN") || UnitDB.CategoriesHash.Contains("INSIGNIFICANTUNIT"))
                    {
                        return(false);
                    }
                    break;

                case "Wall":
                    if (!UnitDB.CategoriesHash.Contains("WALL") && !UnitDB.CategoriesHash.Contains("AIRSTAGINGPLATFORM") && !UnitDB.CategoriesHash.Contains("ORBITALSYSTEM"))
                    {
                        return(false);
                    }
                    break;
                }
            }

            return(FactionCorrect);
        }
Ejemplo n.º 4
0
 public static string SortDescription(GetGamedataFile.UnitDB UnitDB)
 {
     return(UnitDB.Category + "\n" + UnitDB.TechLevel);
 }