using UnityEngine; public class BlockMapGenerator : MonoBehaviour { [Header("»ý¼º ¼³Á¤")] [SerializeField] private GameObject blockPrefab; // À§¿¡¼­ ¸¸µç DestructibleBlock ÇÁ¸®ÆÕ [SerializeField] private int width = 20; // ¸Ê °¡·Î Å©±â [SerializeField] private int height = 10; // ¸Ê ¼¼·Î Å©±â [SerializeField] private float spacing = 1.0f; // ºí·Ï °£°Ý (½ºÇÁ¶óÀÌÆ® Å©±â¿¡ ¸ÂÃç Á¶Àý) [Header("·£´ý È®·ü (0 ~ 1)")] [Range(0, 1)] [SerializeField] private float fillPercent = 0.5f; // 50% È®·ü·Î ºí·Ï »ý¼º private void Start() { GenerateMap(); } void GenerateMap() { // ¸ÊÀÇ Áß¾ÓÀ» (0,0)¿¡ ¸ÂÃß±â À§ÇÑ ½ÃÀÛ À§Ä¡ °è»ê Vector2 startPos = new Vector2(-width / 2f * spacing, -height / 2f * spacing); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { // Ç÷¹ÀÌ¾î ½ÃÀÛ À§Ä¡(Áß¾Ó)´Â ºñ¿öµÎ±â if (x == width / 2 && y == height / 2) { continue; } if (Random.value < fillPercent) { Vector2 spawnPos = startPos + new Vector2(x * spacing, y * spacing); Instantiate(blockPrefab, spawnPos, Quaternion.identity, transform); } } } } }