从 EnemyManager 中拆分刷怪位置策略接口
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.EnemyManager
|
||||
{
|
||||
public interface ISpawnPositionStrategy
|
||||
{
|
||||
Vector3 GetSpawnPosition(Transform player);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71ed05cb0cc806b43a28fc4492963dd2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12331e41ea431384aa2d6a60da5f4c13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user