Refactor NPC spawning logic and adjust grid size; remove unused power-up type
This commit is contained in:
@@ -281,7 +281,8 @@ namespace Infrastructure.Unity
|
||||
}
|
||||
else if (npcPrefab)
|
||||
{
|
||||
Instantiate(npcPrefab, spawnPos, Quaternion.identity);
|
||||
var npc = Instantiate(npcPrefab, spawnPos, Quaternion.identity);
|
||||
npc.Initialize(() => _gameSession.TimeDilation, () => _gameSession.EndGame());
|
||||
}
|
||||
|
||||
soundManager.PlayNpcSpawn();
|
||||
|
||||
@@ -18,9 +18,11 @@ namespace Infrastructure.Unity
|
||||
private Vector3 _currentDir;
|
||||
private float _timer;
|
||||
private Func<float> _timeDilationProvider;
|
||||
private Action _onPlayerHit;
|
||||
|
||||
public void Initialize(Func<float> timeDilationProvider)
|
||||
public void Initialize(Func<float> timeDilationProvider, Action onPlayerHit)
|
||||
{
|
||||
_onPlayerHit = onPlayerHit;
|
||||
_timeDilationProvider = timeDilationProvider;
|
||||
}
|
||||
|
||||
@@ -70,5 +72,14 @@ namespace Infrastructure.Unity
|
||||
case 3: _currentDir = Vector3.right; break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision other)
|
||||
{
|
||||
if (other.gameObject.TryGetComponent<PlayerController>(out var player))
|
||||
{
|
||||
_onPlayerHit?.Invoke();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,6 @@ namespace Infrastructure.Unity
|
||||
case PowerUpType.SpeedBoost:
|
||||
SetColor(EffectColors.SpeedBoostColor);
|
||||
break;
|
||||
case PowerUpType.Hover:
|
||||
SetColor(EffectColors.HoverColor);
|
||||
break;
|
||||
case PowerUpType.TimeSlow:
|
||||
SetColor(EffectColors.TimeSlowColor);
|
||||
break;
|
||||
@@ -79,9 +76,6 @@ namespace Infrastructure.Unity
|
||||
case PowerUpType.SpeedBoost:
|
||||
player.Status.AddEffect(new SpeedBoostEffect(duration, 1.5f));
|
||||
break;
|
||||
case PowerUpType.Hover:
|
||||
player.Status.AddEffect(new HoverEffect(duration));
|
||||
break;
|
||||
case PowerUpType.TimeSlow:
|
||||
// Handled globally
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user