示例#1
0
    public static DataObjectInventory LootObjectToInventory(this ModelNPC.ObjectData targetData, ModelNPC.GameDataAlien alien = null)
    {
        //if(targetData.TypePrefab == SaveLoadData.TypePrefabs.Ground) //Filter: Loot
        if (m_emptyTrgetObjects.ContainsKey(targetData.TypePrefab)) //Filter: Loot
        {
            return(DataObjectInventory.EmptyInventory());
        }

        if (!Enum.IsDefined(typeof(SaveLoadData.TypeInventoryObjects), targetData.TypePrefabName))
        {
            Debug.Log("######## TypePrefabs not exist NameInventopyObject = " + targetData.TypePrefabName);
            return(DataObjectInventory.EmptyInventory());
        }
        int countResource = 1;

        ModelNPC.TerraData terraRes = targetData as ModelNPC.TerraData;
        if (terraRes != null)
        {
            countResource = terraRes.BlockResources;
            if (alien != null)
            {
                terraRes.BlockResources -= alien.WorkPower; // or  WorkPower - is time work
            }
        }
        SaveLoadData.TypeInventoryObjects invObject = (SaveLoadData.TypeInventoryObjects)Enum.Parse(typeof(SaveLoadData.TypeInventoryObjects), targetData.TypePrefabName);
        return(new DataObjectInventory(invObject.ToString(), countResource));
    }
示例#2
0
    public void AddResource(ModelNPC.PortalData portal, SaveLoadData.TypeInventoryObjects invObj, int Count = 1)
    {
        DataObjectInventory inventory = new DataObjectInventory(invObj.ToString(), Count);
        DataObjectInventory existRes  = DataObjectInventory.EmptyInventory();

        //>INV>
        try
        {
            if (portal.Resources == null) //fix null
            {
                portal.Resources = new List <DataObjectInventory>();
            }

            existRes = portal.Resources.Where(p => p.TypeInventoryObject == inventory.TypeInventoryObject).FirstOrDefault();
        }
        catch (System.Exception ex)
        {
            Debug.Log(Storage.EventsUI.ListLogAdd = string.Format("###### AddResource error: {0}", ex));
        }
        if (existRes == null)
        {
            portal.Resources.Add(new DataObjectInventory(inventory));
        }
        else
        {
            existRes.Count += inventory.Count;
        }
    }
示例#3
0
    public static DataObjectInventory GetInventoryObject(this ModelNPC.ObjectData targetData)
    {
        if (!Enum.IsDefined(typeof(SaveLoadData.TypeInventoryObjects), targetData.TypePrefabName))
        {
            Debug.Log("######## TypePrefabs not exist NameInventopyObject = " + targetData.TypePrefabName);
            return(new DataObjectInventory());
        }

        int countResource = 1;

        ModelNPC.TerraData terraRes = targetData as ModelNPC.TerraData;
        if (terraRes != null)
        {
            countResource = terraRes.BlockResources;
        }
        SaveLoadData.TypeInventoryObjects invObject = (SaveLoadData.TypeInventoryObjects)Enum.Parse(typeof(SaveLoadData.TypeInventoryObjects), targetData.TypePrefabName);
        return(new DataObjectInventory(invObject.ToString(), countResource));
    }
示例#4
0
 public static bool IsFlore(this SaveLoadData.TypeInventoryObjects model)
 {
     return(Storage.GridData.NamesPrefabFlore.Contains(model.ToString()));
 }