Example #1
0
        public static TileInfo[,] getMap(int width, int height, IVisibleCellManager visibleCellManager)
        {
            TileInfo[,] tiles = new TileInfo[width, height];

            int[,] heightmap = getHeightmap(width, height);
            int median = getMedian(heightmap);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    TileInfo tileInfo = new TileInfo(x, y, visibleCellManager);
                    if (heightmap[x, y] > median)
                    {
                        tileInfo.setTerrain(TileInfo.TerrainType.Land);
                        tileInfo.setTerrainHeight((heightmap[x, y] - median) / 255f);
                    }
                    else
                    {
                        tileInfo.setTerrain(TileInfo.TerrainType.Sea);
                    }
                    tiles[x, y] = tileInfo;
                }
            }
            return(tiles);
        }
Example #2
0
 public TileInfo(int x, int y, IVisibleCellManager visibleCellManager)
 {
     X = x;
     Y = y;
     _visibleCellManager = visibleCellManager;
     VisibleCell         = _visibleCellManager.getNewCell(new Character(SpecialCharacter.Tilde), X, Y, RLNET.RLColor.Blue);
 }
Example #3
0
 public Population(int x, int y, IVisibleCellManager visibleCellManager)
 {
     X           = x;
     Y           = y;
     VisibleCell = visibleCellManager.getNewCell(new Character(SpecialCharacter.Dude), X, Y, RLNET.RLColor.Cyan);
     Behaviours  = new List <IBehaviour <Population> >();
     Behaviours.Add(new Roam());
 }
Example #4
0
 public SimWorld(IVisibleCellManager visibleCellManager)
 {
     _visibleCellManager = visibleCellManager;
     Width      = 200;
     Height     = 120;
     _mapLayers = new List <MapLayer>();
     _mapLayers.Add(new GeoLayer(Width, Height, visibleCellManager));
     _mapLayers.Add(new VegeLayer(Width, Height, visibleCellManager, this));
     _mapLayers.Add(new TownLayer(Width, Height, visibleCellManager, this));
     _populations = new List <Population>();
 }
Example #5
0
 public VegeLayer(int width, int height, IVisibleCellManager visibleCellManager, SimWorld world) : base(width, height)
 {
     _visibleCellManager = visibleCellManager;
     BuildVegetation(world);
     visibleCellManager.VisibleLayers.Add(1);
 }
Example #6
0
        public TownLayer(int width, int height, IVisibleCellManager visibleCellManager, SimWorld world) : base(width, height)
        {
            Random random = new Random();

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    TileInfo tileInfo = world.getTileInfo <GeoLayer>(x, y);
                    if (random.NextDouble() > 0.99)
                    {
                        if (tileInfo.Terrain == TileInfo.TerrainType.Land)
                        {
                            float points = 0;

                            int waterPoints = 0;
                            int landsAround = 0;
                            foreach (TileInfo info in world.getTileInfosAround <GeoLayer>(x, y, 5))
                            {
                                if (info.Terrain == TileInfo.TerrainType.Land)
                                {
                                    landsAround++;
                                }
                                else
                                {
                                    waterPoints++;
                                }
                                if (info.TerrainHeight < 0.1f)
                                {
                                    points += 0.1f;
                                }
                            }
                            if (waterPoints < 3)
                            {
                                points -= 5;
                            }
                            else if (waterPoints < 7)
                            {
                                points -= 1;
                            }
                            else if (waterPoints < 20)
                            {
                                points += 2;
                            }
                            else if (waterPoints < 30)
                            {
                                points += 3;
                            }
                            else if (waterPoints < 60)
                            {
                                points += 2;
                            }
                            else if (waterPoints > 60)
                            {
                                points -= 6;
                            }

                            //points -= (Math.Abs(waterPoints - landsAround) / 20);
                            if (points <= 0)
                            {
                                points = 1;
                            }
                            if (points > 9)
                            {
                                points = 9;
                            }
                            visibleCellManager.getNewCell(new Character(48 + (int)points),
                                                          tileInfo.X, tileInfo.Y, RLNET.RLColor.Brown, 1);
                        }
                    }
                }
            }
        }
Example #7
0
 public GeoLayer(int width, int height, IVisibleCellManager visibleCellManager)
     : base(width, height)
 {
     Tiles = MapGenerator.MapGenerator.getMap(width, height, visibleCellManager);
 }