Refactor NPC spawning logic and adjust grid size; remove unused power-up type

This commit is contained in:
2025-12-13 02:59:59 +01:00
parent 0e86d2f4f9
commit 1ae7190fd3
6 changed files with 72 additions and 18 deletions

View File

@@ -1,13 +1,14 @@
using System;
using System.Collections.Generic;
using Core.Ports;
using UnityEngine;
using Random = System.Random;
namespace Core.Domain
{
public class GameSession
{
private const string HighScoreKey = "HighScore";
private const float NpcSpawnTime = 30f;
private const float PowerUpSpawnInterval = 25f;
public int Score { get; private set; }
@@ -15,6 +16,7 @@ namespace Core.Domain
public bool IsGameOver { get; private set; }
public float TimeDilation { get; private set; } = 1.0f;
public float NpcSpawnTime { get; private set; } = 30f;
public event Action<int> OnScoreChanged;
public event Action<string> OnOrbSpawned;
@@ -28,7 +30,7 @@ namespace Core.Domain
private readonly Random _rng = new();
private int _playerFloorIndex = 0;
private float _timeSinceStart;
private bool _npcSpawned;
private float _npcTimer;
private float _powerUpTimer;
private float _timeSlowTimer;
@@ -53,7 +55,6 @@ namespace Core.Domain
{
_timeSinceStart = 0f;
_powerUpTimer = 0f;
_npcSpawned = false;
TimeDilation = 1.0f;
ComboMultiplier = 1;
@@ -67,10 +68,13 @@ namespace Core.Domain
if (IsGameOver) return;
_timeSinceStart += deltaTime;
if (!_npcSpawned && _timeSinceStart >= NpcSpawnTime)
_npcTimer += deltaTime;
if (_npcTimer >= NpcSpawnTime)
{
_npcSpawned = true;
_npcTimer = 0f;
OnSpawnNpc?.Invoke();
NpcSpawnTime = Mathf.Max(5f, NpcSpawnTime * 0.95f);
}
_powerUpTimer += deltaTime;
@@ -189,7 +193,6 @@ namespace Core.Domain
{
case 0: type = PowerUpType.LightFooted; break;
case 1: type = PowerUpType.SpeedBoost; break;
case 2: type = PowerUpType.Hover; break;
case 3: type = PowerUpType.TimeSlow; break;
}