Пример #1
0
        public ArrayGrid <Color> TextureToColors(string id)
        {
            var texture = Load(id);

            Color[] data = new Color[texture.Width * texture.Height];
            texture.GetData(data);

            var ret = new ArrayGrid <Color>(texture.Width, data);

            return(ret);
        }
Пример #2
0
        public ArrayGrid <T> ExtractBlock(Rectangle block)
        {
            float top    = (float)block.Top;
            float left   = (float)block.Left;
            float right  = (float)block.Right;
            float bottom = (float)block.Bottom;

            top    = Math.Max(0, top);
            left   = Math.Max(0, left);
            right  = Math.Min((int)Size.X, right);
            bottom = Math.Min((int)Size.Y, bottom);

            var ret = new ArrayGrid <T>(new Vector2(right - left, bottom - top));

            foreach (var cell in ret.Points)
            {
                var src = GetFromPoint(cell.Translate(left, top));
                ret.Set(cell, src);
            }

            return(ret);
        }
Пример #3
0
 public TileMaskMap(ArrayGrid <bool> tiles, BorderTileSet tileSet)
 {
     TileFlags = new ArrayGrid <TileMaskValue>(tiles.Columns, tiles.Select(p => p ? TileMaskValue.Filled : TileMaskValue.Empty));
     TileFlags.ReplaceOutOfBoundsTilesWithAdjacent = true;
     TileSet = tileSet;
 }
Пример #4
0
 public ArrayGridPoint(Vector2 position, ArrayGrid <T> grid)
 {
     Grid     = grid;
     Value    = grid.GetFromPoint(position);
     Position = position;
 }