Добавлена механика Initial Room

This commit is contained in:
ThomasCharester committed 2025-11-28 13:21:56 +03:00
1 parent 5d075034b5
commit 0cab2eda74
20 files changed
+834 -1631

No files matched your search

@@ -1,5 +1,7 @@
using System.Collections.Generic;
using Code.Gameplay.Orders.Order;
using Code.Scenes;
using Code.Scenes.SceneEnvironments;
using Cysharp.Threading.Tasks;
using Reflex.Attributes;
using UnityEngine;
@@ -13,7 +15,7 @@ namespace Code.Generator
[Inject] private GeneratorConfig generatorConfig;
[Inject] private IRoomGeneratorFactory _factory;
private List<RoomIndex> _roomIndexesStack;
private struct RoomIndex
@@ -47,7 +49,7 @@ namespace Code.Generator
_orderService.OnOrderGiven += CreateRoomsStack;
RoomTrigger.PlayerEnteredRoom += OnPlayerEntered;
CreateSaveRoom();
CreateInitialRoom();
SpawnNextRoomAsync();
}
@@ -77,10 +79,8 @@ namespace Code.Generator
private void CreateRoomsStack(float timer)
{
_nextRoomStackIndex = 0;
// var currentSaveRoom = _roomIndexesStack[^1];
_roomIndexesStack.Clear();
// _roomIndexesStack.Add(currentSaveRoom);
_nextRoomStackIndex = 0;
_roomIndexesStack.Clear();
var remainingTime = timer;
@@ -110,17 +110,26 @@ namespace Code.Generator
_roomIndexesStack.Add(new(RoomType.Save, roomIndex));
Debug.Log($"Первая комната: {saveRoom.name}");
}
}
[Inject] private CurrentSceneEnvironment _currentSceneEnvironment;
private async UniTask SpawnInitialRoomsAsync()
private void CreateInitialRoom()
{
_nextRoomStackIndex = 0;
SpawnNextRoomAsync();
SpawnNextRoomAsync();
}
GameplaySceneEnvironment gameplaySceneEnvironment = (GameplaySceneEnvironment)_currentSceneEnvironment;
_factory.GetRandomCachedPrefabOfType(RoomType.Initial, out int roomIndex);
// _roomIndexesStack.Add(new(RoomType.Initial, roomIndex));
InitialRoom instantiated = _factory.CreateRoomByIndex(roomIndex, RoomType.Initial).GetComponent<InitialRoom>();
_spawnedRooms.Add(instantiated);
instantiated.transform.position = Vector3.zero;
instantiated.transform.rotation = Quaternion.identity;
gameplaySceneEnvironment.playerSpawnPoint = instantiated.playerSpawn;
instantiated.Initialize();
Debug.Log($"Первая комната: {instantiated.name}");
}
private void SpawnNextRoomAsync()
{
if (_nextRoomStackIndex >= _roomIndexesStack.Count)