Ejemplo n.º 1
0
 public ChunkViewModel(RegionFileViewModel region, int x, int y)
 {
     this.Region = region;
     this.X      = x;
     this.Y      = y;
     this.Name   = x + " / " + y;
 }
Ejemplo n.º 2
0
        private List <RegionFileViewModel> getAllRegionfiles(Dictionary <UInt32, byte[]> tiles)
        {
            var regions = new List <RegionFileViewModel>();

            int regionSize = 512 / 16;

            foreach (var tile in tiles)
            {
                var key = tile.Key;
                // get position of chunk
                int x = (Int16)(key & 0xFFFF);
                int y = (Int16)((key >> 16));

                // get region from chunk
                int regX = (int)Math.Floor((double)x / regionSize);
                int regY = (int)Math.Floor((double)y / regionSize);

                // find region
                var region = regions.FirstOrDefault(r => r.X == regX && r.Y == regY);
                if (region == null)
                {
                    region = new RegionFileViewModel(regX, regY);
                    regions.Add(region);
                }
                // add tile to region
                region.SetTile(key, tile.Value);
            }

            return(regions);
        }