크립 캠프 배치 데이터 변경

크립 캠프의 일부 기능을 MapGenerator로 이동
This commit is contained in:
2026-02-16 10:39:46 +09:00
parent a3b1b83c8d
commit 3e026d3319
4 changed files with 39 additions and 46 deletions

View File

@@ -11,20 +11,11 @@ namespace Northbound
[Tooltip("Creep prefabs available to spawn")]
[SerializeField] private List<GameObject> creepPrefabs = new List<GameObject>();
[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<GameObject> 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($"<color=green>[CreepCamp] Spawned {spawnedCount} creeps (Cost budget: {_campCostBudget * _campStrength:F2}, Used: {(_campCostBudget * _campStrength) - remainingCost:F2})</color>");
}
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);
}
}
}