예제 #1
0
        /// <summary>
        /// Processes all of the Tiles and determines if they are an edge or not. Edgetiles get added to the list, and the 
        /// other tiles get water / land added to them. 
        /// </summary>
        /// <param name="bmpData">The bmp data we arew processing</param>
        /// <param name="gameWorldX">The game's x coordinate</param>
        /// <param name="gameWorldY">The game's y coordinate</param>		
        private void ProcessTile(BmpData bmpData, int gameWorldX, int gameWorldY)
        {
            bool hasWater = false;
            bool hasLand = false;

            CheckEdges(bmpData, _graphicsTileSize, out hasWater, out hasLand);

            if (hasLand && hasWater)
            {
                //We generate the edge connections for each tile just like they are by themselves.
                //After all of the tiles are processed we will do a second pass to ensure everything is connected.
                MapGraphicsTile mapGraphicsTile = new MapGraphicsTile();
                _gameWorld.GameMap[gameWorldX, gameWorldY] = new MapTile(_mapGraphicsTileSet.EdgePlaceHolder);
                mapGraphicsTile.TileType = TileType.EdgePlaceHolder;
                _edgeTiles.Add(new Point(gameWorldX, gameWorldY), mapGraphicsTile);
            }

            else if (hasLand)
                _gameWorld.GameMap[gameWorldX, gameWorldY] = new MapTile(_mapGraphicsTileSet.LandTile);
            else
                _gameWorld.GameMap[gameWorldX, gameWorldY] = new MapTile(_mapGraphicsTileSet.WaterTile);

            //Need to release the locked bits here
            bmpData.Dispose();
        }
예제 #2
0
        /// <summary>
        /// Processes the gmap tile. splits the gmap tile up into smaller tiles and then checks each tile for the transitions.
        /// </summary>
        /// <param name="gmapX">The google maps X coordinates</param>
        /// <param name="gmapY">The google maps Y coordinates</param>
        /// <param name="gmapBitmap">The bitmap we are processing</param>
        private void ProcessGmapTiles(int gmapX, int gmapY, Bitmap gmapBitmap)
        {
            //The bitmap coming in as 256x256 This needs to be broken down further into 16x16 sized
            //tiles in order to get the proper size of the map
            for (int tileX = 0; tileX < _graphicsTileSize; tileX++)
            {
                for (int tileY = 0; tileY < _graphicsTileSize; tileY++)
                {
                    using (Bitmap smallBmp = new Bitmap(_graphicsTileSize, _graphicsTileSize))
                    {
                        using (Graphics gfx = Graphics.FromImage(smallBmp))
                            gfx.DrawImage(gmapBitmap,new Rectangle(0,0,16,16),tileX * _graphicsTileSize,tileY * _graphicsTileSize,16,16,GraphicsUnit.Pixel);
            //#if DEBUG
                        smallBmp.Save("C:\\tiles\\smalltile" + ((gmapX * _graphicsTileSize) + tileX) + "-" + ((gmapY * _graphicsTileSize) + tileY) + ".jpg");
            //#endif
                        BmpData bmpData = new BmpData(smallBmp, _graphicsTileSize);

                        ProcessTile(bmpData, (gmapX * _graphicsTileSize) + tileX, (gmapY * _graphicsTileSize) + tileY);
                        bmpData.Dispose();
                    }
                }
            }
        }