Exemplo n.º 1
0
 public MapTile(Int32 level, Int32 row, Int32 column, Tile tile)
 {
     Level = level;
     Row = row;
     Column = column;
     Tile = tile;
 }
Exemplo n.º 2
0
        private void ConstructTiles(OriginalImage source, TileType tileType)
        {
            Tiles = new ObservableCollection<Tile>();

            //break it down into x-number pixel square tiles
            for (var tileRow = 0; tileRow < source.Height / Constants.TILE_PIXELS; tileRow++)
            {
                for (var tileColumn = 0; tileColumn < Constants.UNMANAGED_TILE_PIXEL_WIDTH / Constants.TILE_PIXELS; tileColumn++)
                {
                    //we want to go one frame at a time
                    var tile = new Tile() { Type = tileType };
                    for (var frame = 0; frame * Constants.UNMANAGED_TILE_PIXEL_WIDTH < source.Width; frame++)
                    {
                        var tileFrame = new TileFrame();
                        var newBytes = new List<Byte>();
                        for (var row = 0; row < Constants.TILE_PIXELS; row++)
                        {
                            //for each row of this tile, grab the pixels from imagebytes
                            var totalRowOffset = tileRow * Constants.TILE_PIXELS + row;
                            var totalColumnOffset = Constants.UNMANAGED_TILE_PIXEL_WIDTH * frame + tileColumn * Constants.TILE_PIXELS;
                            var offset = source.CalculateImageByteArrayOffset(totalRowOffset, totalColumnOffset);
                            newBytes.AddRange(source.ImageBytes.Skip(offset).Take(4 * Constants.TILE_PIXELS)); //4 bytes per tile
                        }
                        tileFrame.SetSource(Constants.TILE_PIXELS, Constants.TILE_PIXELS, newBytes.ToArray());
                        tile.Frames.Add(tileFrame);
                    }
                    Tiles.Add(tile);
                }
            }
        }
Exemplo n.º 3
0
        public void LayTileOver(Tile tile)
        {
            if (Frames.Count < tile.Frames.Count)
            {
                //the base tile isn't animated, but the layover is
                //we need to clone the base tile frames
                while (Frames.Count != tile.Frames.Count)
                {
                    Frames.Add(Frames[0].Clone());
                }
            }

            //the base tile has the same or more frames than the layover
            for (Int32 frameIndex = 0; frameIndex < Frames.Count; frameIndex++)
            {
                Frames[frameIndex].LayFrameOver(tile.Frames[frameIndex % tile.Frames.Count]);
            }

            //also, overwrite the navigation modes, so whatever is on 'top' wins
            NavigationModes = tile.NavigationModes;
        }
Exemplo n.º 4
0
        public Tile Clone()
        {
            Tile clone = new Tile
            {
                Tags = new ObservableCollection<String>(Tags),
                NavigationModes = new ObservableCollection<NavigationMode>(NavigationModes),
                Frames = new ObservableCollection<TileFrame>(Frames.Select(x => x.Clone())),
                Id = Id
            };

            return clone;
        }