コード例 #1
0
ファイル: DataObjectInventory.cs プロジェクト: TD6370/TheCell
    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
ファイル: PoolGameObjects.cs プロジェクト: TD6370/TheCell
    public PoolGameObject AddPoolNewTypeObject(string prefabTag, bool isLog = false)
    {
        GameObject newGO = null;

        if (!m_collectionPoolPrefabsStr.ContainsKey(prefabTag))
        {
            prefabTag = TypePoolPrefabs.PoolFloor.ToString();
            Debug.Log("############ AddPoolNewTypeObject Not prefab in collection for prefabTag=" + prefabTag);
        }
        GameObject prefabPoolInst = m_collectionPoolPrefabsStr[prefabTag];

        if (prefabPoolInst == null)
        {
            Debug.Log("####### AddPoolNewTypeObject prefabPoolInst == null " + prefabTag);
        }
        newGO = SaveLoadData.CopyGameObject(prefabPoolInst);

        PoolGameObject poolObj = new PoolGameObject();

        poolObj.Name = "GameObjectPool " + indexPool++;
        poolObj.Tag  = prefabTag;
        poolObj.Init(newGO);
        poolObj.Deactivate();

        //Fix Tile field
        bool isField = false;

        isField = TypePoolPrefabs.PoolFloor.ToString() == prefabTag;
        if (isField)
        {
            //see: GetPrefabField
            ModelNPC.TerraData terrD = new ModelNPC.TerraData()
            {
                ModelView = "Weed"
            };
            //Update texture Object pool Field default
            terrD.UpdateGameObject(newGO);
        }
        var stackPool = new Stack <PoolGameObject>();

        if (!PoolGamesObjectsStack.ContainsKey(prefabTag))
        {
            PoolGamesObjectsStack.Add(prefabTag, stackPool);
        }
        else
        {
            stackPool = PoolGamesObjectsStack[prefabTag];
        }

        //int countInPool = PoolGamesObjectsStack[prefabTag].Count;

        stackPool.Push(poolObj);

        return(poolObj);
    }
コード例 #3
0
    private GameObject GetPrefabFieldFloor(Vector3 pos, string nameFieldNew)
    {
        GameObject resGO;

        resGO = Storage.Pool.InstantiatePool(prefabField, pos, nameFieldNew);
        ModelNPC.TerraData terrD = new ModelNPC.TerraData()
        {
            ModelView = "Weed"
        };
        terrD.UpdateGameObject(resGO);
        //fix alpha field
        resGO.GetComponent <SpriteRenderer>().sortingLayerName = Helper.LayerTerraName;
        return(resGO);
    }
コード例 #4
0
ファイル: DataObjectInventory.cs プロジェクト: TD6370/TheCell
    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));
    }