Esempio n. 1
0
        void CreateNewCategory(ProductionCategory categoryToClone = null)
        {
            if (!AssetDatabase.IsValidFolder("Assets/Resources"))
            {
                AssetDatabase.CreateFolder("Assets", "Resources");
            }

            if (!AssetDatabase.IsValidFolder("Assets/Resources/Data"))
            {
                AssetDatabase.CreateFolder("Assets/Resources", "Data");
            }

            if (!AssetDatabase.IsValidFolder("Assets/Resources/Data/ProductionCategories"))
            {
                AssetDatabase.CreateFolder("Assets/Resources/Data", "ProductionCategories");
            }

            var category = ScriptableObject.CreateInstance(typeof(ProductionCategory)) as ProductionCategory;

            category.textId = "New Category";

            if (categoryToClone)
            {
                category         = Instantiate(categoryToClone);
                category.textId += "_Clone";
            }

            AssetDatabase.CreateAsset(category, "Assets/Resources/Data/ProductionCategories/Category" + (loadedCategories.Count + 1) + "_" + category.textId + ".asset");

            LoadCategories();
            SelectCategory(category);
        }
Esempio n. 2
0
 public void SelectCategory(ProductionCategory category)
 {
     for (int i = 0; i < loadedCategories.Count; i++)
     {
         if (category == loadedCategories[i])
         {
             selectedDataId = i;
         }
     }
 }
Esempio n. 3
0
        public List <Production> GetProductionBuildingsByCategory(ProductionCategory category)
        {
            var resultList = new List <Production>();

            for (int i = 0; i < playerProductionBuildings.Count; i++)
            {
                if (playerProductionBuildings[i] != null && playerProductionBuildings[i].GetProductionCategory == category)
                {
                    resultList.Add(playerProductionBuildings[i]);
                }
            }

            return(resultList);
        }
        void Start()
        {
            if (selfUnit.data.productionCategories.Count <= categoryId)
            {
                Debug.LogWarning("[Production module] Your unit " + name + " have incorrectly setted up Production categories.");
                enabled = false;
                return;
            }

            productionCategory = selfUnit.data.productionCategories[categoryId];

            if (productionModuleSpawned != null)
            {
                productionModuleSpawned.Invoke(this);
            }
        }
Esempio n. 5
0
 public bool IsHaveProductionOfCategory(ProductionCategory category)
 {
     return(GetProductionBuildingsByCategory(category).Count > 0);
 }