Exemple #1
0
        internal Map(TileShape topology, int x, int y, bool torus, int provinces = 0, int nations = 0, Random r = null)
        {
            Torus       = torus;
            R           = r ?? new Random();
            MapTopology = Shape.Square;

            Tiles = new Tile[x, y];
            float[,] heightMap = new GenerateHeight(x, y, torus).HeightMap;
            for (x = 0; x < Tiles.GetLength(0); x++)
            {
                for (y = 0; y < Tiles.GetLength(1); y++)
                {
                    Tiles[x, y] = new Tile(topology, x, y, 1 + x + y * Tiles.GetLength(0), heightMap[x, y], 0);
                }
            }
            for (x = 0; x < Tiles.GetLength(0); x++)
            {
                for (y = 0; y < Tiles.GetLength(1); y++)
                {
                    for (int n = 0; n < Tiles[x, y].Neighbours.Length; n++)
                    {
                        Tiles[x, y].Neighbours[n] = GetNeighbour(x, y, n);
                    }
                }
            }

            if (provinces == 0)
            {
                provinces = x;
            }
            Provinces = new Province[provinces];
            for (int n = 0; n < provinces; n++)
            {
                Provinces[n] = new Province(this, x * y / provinces * 2, n);
            }
            Provinces = Provinces.Where(p => p.Tiles[0] != null).ToArray();
            for (int n = 0; n < Provinces.Length; n++)
            {
                Provinces[n].Id = n;
            }


            if (nations == 0)
            {
                nations = (int)Math.Sqrt(provinces);
            }
            Nations = new Nation[nations];
            for (int n = 0; n < nations; n++)
            {
                Nations[n] = new Nation(this, provinces / nations * 2, n);
            }
            Nations = Nations.Where(p => p.Provinces.Count > 0).ToArray();
            for (int n = 0; n < Nations.Length; n++)
            {
                Nations[n].Id = n;
            }
        }
Exemple #2
0
    public override void Process(uint seed)
    {
        T[]     heightMap      = TerrainMeta.HeightMap.dst;
        int     num            = TerrainMeta.HeightMap.res;
        Vector3 position       = TerrainMeta.Position;
        Vector3 size           = TerrainMeta.Size;
        float   lootAxisAngle  = TerrainMeta.LootAxisAngle;
        float   biomeAxisAngle = TerrainMeta.BiomeAxisAngle;

        GenerateHeight.Native_GenerateHeight(heightMap, num, position, size, seed, lootAxisAngle, biomeAxisAngle);
    }
Exemple #3
0
        public TileMap(GenerateHeight heightMap)
        {
            int width = heightMap.Cs.Width;

            height = heightMap.Cs.Height;
            Tiles  = new Tile[width * height];
            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    Tiles[x * height + y] = new Tile(x, y, heightMap.HeightMap[x, y], heightMap.Cs, this);
                }
            }
        }
Exemple #4
0
    public override void Process(uint seed)
    {
        short[] dst            = TerrainMeta.HeightMap.dst;
        int     res1           = TerrainMeta.HeightMap.res;
        Vector3 position       = TerrainMeta.Position;
        Vector3 size1          = TerrainMeta.Size;
        float   lootAxisAngle  = TerrainMeta.LootAxisAngle;
        float   biomeAxisAngle = TerrainMeta.BiomeAxisAngle;
        int     res2           = res1;
        Vector3 pos            = position;
        Vector3 size2          = size1;
        int     num1           = (int)seed;
        double  num2           = (double)lootAxisAngle;
        double  num3           = (double)biomeAxisAngle;

        GenerateHeight.Native_GenerateHeight(dst, res2, pos, size2, (uint)num1, (float)num2, (float)num3);
    }
Exemple #5
0
 public override void ResetMap()
 {
     heightMap = new GenerateHeight(Width, Height, Torus);
 }