public Map GenerateVillage(UInt16 width, UInt16 height)
        {
            // We need a reasonable amount of space to construct the map
            if ((width < 20) || (height < 20))
            {
                return(null);
            }

            // Initializes map (currently to an all-grass space);
            Map canvas = new Map(width, height, (Int32)_randomator.NSidedDice(1000, 1));

            // Initializes a double array where we keep track of which areas of the map are complete
            //BitArray[,] painted = new BitArray[width, height];
            BitArray[] painted = new BitArray[width];
            for (int i = 0; i < width; ++i)
            {
                painted[i] = new BitArray(height);
            }

            // Put roads through the middle of the map; later we'll improve the algo
            UInt16 halfwidth = (UInt16)(width * 0.5);

            FillRectangleWithTiles(canvas, new Coords(CoordsType.Tile, halfwidth, 0), new Coords(CoordsType.Tile, halfwidth, height - 1), Constants.TileGeneratorRoadPaved);
            for (int i = 0; i < height; ++i)
            {
                painted[halfwidth][i] = true;
            }

            UInt16 halfheight = (UInt16)(height * 0.5);

            FillRectangleWithTiles(canvas, new Coords(CoordsType.Tile, 0, halfheight), new Coords(CoordsType.Tile, width - 1, halfheight), Constants.TileGeneratorRoadPaved);
            for (int i = 0; i < width; ++i)
            {
                painted[i][halfheight] = true;
            }

            // Put a house or two
            GenerateRectangularRoom(canvas, new Coords(CoordsType.Tile, halfwidth + 1, 10), new Coords(CoordsType.Tile, halfwidth + 5, 15));
            FurnishRectangularLivingRoom(canvas, new Coords(CoordsType.Tile, halfwidth + 1, 10), new Coords(CoordsType.Tile, halfwidth + 5, 15));
            GenerateRectangularRoom(canvas, new Coords(CoordsType.Tile, 6, halfheight - 5), new Coords(CoordsType.Tile, 12, halfheight - 1));
            FurnishRectangularWorkshop(canvas, new Coords(CoordsType.Tile, 6, halfheight - 5), new Coords(CoordsType.Tile, 12, halfheight - 1));

            // put a well somewhere
            canvas.CreateItem(new Coords(CoordsType.Tile, 20, 20), Constants.ItemGeneratorWell);

            // Apple tree!
            canvas.CreateItem(new Coords(CoordsType.Tile, 30, 5), Constants.ItemGeneratorTreeApple);

            canvas.AnalyzeTileAccessibility();

            return(canvas);
        }
        public Map GenerateVillage(UInt16 width, UInt16 height)
        {
            // We need a reasonable amount of space to construct the map
            if ((width < 20) || (height < 20))
            {
                return null;
            }

            // Initializes map (currently to an all-grass space);
            Map canvas = new Map(width, height, (Int32)_randomator.NSidedDice(1000, 1));
            // Initializes a double array where we keep track of which areas of the map are complete
            //BitArray[,] painted = new BitArray[width, height];
            BitArray[] painted = new BitArray[width];
            for (int i = 0; i < width; ++i)
            {
                painted[i] = new BitArray(height);
            }

            // Put roads through the middle of the map; later we'll improve the algo
            UInt16 halfwidth = (UInt16)(width * 0.5);
            FillRectangleWithTiles(canvas, new Coords(CoordsType.Tile, halfwidth, 0), new Coords(CoordsType.Tile, halfwidth, height - 1), Constants.TileGeneratorRoadPaved);
            for (int i = 0; i < height; ++i)
            {
                painted[halfwidth][i] = true;
            }

            UInt16 halfheight = (UInt16)(height * 0.5);
            FillRectangleWithTiles(canvas, new Coords(CoordsType.Tile, 0, halfheight), new Coords(CoordsType.Tile, width - 1, halfheight), Constants.TileGeneratorRoadPaved);
            for (int i = 0; i < width; ++i)
            {
                painted[i][halfheight] = true;
            }

            // Put a house or two
            GenerateRectangularRoom(canvas, new Coords(CoordsType.Tile, halfwidth + 1, 10), new Coords(CoordsType.Tile, halfwidth + 5, 15));
            FurnishRectangularLivingRoom(canvas, new Coords(CoordsType.Tile, halfwidth + 1, 10), new Coords(CoordsType.Tile, halfwidth + 5, 15));
            GenerateRectangularRoom(canvas, new Coords(CoordsType.Tile, 6, halfheight - 5), new Coords(CoordsType.Tile, 12, halfheight - 1));
            FurnishRectangularWorkshop(canvas, new Coords(CoordsType.Tile, 6, halfheight - 5), new Coords(CoordsType.Tile, 12, halfheight - 1));

            // put a well somewhere
            canvas.CreateItem(new Coords(CoordsType.Tile, 20, 20), Constants.ItemGeneratorWell);

            // Apple tree!
            canvas.CreateItem(new Coords(CoordsType.Tile, 30, 5), Constants.ItemGeneratorTreeApple);

            canvas.AnalyzeTileAccessibility();

            return canvas;
        }
        private void MainFrame_Load(object sender, System.EventArgs e)
        {
            _timer          = new Timer();
            _timer.Interval = Constants.defaultTimerPeriod;
            _timer.Tick    += new System.EventHandler(MainFrame_Tick);

            _zoom = Constants.ZoomDefault;

            WorldGeneration generator = new WorldGeneration(907);

            _currentMap = generator.GenerateVillage(Constants.MapSize, Constants.MapSize);
            _painter    = new Painter(this, _currentMap, _zoom);

            _currentMap.AnalyzeTileAccessibility();

            Team team1 = new Team(Color.Red);
            Team team2 = new Team(Color.Blue);

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < 5; ++i)
                {
                    _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, j), team1, Constants.CreatureGeneratorGnome);
                }
            }

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < 5; ++i)
                {
                    _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, _currentMap.BoundY - 1 - j), team2, Constants.CreatureGeneratorGnome);
                }
            }

            _currentMap.SpawnPlayer(Constants.PlayerStartPos);
            //_player = _currentMap.PlayerReference;

            //_screenAnchor = this.TransformCenterAtPlayer();

            _scheduler = new Scheduler(_currentMap);
            _ledger    = new Ledger(_scheduler);
            _timer.Start();
        }
        private void MainFrame_Load(object sender, System.EventArgs e)
        {
            _timer = new Timer();
            _timer.Interval = Constants.defaultTimerPeriod;
            _timer.Tick += new System.EventHandler(MainFrame_Tick);

            _zoom = Constants.ZoomDefault;

            WorldGeneration generator = new WorldGeneration(907);

            _currentMap = generator.GenerateVillage(Constants.MapSize, Constants.MapSize);
            _painter = new Painter(this, _currentMap, _zoom);

            _currentMap.AnalyzeTileAccessibility();

            Team team1 = new Team(Color.Red);
            Team team2 = new Team(Color.Blue);

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < 5; ++i)
                {
                    _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, j), team1, Constants.CreatureGeneratorGnome);
                }
            }

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < 5; ++i)
                {
                    _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, _currentMap.BoundY-1-j), team2, Constants.CreatureGeneratorGnome);
                }
            }

            _currentMap.SpawnPlayer(Constants.PlayerStartPos);
            //_player = _currentMap.PlayerReference;

            //_screenAnchor = this.TransformCenterAtPlayer();

            _scheduler = new Scheduler(_currentMap);
            _ledger = new Ledger(_scheduler);
            _timer.Start();
        }