Beispiel #1
0
    public void DrawWholeRegion(Region region)
    {
        if (region == null)
        {
            Debug.LogError("Region is null, cannot set pixels!");
            return;
        }

        if (region.Index == -1)
        {
            Debug.LogError("Region index is -1, meaning that it is invalid or uninitialized. Cannot set pixels!");
            return;
        }

        int size   = Region.SQR_SIZE;
        int offset = size * region.Index;
        int subOff = 0;

        for (int x = 0; x < Region.SIZE; x++)
        {
            for (int y = 0; y < Region.SIZE; y++)
            {
                subOff = x + y * Region.SIZE;
                var id = TileIDs[offset + subOff];
                region.SetTilePixels(x, y, id == 0 ? null : TileData.Get(id).GetPixels(TileVariations[offset + subOff]));
            }
        }
    }
Beispiel #2
0
    public void DrawTile(int tileX, int tileY)
    {
        if (TileInBounds(tileX, tileY))
        {
            int ri = GetRegionIndex(tileX / Region.SIZE, tileY / Region.SIZE);
            if (IsRegionLoaded(ri))
            {
                var r      = GetSpawnedRegion(ri);
                int ox     = tileX - (r.X * Region.SIZE);
                int oy     = tileY - (r.Y * Region.SIZE);
                int ti     = GetTileIndex(tileX, tileY);
                var tileID = TileIDs[ti];

                if (tileID != 0)
                {
                    r.SetTilePixels(ox, oy, TileData.Get(tileID).GetPixels(TileVariations[ti]));
                }
                else
                {
                    r.SetTilePixels(ox, oy, null);
                }
            }
        }
    }