예제 #1
0
 /// <summary>
 /// Constructor for <see cref="Chunk"/> object
 /// </summary>
 /// <param name="position">The position of the chunk</param>
 /// <param name="terrainGenerator">The terrain generator</param>
 public Chunk(int x, int y, TerrainGenerator terrainGenerator)
 {
     // Assigning position and generating chunks
     Position = new Vector2Int(x, y);
     tiles    = new Tile[SIZE, SIZE];
     this.terrainGenerator = terrainGenerator;
     tiles     = terrainGenerator.GenerateChunkTiles(Position);
     Rectangle = new Rectangle(SIZE * Tile.SPACING * x, SIZE * Tile.SPACING * y, SIZE * Tile.SPACING, SIZE * Tile.SPACING);
 }
예제 #2
0
        /// <summary>
        /// Constructor for <see cref="World"/> object
        /// </summary>
        /// <param name="seed">The seed of this <see cref="World"/></param>
        public World(int?seed = null)
        {
            // Setting up singleton
            Instance = this;

            // Setting up quadtree and search range
            worldBoundsRect = new Rectangle(0, 0, Tile.SPACING * Chunk.SIZE * CHUNK_COUNT, Tile.SPACING * Chunk.SIZE * CHUNK_COUNT);
            collisionTree   = new CollisionTree(worldBoundsRect);

            // Creating terrtain generator and generating terrain
            terrainGenerator = new TerrainGenerator(seed);
            AdjustLoadedChunks(new Vector2Int(0, 0));
            cachedBuildings.Add(new Dungeon(new Vector2Int(0, 0)));
        }