Exemplo n.º 1
0
        public void SetupTilemapGeneration()
        {
            // Create tilemap if it does not exist
            tilemap = GetComponent <Tilemap>();
            if (tilemap == null)
            {
                tilemap = transform.gameObject.AddComponent <Tilemap>();
                transform.gameObject.AddComponent <TilemapRenderer>();
            }

            // Set tilemap bounds object to the value of sideSize x  sideSize x 0
            tilemapBounds = new BoundsInt(Vector3Int.zero, new Vector3Int(sideSize, sideSize, 0));

            // Initialize and fill the rules dictionary
            rules.Add(TransformRule.WALL_FROM_BOUNDS, new TransformToTileFromBounds(TileType.WALL));
            rules.Add(TransformRule.WALL_FROM_ADJACENTS, new TransformToWallFromAdjacents());
            rules.Add(TransformRule.WALL_FOR_ROOM, new TransformToWallForRoom());
            rules.Add(TransformRule.ROOM_FROM_ADJACENTS, new TransformToRoomFromAdjacents());
            rules.Add(TransformRule.FLOOR_FROM_BOUNDS, new TransformToTileFromBounds(TileType.CORRIDOR));

            defaultTile = TilemapHelper.GetDefaultTile();

            // Create DataParser object
            fileParser = new DataParser();
        }