Add FloorVisibilityManager for dynamic floor visibility management and update material properties for transparency effects

This commit is contained in:
2025-12-13 01:35:22 +01:00
parent 189bbb7ae7
commit 7b1eb645ef
13 changed files with 348 additions and 24 deletions

View File

@@ -21,6 +21,7 @@ namespace Infrastructure.Unity
[SerializeField] private CameraController cameraController;
[SerializeField] private NpcController npcPrefab;
[SerializeField] private HunterNpcController hunterNpcPrefab;
[SerializeField] private FloorVisibilityManager floorVisibilityManager;
[Header("Level Generation")]
[SerializeField] private int floorsCount = 3;
@@ -68,7 +69,17 @@ namespace Infrastructure.Unity
// Set Theme based on High Score
ThemeManager.CurrentTheme = ThemeManager.GetTheme(_gameSession.HighScore);
if (levelGenerator) levelGenerator.Generate(soundManager, _allTiles, _tileViews, cameraController, rumbleManager);
if (levelGenerator)
{
levelGenerator.Generate(soundManager, _allTiles, _tileViews, cameraController, rumbleManager);
if (!floorVisibilityManager)
{
floorVisibilityManager = gameObject.AddComponent<FloorVisibilityManager>();
}
floorVisibilityManager.Initialize(_gameSession, _allTiles, _tileViews, floorsCount);
}
SpawnDeathPlane();
SpawnPlayer();
@@ -95,11 +106,18 @@ namespace Infrastructure.Unity
if (_playerInstance)
{
var playerY = _playerInstance.transform.position.y;
var currentFloor = Mathf.RoundToInt(-playerY / floorHeightDistance);
currentFloor = Mathf.Clamp(currentFloor, 0, floorsCount - 1);
// Calculate current floor index based on Y height (inverse logic from Generator)
// Note: Generator uses negative offsets: 0, -15, -30.
// So Floor 0 is at Y=0. Floor 1 is at Y=-15.
// Math to get positive index:
var rawFloor = Mathf.RoundToInt(-playerY / floorHeightDistance);
var currentFloor = Mathf.Clamp(rawFloor, 0, floorsCount - 1);
_gameSession.SetPlayerFloor(currentFloor);
// UPDATE VISIBILITY
floorVisibilityManager.UpdateFloorVisibility(currentFloor);
}
var dt = Time.deltaTime;