24 lines
631 B
C#
24 lines
631 B
C#
using UnityEngine;
|
|
using Random = UnityEngine.Random;
|
|
|
|
namespace SepCore.EnemyManager
|
|
{
|
|
public class RandomCircleSpawnStrategy : ISpawnPositionStrategy
|
|
{
|
|
private readonly float _spawnDistance;
|
|
|
|
public RandomCircleSpawnStrategy(float spawnDistance)
|
|
{
|
|
_spawnDistance = spawnDistance;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|