重构清理敌人类
This commit is contained in:
+8
-5
@@ -5,19 +5,22 @@ namespace SepCore.EnemyManager
|
||||
{
|
||||
public class RandomCircleSpawnStrategy : ISpawnPositionStrategy
|
||||
{
|
||||
private readonly float _spawnDistance;
|
||||
private readonly float _minDistance;
|
||||
private readonly float _maxDistance;
|
||||
|
||||
public RandomCircleSpawnStrategy(float spawnDistance)
|
||||
public RandomCircleSpawnStrategy(float minDistance, float maxDistance)
|
||||
{
|
||||
_spawnDistance = spawnDistance;
|
||||
_minDistance = minDistance;
|
||||
_maxDistance = maxDistance;
|
||||
}
|
||||
|
||||
public Vector3 GetSpawnPosition(Transform player)
|
||||
{
|
||||
float x = Random.Range(-1f, 1f);
|
||||
float z = Random.Range(-1f, 1f);
|
||||
Vector3 dir = new Vector3(x, 0, z).normalized;
|
||||
return player.position + dir * _spawnDistance;
|
||||
Vector3 dir = new Vector3(x, 0f, z).normalized;
|
||||
float distance = Random.Range(_minDistance, _maxDistance);
|
||||
return player.position + dir * distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user