Ejemplo n.º 1
0
    public static void Draw(Texture2D text, Vector3Int center)
    {
        TileDatas wall = DataMap.GetWallTiles();
        TileDatas back = DataMap.GetBackTiles();

        if (tilemapCR == null)
        {
            Debug.Log("Null CR");
        }
        if (tilemapN == null)
        {
            Debug.Log("Null N");
        }
        Vector3Int StartPosition = center - new Vector3Int(text.width / 2, text.height / 2, 0) - new Vector3Int(1, 1, 0);

        for (int x = StartPosition.x; x < StartPosition.x + text.width + 2; x++)
        {
            for (int y = StartPosition.y; y < StartPosition.y + text.height + 2; y++)
            {
                Vector3Int pos = new Vector3Int(x, y, 0);
                if (x == StartPosition.x ||
                    x == StartPosition.x + text.width + 1 ||
                    y == StartPosition.y ||
                    y == StartPosition.y + text.height + 1)
                {
                    if (wall != null)
                    {
                        tilemapCR.SetTile(pos, wall.GetTile());
                    }
                }
                else
                {
                    Vector2Int pixelVector = (Vector2Int)(pos - StartPosition) - Vector2Int.one;
                    TileDatas  tiles       = DataMap.GetBarrierTiles(text.GetPixel(pixelVector.x, pixelVector.y));
                    if (tiles != null)
                    {
                        tilemapCR.SetTile(pos, tiles.GetTile());
                    }
                    if (back != null)
                    {
                        tilemapN.SetTile(pos, back.GetTile());
                    }
                }
            }
        }
    }