Ejemplo n.º 1
0
    public void SetPreviewZoneSingle(MapSegmentPaletteSelection selection, Point startPoint)
    {
        List <Vector3> vertices = new List <Vector3>();
        List <Vector2> uvs      = new List <Vector2>();
        List <int>     tris     = new List <int>();
        List <Vector3> normals  = new List <Vector3>();
        int            index    = 0;

        var scaledOffset = GetScaledOffset(startPoint, MapSegment.GridTileSize);

        for (int y = 0; y < selection.Height; y++)
        {
            for (int x = 0; x < selection.Width; x++)
            {
                if (MapSegment.ValidateBounds(x, y, startPoint))
                {
                    // Adjust the y value as its draw in the opposite direction (Start in the top left corner)
                    var adjustedY = (selection.Height - y) - 1;
                    AddVertices(scaledOffset, x, -y, vertices, MapSegment.GridTileSize);
                    AddUvs(selection.GetTileType(x, adjustedY), uvs, MapSegment.CurrentLayer.TileSetLayer);
                    index = AddTris(index, tris);
                    AddNormals(normals);
                }
            }
        }

        UpdateMesh(vertices, uvs, tris, normals);
    }
Ejemplo n.º 2
0
    public void SetPreviewZoneBlock(MapSegmentPaletteSelection selection, Point startPoint, Point endPoint)
    {
        List <Vector3> vertices = new List <Vector3>();
        List <Vector2> uvs      = new List <Vector2>();
        List <int>     tris     = new List <int>();
        List <Vector3> normals  = new List <Vector3>();
        int            index    = 0;

        var start = new Point(Mathf.Min(startPoint.X, endPoint.X), Mathf.Min(startPoint.Y, endPoint.Y));
        var end   = new Point(Mathf.Max(startPoint.X, endPoint.X), Mathf.Max(startPoint.Y, endPoint.Y));

        // Some of the points are not on the mapsegment and this will look really weird if its allowed
        if (!MapSegment.ValidateBounds(start) || !MapSegment.ValidateBounds(end))
        {
            return;
        }

        var scaledOffset = Vector3.zero;

        for (int y = start.Y; y <= end.Y; y++)
        {
            for (int x = start.X; x <= end.X; x++)
            {
                AddVertices(scaledOffset, x, y, vertices, MapSegment.GridTileSize);
                AddUvs(selection.GetSingleSelecttion(), uvs, MapSegment.CurrentLayer.TileSetLayer);
                index = AddTris(index, tris);
                AddNormals(normals);
            }
        }

        UpdateMesh(vertices, uvs, tris, normals);
    }
Ejemplo n.º 3
0
    public void Paint(Point point, MapSegmentPaletteSelection selection, Vector2[] uvs)
    {
        if (CurrentLayer == null)
        {
            return;
        }

        CurrentLayer.Paint(point, selection, uvs);
    }
Ejemplo n.º 4
0
    public void Paint(Point point, MapSegmentPaletteSelection selection, Vector2[] uvs)
    {
        for (int y = 0; y < selection.Height; y++)
        {
            for (int x = 0; x < selection.Width; x++)
            {
                if (MapSegment.ValidateBounds(x, y, point))
                {
                    var currentX = point.X + x;
                    var currentY = point.Y - y;

                    // The tiles are counted from down to up in the inspector, so this needs to be inverted
                    var tileY = (selection.Height - 1) - y;

                    var tileType = selection.GetTileType(x, tileY);
                    var tile     = TileSetLayer.Tiles[tileType];

                    SetTileTypeToTile(currentX, currentY, tile, tileType, MapSegment, uvs);
                }
            }
        }
    }
Ejemplo n.º 5
0
    public void SetPreviewZoneBucket(MapSegmentPaletteSelection selection, List <Point> tilePoints)
    {
        var tileType = selection.GetSingleSelecttion();

        List <Vector3> vertices = new List <Vector3>();
        List <Vector2> uvs      = new List <Vector2>();
        List <int>     tris     = new List <int>();
        List <Vector3> normals  = new List <Vector3>();
        int            index    = 0;

        var scaledOffset = Vector3.zero;

        foreach (var tilePoint in tilePoints)
        {
            AddVertices(scaledOffset, tilePoint.X, tilePoint.Y, vertices, MapSegment.GridTileSize);
            AddUvs(tileType, uvs, MapSegment.CurrentLayer.TileSetLayer);
            index = AddTris(index, tris);
            AddNormals(normals);
        }

        UpdateMesh(vertices, uvs, tris, normals);
    }