From 65af5ad2eb927a7b815e77e0ae6d85785dee5237 Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Thu, 14 May 2026 01:39:39 +0200 Subject: [PATCH] fix: equalize power-up spawn odds, use Math.Max in domain, null-guard Definition --- Assets/Scripts/Core/Domain/GameSession.cs | 9 ++++----- Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Core/Domain/GameSession.cs b/Assets/Scripts/Core/Domain/GameSession.cs index 2d75118..bfd2c19 100644 --- a/Assets/Scripts/Core/Domain/GameSession.cs +++ b/Assets/Scripts/Core/Domain/GameSession.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Generic; using System.Linq; using Core.Ports; -using UnityEngine; using Random = System.Random; namespace Core.Domain @@ -75,7 +74,7 @@ namespace Core.Domain { _npcTimer = 0f; OnSpawnNpc?.Invoke(); - NpcSpawnTime = Mathf.Max(5f, NpcSpawnTime * 0.95f); + NpcSpawnTime = Math.Max(5f, NpcSpawnTime * 0.95f); } _powerUpTimer += deltaTime; @@ -182,13 +181,13 @@ namespace Core.Domain var tile = validTiles[_rng.Next(validTiles.Count)]; - var rand = _rng.Next(0, 4); - var type = PowerUpType.LightFooted; + var rand = _rng.Next(0, 3); + PowerUpType type; switch (rand) { case 0: type = PowerUpType.LightFooted; break; case 1: type = PowerUpType.SpeedBoost; break; - case 3: type = PowerUpType.TimeSlow; break; + default: type = PowerUpType.TimeSlow; break; } OnSpawnPowerUp?.Invoke(type, tile.Id); diff --git a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs index d49687e..cfbee3c 100644 --- a/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs +++ b/Assets/Scripts/Infrastructure/Unity/GameBootstrap.cs @@ -65,8 +65,8 @@ namespace Infrastructure.Unity // Set Theme based on High Score ThemeManager.CurrentTheme = ThemeManager.GetTheme(_gameSession.HighScore); - - var floorsCount = levelGenerator ? levelGenerator.Definition.FloorCount : 1; + + var floorsCount = levelGenerator?.Definition != null ? levelGenerator.Definition.FloorCount : 1; if (levelGenerator) {