Добавлена механика Initial Room
This commit is contained in:
1 parent
5d075034b5
commit
0cab2eda74
20 files changed
+834
-1631
No files matched your search
@@ -9,7 +9,7 @@ namespace Code.Gameplay.Orders.Order
|
||||
private bool _playerEntered;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (_playerEntered) return;
|
||||
if (_playerEntered && !other.CompareTag("Player")) return;
|
||||
|
||||
_playerEntered = true;
|
||||
_orderService.OrderGive();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Generator
|
||||
{
|
||||
public class InitialRoom : Room
|
||||
{
|
||||
public Transform playerSpawn;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4245aa5c87c7455ebad11edaad3b649e
|
||||
timeCreated: 1764324045
|
||||
@@ -8,17 +8,17 @@ namespace Code.Generator
|
||||
[RequireComponent(typeof(Transform))]
|
||||
public class Room : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RoomType roomType;
|
||||
[SerializeField] protected RoomType roomType;
|
||||
public RoomType RoomType => roomType;
|
||||
[SerializeField] private float roomTimer;
|
||||
[SerializeField] protected float roomTimer;
|
||||
public float RoomTimer => roomTimer;
|
||||
[SerializeField] private Transform enterMarker;
|
||||
[SerializeField] protected Transform enterMarker;
|
||||
public Transform EnterMarker => enterMarker;
|
||||
[SerializeField] private Transform exitMarker;
|
||||
[SerializeField] protected Transform exitMarker;
|
||||
public Transform ExitMarker => exitMarker;
|
||||
[SerializeField] private Door door;
|
||||
[SerializeField] protected Door door;
|
||||
|
||||
private void Awake()
|
||||
protected void Awake()
|
||||
{
|
||||
if (EnterMarker == null || ExitMarker == null)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace Code.Generator
|
||||
_cashedRooms.Add(RoomType.Basic, new());
|
||||
_cashedRooms.Add(RoomType.Save, new ());
|
||||
_cashedRooms.Add(RoomType.PickUp, new ());
|
||||
_cashedRooms.Add(RoomType.Initial, new ());
|
||||
}
|
||||
|
||||
public async UniTask PreloadRooms(IOrderService orderService)
|
||||
|
||||
@@ -3,8 +3,8 @@ namespace Code.Generator
|
||||
public enum RoomType
|
||||
{
|
||||
Basic,
|
||||
Ladder,
|
||||
Save,
|
||||
PickUp
|
||||
PickUp,
|
||||
Initial
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user