Exemplo n.º 1
0
 /// <summary>
 /// Get a new copy of an item based on the factory template.  This is necessary so items can be deleted without deleting the entire item from the database
 /// </summary>
 /// <param name="resourceName"></param>
 /// <returns></returns>
 public Item GetNewResource(string resourceName, ItemQuality usedItemQuality = null)
 {
     //Debug.Log(this.GetType().Name + ".GetNewResource(" + resourceName + ")");
     if (!SystemDataFactory.RequestIsEmpty(resourceName))
     {
         string keyName      = SystemDataFactory.PrepareStringForMatch(resourceName);
         Item   itemTemplate = systemDataFactory.GetResource <Item>(keyName);
         if (itemTemplate != null)
         {
             Item returnValue = ScriptableObject.Instantiate(itemTemplate) as Item;
             returnValue.SetupScriptableObjects(systemGameManager);
             returnValue.InitializeNewItem(usedItemQuality);
             return(returnValue);
         }
     }
     return(null);
 }
Exemplo n.º 2
0
        public TDataType GetResource <TDataType>(string resourceName) where TDataType : ResourceProfile
        {
            //Debug.Log(this.GetType().Name + ".GetResource(" + resourceName + ")");
            if (!SystemDataFactory.RequestIsEmpty(resourceName))
            {
                string keyName = SystemDataFactory.PrepareStringForMatch(resourceName);

                /*
                 * foreach (string dictKeyName in factoryData.Keys) {
                 *  Debug.Log("count: " + factoryData.Count + "; " + dictKeyName);
                 * }
                 */
                if (factoryData.ContainsKey(keyName))
                {
                    return(factoryData[keyName] as TDataType);
                }
            }
            return(default(TDataType));
        }