Esempio n. 1
0
    public void GenerateColors()
    {
        backgroundTileSets = new GameObject[][] {
            background1Tiles,
            background2Tiles,
            background3Tiles,
            foreground1Tiles
        };
        TilemapSet = new Tilemap[] {
            GameObject.Find("Tilemap_Background1").GetComponent <Tilemap>(),
            GameObject.Find("Tilemap_Background2").GetComponent <Tilemap>(),
            GameObject.Find("Tilemap_Background3").GetComponent <Tilemap>(),
            GameObject.Find("Tilemap_Foreground").GetComponent <Tilemap>()
        };
        customTileSets = new gmMapTile[backgroundTileSets.Length][];
        for (int iBuild = 0; iBuild < backgroundTileSets.Length; iBuild++)
        {
            customTileSets[iBuild] = new gmMapTile[(backgroundTileSets[iBuild].Length)];
            int iCtr = 0;
            foreach (GameObject tilePrefab in backgroundTileSets[iBuild])
            {
                gmMapTile tempTile = ScriptableObject.CreateInstance <gmMapTile>();
                tempTile.prefabObject        = tilePrefab;
                customTileSets[iBuild][iCtr] = tempTile;
                iCtr++;
            }
        }
        colors = new PrefabColors[prefabs.Length];
        int iPFC = 0;

        foreach (GameObject tempPF in prefabs)
        {
            PrefabColors tempPFC = new PrefabColors();
            tempPFC.prefab         = tempPF;
            tempPFC.color          = tempPFC.prefab.GetComponent <SpriteRenderer>().color;
            tempPFC.tileArrayIndex = iPFC;
            colors[iPFC]           = tempPFC;
            //Debug.LogError("color="+tempPFC.color.r+","+tempPFC.color.g+","+tempPFC.color.b);
            iPFC++;
        }
    }
Esempio n. 2
0
    void stageSetup()
    {
        stageHolder          = new GameObject("Stage").transform;
        tileMapContainerGrid = GameObject.Find("TileMapContainerGrid");
        tileMap_Background1  = GameObject.Find("TileMap_Background1").GetComponent <Tilemap>();      //

        gmMapTile[] gmMapTileArray = new gmMapTile[background1Tiles.Length];
        for (int iG = 0; iG < background1Tiles.Length; iG++)
        {
            gmMapTile newTile = (gmMapTile)ScriptableObject.CreateInstance("gmMapTile");
            newTile.prefabObject = background1Tiles[iG];
            gmMapTileArray[iG]   = newTile;
        }

        for (int iY = 0; iY < 8; iY++)
        {
            for (int iX = 0; iX < 8; iX++)
            {
                GameObject tempObject0 = background1Tiles[(levelData0[iY, iX])];

                gmMapTile tempTile = gmMapTileArray[(levelData0[iY, iX])];
                if (tempTile == null)
                {
                    Debug.LogError("Wha?");
                }
                if (tileMap_Background1 == null)
                {
                    Debug.LogError("Uh?");
                }
                tileMap_Background1.SetTile(new Vector3Int(iX, 8 - iY, 0), tempTile);

                /*
                 * GameObject instance = Instantiate(tempObject0, new Vector3(iX,8f-iY,0f), Quaternion.identity) as GameObject;
                 * instance.transform.SetParent(stageHolder);
                 */
            }
        }
    }