diff --git a/Assets/Prefabs/CreepCamp.prefab b/Assets/Prefabs/CreepCamp.prefab index 1a12d21..ad1edc4 100644 --- a/Assets/Prefabs/CreepCamp.prefab +++ b/Assets/Prefabs/CreepCamp.prefab @@ -45,7 +45,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: Unity.Netcode.Runtime::Unity.Netcode.NetworkObject - GlobalObjectIdHash: 0 + GlobalObjectIdHash: 1167141433 InScenePlacedSourceGlobalObjectIdHash: 0 DeferredDespawnTick: 0 Ownership: 1 @@ -72,7 +72,3 @@ MonoBehaviour: m_EditorClassIdentifier: Assembly-CSharp::Northbound.CreepCamp ShowTopMostFoldoutHeaderGroup: 1 creepPrefabs: [] - campStrength: 1 - campCostBudget: 10 - spawnRadius: 5 - maxSpawnAttempts: 50 diff --git a/Assets/Scenes/GameMain.unity b/Assets/Scenes/GameMain.unity index f1f816b..a8ada3f 100644 --- a/Assets/Scenes/GameMain.unity +++ b/Assets/Scenes/GameMain.unity @@ -902,7 +902,7 @@ MonoBehaviour: generateOnSpawn: 1 groupUnderParent: 1 playableAreaWidth: 80 - startZ: 0 + startZ: 25 endZ: 725 resourcePrefab: {fileID: 5585059388146411250, guid: f395fcc064a3a834ba957327f1387c19, type: 3} minResourceCount: 8 @@ -951,14 +951,17 @@ MonoBehaviour: scaleVariation: 0.2 maxObstacleSpawnAttempts: 50 creepCampPrefab: {fileID: 3360908504529629757, guid: 41d918243a20cbd4d8f1558ac8345e9b, type: 3} - minDistanceBetweenCamps: 60 - minDistanceFromCoreCamps: 20 - minDistanceFromBarracksCamps: 20 - minDistanceFromInitialResource: 60 - additionalCreepCampCount: 5 - baseCampStrength: 3 + minDistanceBetweenCamps: 30 + minDistanceFromCoreCamps: 0 + minDistanceFromBarracksCamps: 0 + minDistanceFromInitialResource: 20 + additionalCreepCampCount: 200 + baseCampStrength: 1 strengthIncreasePerZ100: 0.1 - resourceCampStrengthBonus: 0.2 + resourceCampStrengthBonus: 1.2 + campCostBudget: 5 + spawnRadius: 5 + maxSpawnAttempts: 50 generateResourcesFirst: 1 --- !u!4 &672563223 Transform: diff --git a/Assets/Scripts/CreepCamp.cs b/Assets/Scripts/CreepCamp.cs index 38d097e..4488290 100644 --- a/Assets/Scripts/CreepCamp.cs +++ b/Assets/Scripts/CreepCamp.cs @@ -11,20 +11,11 @@ namespace Northbound [Tooltip("Creep prefabs available to spawn")] [SerializeField] private List creepPrefabs = new List(); - [Header("Spawning Settings")] - [Tooltip("Camp strength multiplier (higher = stronger creeps)")] - [SerializeField] private float campStrength = 1f; - - [Tooltip("Cost budget for spawning creeps")] - [SerializeField] private float campCostBudget = 10f; - - [Tooltip("Spawn radius around camp")] - [SerializeField] private float spawnRadius = 5f; - - [Tooltip("Max creep spawn attempts")] - [SerializeField] private int maxSpawnAttempts = 50; - private float _zPosition; + private float _campStrength; + private float _campCostBudget; + private float _spawnRadius; + private int _maxSpawnAttempts; public override void OnNetworkSpawn() { @@ -34,10 +25,13 @@ namespace Northbound } } - public void InitializeCamp(float zPosition, float strengthMultiplier) + public void InitializeCamp(float zPosition, float strengthMultiplier, float costBudget, float radius, int maxAttempts) { _zPosition = zPosition; - campStrength = strengthMultiplier; + _campStrength = strengthMultiplier; + _campCostBudget = costBudget; + _spawnRadius = radius; + _maxSpawnAttempts = maxAttempts; } public void SetCreepPrefabs(List prefabs) @@ -55,16 +49,16 @@ namespace Northbound return; } - float remainingCost = campCostBudget * campStrength; + float remainingCost = _campCostBudget * _campStrength; int spawnedCount = 0; - for (int attempt = 0; attempt < maxSpawnAttempts && remainingCost > 0; attempt++) + for (int attempt = 0; attempt < _maxSpawnAttempts && remainingCost > 0; attempt++) { GameObject selectedCreep = SelectCreepByCost(remainingCost); if (selectedCreep == null) { - Debug.LogWarning($"[CreepCamp] Could not select creep (attempt {attempt + 1}/{maxSpawnAttempts}), remaining cost: {remainingCost:F2}"); + Debug.LogWarning($"[CreepCamp] No affordable creeps. Remaining cost: {remainingCost:F2}"); break; } @@ -75,21 +69,12 @@ namespace Northbound continue; } - if (creepData.cost > remainingCost) - { - if (!CanSpawnAnyCreep(remainingCost)) - { - Debug.LogWarning($"[CreepCamp] No affordable creeps found. Remaining cost: {remainingCost:F2}"); - break; - } - continue; - } - SpawnCreep(selectedCreep); remainingCost -= creepData.cost; spawnedCount++; } + Debug.Log($"[CreepCamp] Spawned {spawnedCount} creeps (Cost budget: {_campCostBudget * _campStrength:F2}, Used: {(_campCostBudget * _campStrength) - remainingCost:F2})"); } private GameObject SelectCreepByCost(float remainingCost) @@ -172,7 +157,7 @@ namespace Northbound private void SpawnCreep(GameObject prefab) { - Vector3 spawnOffset = Random.insideUnitSphere * spawnRadius; + Vector3 spawnOffset = Random.insideUnitSphere * _spawnRadius; spawnOffset.y = 0; GameObject creep = Instantiate(prefab, transform.position + spawnOffset, Quaternion.identity); @@ -196,13 +181,13 @@ namespace Northbound private void OnDrawGizmos() { Gizmos.color = Color.red; - Gizmos.DrawWireSphere(transform.position, spawnRadius); + Gizmos.DrawWireSphere(transform.position, _spawnRadius); } private void OnDrawGizmosSelected() { Gizmos.color = new Color(1f, 0f, 0f, 0.3f); - Gizmos.DrawSphere(transform.position, spawnRadius); + Gizmos.DrawSphere(transform.position, _spawnRadius); } } } diff --git a/Assets/Scripts/MapGenerator.cs b/Assets/Scripts/MapGenerator.cs index 325ce90..a302f86 100644 --- a/Assets/Scripts/MapGenerator.cs +++ b/Assets/Scripts/MapGenerator.cs @@ -98,7 +98,7 @@ namespace Northbound [Tooltip("초기 자원과의 최소 거리")] [SerializeField] private float minDistanceFromInitialResource = 30f; [Tooltip("추가 크립 캠프 개수")] - [Range(0, 10)] + [Range(0, 1000)] [SerializeField] private int additionalCreepCampCount = 5; [Tooltip("크립 캠프 강도 기본값")] [SerializeField] private float baseCampStrength = 1f; @@ -107,6 +107,15 @@ namespace Northbound [Tooltip("자원 보호 캠프 강도 보너스 (far camp보다 얼마나 강할지)")] [SerializeField] private float resourceCampStrengthBonus = 0.5f; + [Tooltip("크립 스폰 비용 예산")] + [SerializeField] private float campCostBudget = 10f; + + [Tooltip("스폰 반경 (캠프 주변)")] + [SerializeField] private float spawnRadius = 5f; + + [Tooltip("최대 크립 스폰 시도 횟수")] + [SerializeField] private int maxSpawnAttempts = 50; + [Header("Generation Order")] [Tooltip("자원 먼저 생성 후 장애물 생성 (true) 또는 그 반대 (false)")] [SerializeField] private bool generateResourcesFirst = true; @@ -845,7 +854,7 @@ namespace Northbound return; } - creepCamp.InitializeCamp(position.z, strength); + creepCamp.InitializeCamp(position.z, strength, campCostBudget, spawnRadius, maxSpawnAttempts); creepCamp.SetCreepPrefabs(_creepPrefabs); Debug.Log($"[MapGenerator] Camp initialized with {_creepPrefabs.Count} creep prefabs");