Example #1
0
 public Chunk(World.ChunkPoint position, float[] points, int chunkSize, int chunkHeight)
 {
     Position    = position;
     Points      = points;
     ChunkSize   = chunkSize;
     ChunkHeight = chunkHeight;
     this.Entity = new List <GameObject>();
 }
Example #2
0
    public void Generate(Vector2 min, Vector2 max)
    {
        for (int x = (int)min.x; x < max.x; x++)
        {
            for (int z = (int)min.y; z < max.y; z++)
            {
                var   point = new World.ChunkPoint(x, z);
                Chunk c     = world.LoadChunkAt(point);

                if (c == null)
                {
                    continue;
                }

                world.SpawnChunk(c);
            }
        }
    }
    public BiomeType PickCommonBiome(World.ChunkPoint point)
    {
        //Get all neighboring chunks
        Chunk[] chunks =
        {
            world.ChunkAt(point.Move(Neighbor.LEFT),         false),
            world.ChunkAt(point.Move(Neighbor.RIGHT),        false),
            world.ChunkAt(point.Move(Neighbor.TOP),          false),
            world.ChunkAt(point.Move(Neighbor.BOTTOM),       false),
            world.ChunkAt(point.Move(Neighbor.TOP_LEFT),     false),
            world.ChunkAt(point.Move(Neighbor.TOP_RIGHT),    false),
            world.ChunkAt(point.Move(Neighbor.BOTTOM_LEFT),  false),
            world.ChunkAt(point.Move(Neighbor.BOTTOM_RIGHT), false)
        };

        List <BiomeData> dataPool = (from c in chunks where c != null where c.BiomeData.type != BiomeType.Unknown select c.BiomeData).ToList();

        return(dataPool.Count == 0 ? BiomeType.Unknown : dataPool[Random.Range(0, dataPool.Count)].type);
    }
 public BiomeType PickCommonBiome(Vector3 position)
 {
     World.ChunkPoint p = world.VectorToPoint(position);
     return(PickCommonBiome(p));
 }