Beispiel #1
0
        public static UnityEngine.Object Load(ResourceType type, ResourceCategory category, string name, Type returnType)
        {
            string resourcePath = string.Format("{0}/{1}/{2}", type.ToString(), category.ToString(), name);

            UnityEngine.Object resource = Resources.Load(resourcePath, returnType);
            if (resource == null)
            {
                GameLogger.FatalError("ResourceLoader could not find resource {0}", resourcePath);
            }

            return(resource);
        }
Beispiel #2
0
        public static string FindResourceName(int id, ResourceCategory category = ResourceCategory.Id)
        {
            if (resourceClassType == null)
            {
                return(null);
            }
            var categoryClassType = resourceClassType.GetNestedType(category.ToString()); // MQC TODO: Check if optimize perf by caching type for each category is needed?

            if (categoryClassType == null)
            {
                return(null);
            }
            return(Enum.GetName(categoryClassType, id));
        }
Beispiel #3
0
        public static int?FindResourceId(string name, ResourceCategory category = ResourceCategory.Id)
        {
            if (string.IsNullOrEmpty(name) || resourceClassType == null)
            {
                return(null);
            }
            var categoryClassType = resourceClassType.GetNestedType(category.ToString()); // MQC TODO: Check if optimize perf by caching type for each category is needed?

            if (categoryClassType == null)
            {
                return(null);
            }
            var fieldInfo = categoryClassType.GetField(name);

            if (fieldInfo == null)
            {
                return(null);
            }
            return((int)fieldInfo.GetValue(null));
        }
Beispiel #4
0
 public override string GetActionString()
 {
     return("Change Resource Amounts in Category " + resourceCategory.ToString() + " by min " + amountMin.ToString() + " and max " + amountMax.ToString());
 }
Beispiel #5
0
 public override string GetRequiermentString()
 {
     return(resourceAmount.ToString() + " in " + resourceCategory.ToString());
 }
Beispiel #6
0
        public static T[] LoadAll <T>(ResourceType type, ResourceCategory category) where T : UnityEngine.Object
        {
            string resourcePath = string.Format("{0}/{1}", type.ToString(), category.ToString());

            return(Resources.LoadAll <T>(resourcePath));
        }