Exemplo n.º 1
0
    public bool AddConstructInGridData(string nameField, DataTile itemTile,
                                       PaletteMapController.SelCheckOptDel p_TypeModeOptStartDelete = PaletteMapController.SelCheckOptDel.None,
                                       PaletteMapController.SelCheckOptDel p_TypeModeOptStartCheck  = PaletteMapController.SelCheckOptDel.None)
    {
        TypePrefabs prefabName        = TypePrefabs.PrefabField;
        string      personTextureName = "";

        if (itemTile == null)
        {
            Debug.Log("####### AddConstructInGridData  itemTile == null");
            return(false);
        }

        //ArgumentException: The requested value 'SpriteBossAlien(Clone)' was not found.

        TypesStructure structType = (TypesStructure)Enum.Parse(typeof(TypesStructure), itemTile.Tag);;

        if (structType == TypesStructure.Terra)
        {
            prefabName = TypePrefabs.PrefabField;
        }
        if (structType == TypesStructure.Person)
        {
            personTextureName = itemTile.Name.ClearClone();
            prefabName        = TypePrefabs.PrefabBoss;
        }
        if (structType == TypesStructure.Prefab)
        {
            //ArgumentException: The requested value 'SpriteBossAlien(Clone)' was not found.
            prefabName = (TypePrefabs)Enum.Parse(typeof(TypePrefabs), itemTile.Name);
        }

        Vector2 posStruct = Helper.GetPositByField(nameField);
        int     x         = (int)posStruct.x;
        int     y         = (int)posStruct.y;
        int     _y        = y * (-1);
        Vector3 pos       = new Vector3(x, _y, 0) * Spacing;

        pos.z = -1;
        if (prefabName == TypePrefabs.PrefabUfo)
        {
            pos.z = -2;
        }

        string nameObject = Helper.CreateName(prefabName.ToString(), nameField, "-1");// prefabName.ToString() + "_" + nameFiled + "_" + i;

        ModelNPC.ObjectData objDataSave = BilderGameDataObjects.BildObjectData(prefabName);
        objDataSave.CreateID(nameObject);
        objDataSave.SetNameObject(nameObject, true);

        if (PoolGameObjects.IsUseTypePoolPrefabs)
        {
            objDataSave.ModelView = itemTile.Name;
        }
        else
        {
            if (structType == TypesStructure.Terra)
            {
                var objTerra = objDataSave as ModelNPC.TerraData;
                if (objTerra == null)
                {
                    Debug.Log("####### AddConstructInGridData: structType is TypesStructure.Terra   objDataSave Not is ModelNPC.TerraData !!!!");
                    return(false);
                }
                objTerra.ModelView = itemTile.Name;
            }
            if (structType == TypesStructure.TerraPrefab)
            {
                var objTerraPrefab = objDataSave as ModelNPC.WallData;
                if (objTerraPrefab == null)
                {
                    Debug.Log("####### AddConstructInGridData: structType is TypesStructure.TerraPrefab   objDataSave Not is ModelNPC.TerraData !!!!");
                    return(false);
                }
                objTerraPrefab.ModelView = itemTile.Name;
            }
        }

        if (structType == TypesStructure.Person)
        {
            var objPerson = objDataSave as ModelNPC.GameDataBoss;
            if (objPerson == null)
            {
                Debug.Log("####### AddConstructInGridData: structType is TypesStructure.Terra   objDataSave Not is ModelNPC.TerraData !!!!");
                return(false);
            }
        }

        bool res = Storage.Data.AddDataObjectInGrid(objDataSave, nameField, "CreateDataGamesObjectsWorld",
                                                    p_TypeModeOptStartDelete, p_TypeModeOptStartCheck);


        objDataSave.SetPosition(pos);
        return(res);
    }
Exemplo n.º 2
0
    private string GetTypeByName(string namePrefab)
    {
        if (PoolGameObjects.IsUseTypePoolPrefabs)
        {
            Debug.Log("############### IsUseTypePoolPrefabs - LEGACY CODE  - GetTypeByName");
            return("");
        }

        string resType = "";

        TypePrefabs prefabType = TypePrefabs.PrefabField;

        try
        {
            //fix new pool prefabs type
            bool isLegacyType = Enum.IsDefined(typeof(TypePrefabsLegacy), namePrefab);
            if (isLegacyType)
            {
                prefabType = (TypePrefabs)Enum.Parse(typeof(TypePrefabs), namePrefab);
            }
            else
            {
                prefabType = TypePrefabs.PrefabField;
            }
        }
        catch (Exception x)
        {
            Debug.Log("######## (SaveLoadData.GetTypeByName) ERROR TYPE POOL TO TYPE PREFAB : " + x.Message);
        }

        switch (prefabType)
        {
        case TypePrefabs.PrefabRock:
            resType = PrefabRock.tag;
            break;

        case TypePrefabs.PrefabVood:
            resType = PrefabVood.tag;
            break;

        case TypePrefabs.PrefabUfo:
            resType = PrefabUfo.tag;
            break;

        case TypePrefabs.PrefabBoss:
            resType = PrefabBoss.tag;
            break;

        case TypePrefabs.PrefabWallRock:
            resType = PrefabWallRock.tag;
            break;

        case TypePrefabs.PrefabWallWood:
            resType = PrefabWallWood.tag;
            break;

        case TypePrefabs.PrefabElka:
            resType = PrefabElka.tag;
            //TypePrefabs.PrefabElka.ToString();
            break;

        case TypePrefabs.PrefabField:
            resType = PrefabField.tag;
            break;

        case TypePrefabs.PrefabPerson:
            resType = PrefabField.tag;
            break;

        case TypePrefabs.PrefabFlore:
            resType = PrefabField.tag;
            break;

        default:
            Debug.Log("!!! FindPrefabHieracly no type : " + prefabType.ToString());
            break;
        }
        return(resType);
    }