Add FloorVisibilityManager for dynamic floor visibility management and update material properties for transparency effects
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user