调整部分数据表配置,优化 SpriteCache 功能
This commit is contained in:
+13
-8
@@ -19,7 +19,7 @@ namespace SepCore.EnemyManager
|
||||
private EnemyRegistry _enemyRegistry;
|
||||
private EnemySpawnScheduler _spawnScheduler;
|
||||
|
||||
public IReadOnlyCollection<EntityBase> Enemies => _enemyRegistry?.Enemies;
|
||||
public IReadOnlyCollection<EntityBase> Enemies => _enemyRegistry.Enemies;
|
||||
|
||||
[SerializeField] private int _spawnEnemyMaxCount = 5000;
|
||||
[SerializeField] private int _spawnDistanceFromPlayer = 20;
|
||||
@@ -38,10 +38,10 @@ namespace SepCore.EnemyManager
|
||||
// 此时 _isStopped 为真,由 OnShowEntitySuccess 在出生瞬间兜底 Hide 掉。
|
||||
private bool _isStopped;
|
||||
|
||||
public float SpawnRateScale => _spawnScheduler?.SpawnRateScale ?? 1f;
|
||||
public float SpawnRateScale => _spawnScheduler.SpawnRateScale;
|
||||
public float BattleDuration => _duration;
|
||||
public float ElapsedBattleTime => _spawnScheduler?.ElapsedTime ?? 0f;
|
||||
public int CurrentEnemyCount => _enemyRegistry?.Count ?? 0;
|
||||
public float ElapsedBattleTime => _spawnScheduler.ElapsedTime;
|
||||
public int CurrentEnemyCount => _enemyRegistry.Count;
|
||||
|
||||
#region Lifecycle
|
||||
|
||||
@@ -71,9 +71,15 @@ namespace SepCore.EnemyManager
|
||||
|
||||
public void OnInit(LevelConfig level, Player player)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
Log.Error("Can not init enemy manager without a player.");
|
||||
return;
|
||||
}
|
||||
|
||||
_isStopped = false;
|
||||
|
||||
_player = player != null ? player.CachedTransform : null;
|
||||
_player = player.CachedTransform;
|
||||
_spawnPositionStrategy = new RandomCircleSpawnStrategy(_spawnDistanceFromPlayer);
|
||||
|
||||
_baseDuration = level.Duration;
|
||||
@@ -116,14 +122,13 @@ namespace SepCore.EnemyManager
|
||||
_currentLevel = 0;
|
||||
_baseDuration = 0;
|
||||
_duration = 0;
|
||||
_player = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private async UniTaskVoid SpawnEnemyAsync(EnemyType enemyType)
|
||||
{
|
||||
if (_player == null) return;
|
||||
|
||||
if (_enemyRegistry.Count >= _spawnEnemyMaxCount) return;
|
||||
int entityId = _currentSpawnEnemyId++;
|
||||
|
||||
@@ -198,7 +203,7 @@ namespace SepCore.EnemyManager
|
||||
private void OnShowEntitySuccess(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ShowEntitySuccessEventArgs ne) return;
|
||||
if (ne.Entity.EntityGroup?.Name != EnemyGroupName)
|
||||
if (ne.Entity.EntityGroup.Name != EnemyGroupName)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user