Author SHA1 Message Date
Pe4enega ff8ed96138 Merge branch 'Dev' into Generator 2025-11-24 18:00:18 +03:00
ThomasCharester 95cb51db79 Update OrderService.cs 2025-11-23 15:22:25 +03:00
ThomasCharester 2b9fd70c85 Update AudioService.cs 2025-11-23 15:17:56 +03:00
ThomasCharester cd384239ff Загрузчик не юзлес + больше интерфейса 2025-11-23 15:06:35 +03:00
ThomasCharester f3a83eb909 AudioSourceConfig 2025-11-23 01:39:08 +03:00
ThomasCharester 35f703a8d2 Озвучка при уроне, новая музыка 2025-11-23 01:17:45 +03:00
ThomasCharester e5f4f292c2 Интерфейс, конфиги камер 2025-11-23 00:51:58 +03:00
ThomasCharester efad72b4d9 Меню красивое 2025-11-22 01:24:33 +03:00
ThomasCharester 855108d88b Сцена геймплея, дебажные зоны 2025-11-21 20:41:43 +03:00
ThomasCharester 388773129d CoreGameplay 2025-11-21 20:27:11 +03:00
ThomasCharester 5da64a7b3d Меню, дверь, цвет 2025-11-19 14:45:45 +03:00
ThomasCharester c4ab11488b Ещё модели 2025-11-19 12:53:09 +03:00
ThomasCharester cb968d782b Освещение, модели, текстуры 2025-11-18 20:07:45 +03:00
ThomasCharester 522f51be3f Текстуры модели и пр 2025-11-18 15:02:12 +03:00
Pe4enega 01505de4c3 Проверка расстановки 2025-11-18 14:45:43 +03:00
Pe4enega 52edef92e3 Вроде ок, осталось проверить на практике нормально, когда комнаты будут готовы 2025-11-15 21:31:40 +03:00
Pe4enega c6b097a879 Промежуточный 2025-11-15 17:25:09 +03:00
Pe4enega a243ad53d6 Вставка лестниц(не доделана) 2025-11-12 14:26:16 +03:00
Pe4enega 85a07065d9 Комнаты ставятся, но криво 2025-11-10 21:08:54 +03:00
433 changed files with 54572 additions and 5086 deletions

No files matched your search

@@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: d447fc60305c17a17bf20948ab295a45
m_currentHash:
serializedVersion: 2
Hash: a73bab36f6f0172906557a562d766427
Hash: f3899bd8b96717b1b70a2db310a9fcf2
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0
m_CatalogRequestsTimeout: 0
@@ -15,21 +15,28 @@ MonoBehaviour:
m_GroupName: Default Local Group
m_GUID: d447fc60305c17a17bf20948ab295a45
m_SerializeEntries:
- m_GUID: 03e51c504fa7e0624ba855ec35b60bcc
m_Address: absolutely
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 111011400ce13ae859c52c757aef859e
m_Address: ahfreeman
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 144ab5188f8ad7a0a92c75703bd12e60
m_Address: launch_upmenu1
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 16562a5c87213914cad415f10c65a3b0
m_Address: "Assets/Resources_moved/Audio/Music/LASKX3I - \u041F\u0440\u043E\u0442\u0438\u0432
\u0446\u0430\u0440\u044F (\u041A\u0430\u0440\u0430\u043E\u043A\u0435).mp3"
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 170b1a70ddee4d948abea041b9b805e4
m_Address: Assets/Resources_moved/Audio/Music/Half Life Original Soundtrack -
Track 8 - Diabolical Adrenaline Guitar.mp3
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 1d4767c722c05b5d6b96bb226d378c65
m_Address: Assets/Resources_moved/Prefabs/Player/ArmsMesh.prefab
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 1d7110a045075b22fa27d62bd5f2784e
m_Address: 357_shot1
m_ReadOnly: 0
@@ -40,11 +47,6 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 2301400160a23924eb27c4bdbe797739
m_Address: 'Audio/Music/Nightmargin (Oneshot OST) - The Prophecy '
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 23e11d2c8a4f12f4ea9a7a43d1118464
m_Address: Gameplay
m_ReadOnly: 0
@@ -90,6 +92,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 751890caa1647ec6689f24933fbcb770
m_Address: "Prefabs/Furniture/\u0442\u0440\u0443\u0431\u0430"
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 7c5caf3ceee44f71588860c5c1fbdbe0
m_Address: Audio/Dispatcher/take_damage3
m_ReadOnly: 0
@@ -105,6 +112,12 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 8187ea542d6ed824d81230966a3b7499
m_Address: Assets/Resources_moved/Audio/Music/Bauhaus - Bela Lugosi's Dead (No
Vocals Remix).mp3
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 82c71411174bfa86ca1f676b9d389f94
m_Address: bastard!
m_ReadOnly: 0
@@ -130,11 +143,6 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: b2c9f83c47783069aabb564f68cb0cbb
m_Address: absolutelynot
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: b2e8dc2aeb0311cd8a826b51cf8e94dc
m_Address: GameOver
m_ReadOnly: 0
@@ -160,11 +168,6 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: f4b6fa54ecac6cc418f98824491aa17a
m_Address: Audio/Music/SANABI - JUSTICE Is Watching You
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: f74a409bf11b25148ad305acc05b14f5
m_Address: Audio/Dispatcher/take_damage2
m_ReadOnly: 0
@@ -1,41 +1,76 @@
using Code.App.StateMachine;
using Code.Scenes;
using Code.App.StateMachine;
using Code.Gameplay.Player;
using Code.Input;
using Code.StateMachine;
using Code.UI;
using Cysharp.Threading.Tasks;
using Reflex.Core;
using Reflex.Extensions;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
namespace Code.App.AppStates
{
public class GameOverState : BaseState<AppStateMachineContext>
{
public GameOverState(AppStateMachineContext context) : base(context)
{ }
{
}
private IPlayerScore _playerScore;
private GameOverPanel _gameOverPanel;
private float damnTimer = 3f; // TODO Удалить при первой возможности
public override void EnterState()
{
Context.UIService.SwitchPanelTo(UIPanel.GameOver);
Container sceneContainer = SceneManager.GetActiveScene().GetSceneContainer();
_playerScore = sceneContainer.Resolve<IPlayerScore>();
_scoreCounter = 0;
Context.InputService.EnableMap(ActionMappings.UI);
Context.InputService.DebugBindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
GameOver();
base.EnterState();
}
private void TryToExit(InputAction.CallbackContext context)
{
ToMainMenu();
}
private async UniTaskVoid GameOver()
{
await Context.UIService.AsyncSwitchPanelTo(UIPanel.GameOver);
_gameOverPanel = (GameOverPanel)Context.UIService.CurrentPanel;
}
private void ToMainMenu()
{
Context.StateMachine.SwitchState(AppState.MainMenu)
.AllowStateTransition(AppState.Gameplay);
}
private float _scoreCounter;
public override void Tick()
{
damnTimer -= Time.deltaTime;
if (damnTimer <= float.Epsilon) ToMainMenu();
if (!_gameOverPanel) return;
_scoreCounter += Time.deltaTime * 100;
// UnityEngine.Debug.Log($"Score: {_scoreCounter}");
if((int)_scoreCounter >= _playerScore.Score)
{
_gameOverPanel.UpdateScoreText(_playerScore.Score);
}
else _gameOverPanel.UpdateScoreText((int)_scoreCounter);
}
public override void ExitState()
{
damnTimer = 5f;
{
Context.InputService.DisableMap(ActionMappings.UI);
Context.InputService.DebugUnbindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
Context.UIService.LoadingScreen.Show();
base.ExitState();
}
}
@@ -1,16 +1,25 @@
using System.Globalization;
using System.Reflection.Emit;
using System.Threading.Tasks;
using Code.App.Loading;
using Code.App.StateMachine;
using Code.Audio;
using Code.Gameplay.Camera;
using Code.Gameplay.Camera.CameraStates;
using Code.Gameplay.Character.Core;
using Code.Gameplay.Orders.Order;
using Code.Gameplay.Orders.Order;
using Code.Gameplay.Player;
using Code.Input;
using Code.Scenes;
using Code.Scenes.SceneEnvironments;
using Code.StateMachine;
using Code.UI;
using Code.UI.Panels;
using Cysharp.Threading.Tasks;
using Reflex.Core;
using Reflex.Extensions;
using Reflex.Injectors;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
@@ -18,13 +27,12 @@ using UnityEngine.SceneManagement;
namespace Code.App.AppStates
{
public class GameplayState : BaseState<AppStateMachineContext>
{
// DEBUG
private Transform _testSFXTransform;
// DEBUG
{
private PlayerHealth _playerHealth;
private PlayerMoney _playerMoney;
private IPlayerScore _playerScore;
private IOrderService _orderService;
private CharacterProvider _playerCharacter;
@@ -34,98 +42,141 @@ namespace Code.App.AppStates
public override void EnterState()
{
Context.UIService.LoadingScreen.Show();
_playerMoney = Context.PlayerFactory.CreatePlayerMoney();
Context.LoadingManager
.RegisterLoading(LoadingWork.LoadScene)
.RegisterLoading(LoadingWork.LoadUI)
// .RegisterLoading(LoadingWork.LoadModelResource)
.RegisterLoading(LoadingWork.LoadAudio);
_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
_playerHealth.OnDamage += PlayerDamageTaken;
_playerHealth.OnDeath += EndGame;
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Peaceful);
Context.AudioService.TransitToSnapshot(AudioSnapshotState.None);
Context.InputService.EnableMap(ActionMappings.Gameplay);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, GiveHealth);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug3, GiveMoney);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug2, LooseHealth);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, LooseMoney);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, PlayDebugSFX);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug6, PlayDebugDispatcher);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.Gameplay);
Context.LoadingManager.OnLoadingEnded += AfterSceneLoaded;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
WaitForSceneToLoad();
WaitForLoad();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
private async UniTask WaitForPlayerCharacterLoad() => _playerCharacter = await Context.PlayerFactory.CreatePlayer();
private async UniTaskVoid WaitForSceneToLoad()
{
private async UniTaskVoid WaitForLoad()
{
await UniTask.WhenAll(
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.Gameplay),
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
Context.AudioFactory.WarmGameplayMusic(),
Context.AudioFactory.WarmSFX(),
WaitForPlayerCharacterLoad()
);
Context.AudioFactory.WarmDispatcher()
);
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Peaceful);
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Action);
var sceneEnvironment = ((GameplaySceneEnvironment)SceneManager.GetActiveScene()
.GetSceneContainer().Resolve<CurrentSceneEnvironment>());
Context.LoadingManager
.UnregisterLoading(LoadingWork.LoadUI)
.UnregisterLoading(LoadingWork.LoadAudio);
_testSFXTransform = sceneEnvironment.debugSfxTarget;
_playerCharacter.Teleport(sceneEnvironment.playerSpawnPoint.position, sceneEnvironment.playerSpawnPoint.rotation);
((GameplayPanel)Context.UIService.CurrentPanel).Initialize(_playerMoney, _playerHealth);
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(_playerCharacter.GetFollowTransform());
Context.InputService.EnableMap(ActionMappings.Gameplay);
Context.UIService.LoadingScreen.Hide();
InputServiceInitialize();
MusicInitialize();
}
private void OnCharacterSpawn(CharacterProvider characterProvider)
private async void AfterSceneLoaded()
{
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(_playerCharacter.GetFollowTransform());
}
private void PlayDebugSFX(InputAction.CallbackContext context)
{
Context.AudioService.PlaySFX(SFXSounds.Crowbar, _testSFXTransform.position);
}
private void PlayDebugDispatcher(InputAction.CallbackContext context)
{
Context.AudioService.PlayDispatcher(DispatcherSounds.AhFreeman);
}
private void GiveHealth(InputAction.CallbackContext context)
{
_playerHealth.GetDamage(-1);
Context.LoadingManager
.RegisterLoading(LoadingWork.LoadModelResource);
Context.LoadingManager.OnLoadingEnded -= AfterSceneLoaded;
Context.LoadingManager.OnLoadingEnded += AfterPlayerLoaded;
await UniTask.WhenAll(
WaitForPlayerArmsToInitialize(),
WaitForPlayerCharacterLoad()
);
Context.LoadingManager
.UnregisterLoading(LoadingWork.LoadModelResource);
}
private void LooseHealth(InputAction.CallbackContext context)
private void AfterPlayerLoaded()
{
_playerHealth.GetDamage(1);
Container sceneContainer = SceneManager.GetActiveScene().GetSceneContainer();
_playerScore = sceneContainer.Resolve<IPlayerScore>();
GameplaySceneEnvironment sceneEnvironment = SceneEnvironmentVariables(sceneContainer);
PlayerInitialize(sceneEnvironment);
CameraInitialize();
GameplayServicesInitialize(sceneContainer);
UIInitialize();
Context.LoadingManager.OnLoadingEnded -= AfterPlayerLoaded;
_tickEnabled = true;
}
private void GiveMoney(InputAction.CallbackContext context)
private async UniTask WaitForPlayerArmsToInitialize() => _armsMesh = await Context.PlayerFactory.CreateArms(Context.CameraStateMachine.Camera.transform);
private void OrderGiven(float time)
{
_gameplayPanel.ShowTimer();
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Action);
}
private void OrderFailure()
{
_playerMoney.GiveMoney(100);
((GameplayPanel)(Context.UIService.CurrentPanel)).SummonDispatcher();
_playerHealth.InstaKill();
}
private void OrderRecieved(float time)
{
Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.Recieve1,(int)DispatcherSounds.Recieve2));
}
private void OrderDelivered(int score, float time)
{
_gameplayPanel.HideTimer();
if(time < 0f) Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.Late1,(int)DispatcherSounds.Late2));
_playerScore.UpdateScore(score);
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Peaceful);
}
private void LooseMoney(InputAction.CallbackContext context)
private void PlayerDamageTaken(int damage, PlayerHealth health)
{
_playerMoney.LooseMoney(100);
((GameplayPanel)(Context.UIService.CurrentPanel)).CloseDispatcher();
Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.TakeDamage1,(int)DispatcherSounds.TakeDamage4));
}
// DEBUG
private void InstaKillDEBUG(InputAction.CallbackContext context)
{
_playerHealth.InstaKill();
}
private void RoomPassedDEBUG(InputAction.CallbackContext context)
{
_orderService.RoomPassed();
}
private OrderDispenser _debugTube;
private void Tube(InputAction.CallbackContext context)
{
_debugTube.ThrowOrder();
}
// DEBUG
private bool _tickEnabled;
public override void Tick()
{
if (!_tickEnabled) return;
_orderService.DecreaseTimer(Time.deltaTime);
}
private void EndGame()
@@ -137,23 +188,77 @@ namespace Code.App.AppStates
public override void ExitState()
{
_playerHealth = null;
_playerMoney = null;
_playerScore = null;
_tickEnabled = false;
Context.PlayerFactory.ReleasePlayer(_playerCharacter);
_playerCharacter = null;
Context.PlayerFactory.ReleaseArms(_armsMesh);
_armsMesh = null;
_orderService = null;
Context.AudioService.OnDispatcherStarted -= _gameplayPanel.SummonDispatcher;
Context.AudioService.OnDispatcherEnded -= _gameplayPanel.CloseDispatcher;
Context.InputService.DisableMap(ActionMappings.Gameplay);
Context.AudioService.GladlyAskToStopMusic(MusicType.Action, callback: Context.AudioFactory.ReleaseActionMusic);
Context.AudioService.GladlyAskToStopMusic(MusicType.Peaceful, callback: Context.AudioFactory.ReleasePeacefulMusic);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, GiveHealth);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug3, GiveHealth);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug2, LooseHealth);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, LooseMoney);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, PlayDebugSFX);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug6, PlayDebugDispatcher);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
base.ExitState();
}
private void InputServiceInitialize()
{
Context.InputService.EnableMap(ActionMappings.Gameplay);
}
private void CameraInitialize()
{
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(_playerCharacter.GetFollowTransform());
}
private GameplayPanel _gameplayPanel;
private ArmsMeshProvider _armsMesh;
private void UIInitialize()
{
_gameplayPanel = (GameplayPanel)Context.UIService.CurrentPanel;
_gameplayPanel.Initialize(_playerScore, _playerHealth, _orderService);
Context.AudioService.OnDispatcherStarted += _gameplayPanel.SummonDispatcher;
Context.AudioService.OnDispatcherEnded += _gameplayPanel.CloseDispatcher;
}
private void MusicInitialize()
{
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Peaceful);
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Action);
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Peaceful);
}
private void PlayerInitialize(GameplaySceneEnvironment sceneEnvironment)
{
_playerCharacter.Teleport(sceneEnvironment.playerSpawnPoint.position, sceneEnvironment.playerSpawnPoint.rotation);
_playerCharacter.PlayerAnimator.SetAnimator(_armsMesh.ArmsAnimator);
}
private void GameplayServicesInitialize(Container sceneContainer)
{
_orderService = sceneContainer.Resolve<IOrderService>();
_orderService.OnOrderGiven += OrderGiven;
_orderService.OnOrderRecieved += OrderRecieved;
_orderService.OnOrderDelivered += OrderDelivered;
_orderService.OnOrderFailure += OrderFailure;
}
private GameplaySceneEnvironment SceneEnvironmentVariables(Container sceneContainer)
{
var sceneEnvironment = (GameplaySceneEnvironment)sceneContainer.Resolve<CurrentSceneEnvironment>();
_debugTube = sceneEnvironment.debugTube;
return sceneEnvironment;
}
}
}
@@ -1,12 +1,15 @@
using Code.App.Loading;
using Code.App.StateMachine;
using Code.Audio;
using Code.Gameplay.Camera;
using Code.Gameplay.Camera.CameraStates;
using Code.Gameplay.Door;
using Code.Input;
using Code.Scenes;
using Code.Scenes.SceneEnvironments;
using Code.StateMachine;
using Code.UI;
using Code.UI.Panels;
using Cysharp.Threading.Tasks;
using Reflex.Extensions;
using UnityEngine;
@@ -22,40 +25,79 @@ namespace Code.App.AppStates
public override void EnterState()
{
Context.UIService.LoadingScreen.Show();
Context.LoadingManager
.RegisterLoading(LoadingWork.LoadScene)
.RegisterLoading(LoadingWork.LoadUI)
.RegisterLoading(LoadingWork.LoadAudio);
// Context.UIService.LoadingScreen.Show();
Context.CameraStateMachine.SwitchState(CameraMode.MainMenu);
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.MainMenu);
Context.LoadingManager.OnLoadingEnded += AfterSceneLoaded;
Context.CameraStateMachine.SwitchState(CameraMode.Static);
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
WaitForSceneToLoad();
WaitForLoad();
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
private async UniTaskVoid WaitForSceneToLoad()
private async UniTaskVoid WaitForLoad()
{
await UniTask.WhenAll(
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.MainMenu),
Context.UIService.AsyncSwitchPanelTo(UIPanel.MainMenu),
Context.AudioFactory.WarmMenuMusic()
);
);
Context.LoadingManager
.UnregisterLoading(LoadingWork.LoadUI)
.UnregisterLoading(LoadingWork.LoadAudio);
InitializeAudio();
InitializeInput();
}
private void AfterSceneLoaded()
{
var mainMenuEnvironment = (MainMenuEnvironment)SceneManager.GetActiveScene()
.GetSceneContainer().Resolve<CurrentSceneEnvironment>();
InitializeUI(mainMenuEnvironment);
InitializeCamera(mainMenuEnvironment);
Context.LoadingManager.OnLoadingEnded -= AfterSceneLoaded;
}
private void InitializeCamera(MainMenuEnvironment mainMenuEnvironment)
{
((Gameplay.Camera.CameraStates.MainMenuState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(mainMenuEnvironment
.cameraPosition);
}
private void InitializeInput()
{
Context.InputService.EnableMap(ActionMappings.MainMenu);
}
private void InitializeAudio()
{
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Menu);
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Menu);
}
((MainMenuPanel)Context.UIService.CurrentPanel).startButton.onClick.AddListener(StartGame);
((MainMenuPanel)Context.UIService.CurrentPanel).exitButton.onClick.AddListener(ExitGame);
private void InitializeUI(MainMenuEnvironment mainMenuEnvironment)
{
var menuPanel = (MainMenuPanel)Context.UIService.CurrentPanel;
menuPanel.Initialize(mainMenuEnvironment.uiVariables,
mainMenuEnvironment.startButton,
mainMenuEnvironment.settingButton,
mainMenuEnvironment.exitButton);
var hui = ((MainMenuEnvironment)SceneManager.GetActiveScene()
.GetSceneContainer().Resolve<CurrentSceneEnvironment>());
((StaticState)Context.CameraStateMachine.CurrentBaseState).LookTarget =
hui.cameraTarget;
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(hui.cameraPosition);
menuPanel.startButton.button.onClick.AddListener(StartGame);
menuPanel.exitButton.button.onClick.AddListener(ExitGame);
Context.UIService.LoadingScreen.Hide();
Context.InputService.EnableMap(ActionMappings.MainMenu);
mainMenuEnvironment.menuButtonsCanvas.worldCamera = Context.CameraStateMachine.Camera;
}
public override void Tick()
@@ -76,8 +118,8 @@ namespace Code.App.AppStates
public override void ExitState()
{
Context.InputService.DisableMap(ActionMappings.MainMenu);
Context.AudioService.GladlyAskToStopMusic(MusicType.Menu, callback: Context.AudioFactory.ReleaseMenuMusic);
Context.AudioService.GladlyAskToStopMusic(MusicType.Menu, callback: Context.AudioFactory.ReleaseMenuMusic);
base.ExitState();
}
}
@@ -1,8 +1,11 @@
using System.Collections.Generic;
using Code.App.Loading;
using Code.App.StateMachine;
using Code.Audio;
using Code.Configs;
using Code.Constants;
using Code.Gameplay.Camera;
using Code.Gameplay.Orders.Order;
using Code.Gameplay.Player;
using Code.Input;
using Code.Scenes;
@@ -25,10 +28,13 @@ namespace Code.App
InstallInfrastructureUnit(containerBuilder, staticDataService);
containerBuilder.AddSingleton(typeof(LoadingManager), typeof(ILoadingManager));
containerBuilder.AddSingleton(typeof(InputService), typeof(IInputService));
containerBuilder.AddSingleton(typeof(PlayerFactory), typeof(IPlayerFactory));
InitializeCamera(containerBuilder, staticDataService);
containerBuilder.AddSingleton(typeof(UIFactory), typeof(IUIFactory));
containerBuilder.AddSingleton(typeof(UIService), typeof(IUIService));
@@ -71,6 +77,7 @@ namespace Code.App
containerBuilder.AddSingleton(staticDataService.InputConfig, typeof(InputConfig));
containerBuilder.AddSingleton(staticDataService.CameraConfig, typeof(CameraConfig));
containerBuilder.AddSingleton(staticDataService.CameraSettingsConfigs, typeof(Dictionary<CameraMode,CameraSettingsConfig>));
containerBuilder.AddSingleton(staticDataService.PlayerConfig, typeof(PlayerConfig));
containerBuilder.AddSingleton(staticDataService.CharacterConfig, typeof(CharacterConfig));
@@ -82,6 +89,10 @@ namespace Code.App
containerBuilder.AddSingleton(staticDataService.SFXListConfig, typeof(SFXListConfig));
containerBuilder.AddSingleton(staticDataService.DispatcherSoundListConfig, typeof(DispatcherSoundListConfig));
containerBuilder.AddSingleton(staticDataService.EnemiesSoundListConfig, typeof(EnemiesSoundListConfig));
containerBuilder.AddSingleton(staticDataService.AudioSourceSettingsConfigs, typeof(Dictionary<AudioSourceType, AudioSourceSettingsConfig>));
containerBuilder.AddSingleton(staticDataService.OrderServiceConfig, typeof(OrderServiceConfig));
containerBuilder.AddSingleton(staticDataService.OrderBoxConfig, typeof(OrderBoxConfig));
}
private AppStateMachine _appStateMachine;
@@ -98,19 +109,26 @@ namespace Code.App
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
BootstrapFinish(container);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
private async UniTaskVoid BootstrapFinish(Container container)
{
var loadingScreen = GameObject.FindWithTag(Tags.LoadingScreen);
DontDestroyOnLoad(loadingScreen);
var loadingScreen = GameObject.FindWithTag(Tags.LoadingScreen).GetComponent<LoadingScreen>();
DontDestroyOnLoad(loadingScreen.gameObject);
ILoadingManager loadingManager = container.Resolve<ILoadingManager>();
loadingManager.OnLoadingStarted += loadingScreen.Show;
loadingManager.OnLoadingEnded += loadingScreen.Hide;
loadingManager.RegisterLoading(LoadingWork.Bootstrap);
await UniTask.WhenAll(
container.Resolve<IUIService>().Initialize(loadingScreen.GetComponent<LoadingScreen>()),
container.Resolve<IUIService>().Initialize(loadingScreen),
container.Resolve<IAudioService>().Initialize()
);
loadingManager.UnregisterLoading(LoadingWork.Bootstrap);
_appStateMachine
.SwitchState(AppState.MainMenu)
.AllowStateTransition(AppState.Gameplay);
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 08b54658296d4279b85a2bfc3cf10e62
timeCreated: 1763842256
@@ -0,0 +1,16 @@
using System.Collections.ObjectModel;
using Cysharp.Threading.Tasks;
namespace Code.App.Loading
{
public interface ILoadingManager
{
delegate void OnLoadingDelegate();
event OnLoadingDelegate OnLoadingStarted;
event OnLoadingDelegate OnLoadingEnded;
ReadOnlyCollection<LoadingWork> LoadingThings { get; }
LoadingManager RegisterLoading(LoadingWork loadingThingName);
LoadingManager UnregisterLoading(LoadingWork loadingThingName);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: bfb3837590d04da3b04ca8b0f0aca437
timeCreated: 1763842985
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Cysharp.Threading.Tasks;
namespace Code.App.Loading
{
public class LoadingManager : ILoadingManager
{
public event ILoadingManager.OnLoadingDelegate OnLoadingStarted;
public event ILoadingManager.OnLoadingDelegate OnLoadingEnded;
private List<LoadingWork> _loadingThings = new();
public ReadOnlyCollection<LoadingWork> LoadingThings => _loadingThings.AsReadOnly();
public LoadingManager RegisterLoading(LoadingWork loadingThingName)
{
if(_loadingThings.Count == 0) OnLoadingStarted?.Invoke();
_loadingThings.Add(loadingThingName);
return this;
}
public LoadingManager UnregisterLoading(LoadingWork loadingThingName)
{
_loadingThings.Remove(loadingThingName);
if(_loadingThings.Count == 0) OnLoadingEnded?.Invoke();
return this;
}
}
// public static class LoadingManagerExtensions
// {
// public static LoadingManager AddLoading(this LoadingManager manager, LoadingWork loadingThingName)
// {
// manager.RegisterLoading(loadingThingName);
// return manager;
// }
// public static LoadingManager RemoveLoading(this LoadingManager manager, LoadingWork loadingThingName)
// {
// manager.UnregisterLoading(loadingThingName);
// return manager;
// }
// }
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 185988ac74a24a39864238cd7f5cb626
timeCreated: 1763842268
@@ -0,0 +1,12 @@
namespace Code.App.Loading
{
public enum LoadingWork
{
Bootstrap,
LoadUI,
LoadAudio,
LoadScene,
LoadModelResource,
WaitingForTime
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 318d1b29b41d4b96bc09334acbf36506
timeCreated: 1763843934
@@ -1,7 +1,11 @@
using Code.App.Loading;
using Code.Gameplay.Orders.Order;
using Code.Gameplay.Player;
using Code.Scenes;
using Code.Scenes.SceneEnvironments;
using Reflex.Core;
using UnityEngine;
using IPlayerScore = Code.Gameplay.Player.IPlayerScore;
namespace Code.App.SceneInstallers
{
@@ -12,15 +16,22 @@ namespace Code.App.SceneInstallers
public void InstallBindings(ContainerBuilder containerBuilder)
{
containerBuilder.AddScoped(typeof(GameplaySceneEnvironment), typeof(CurrentSceneEnvironment));
containerBuilder.AddScoped(typeof(PlayerScore), typeof(IPlayerScore));
containerBuilder.AddScoped(typeof(OrderService), typeof(IOrderService));
containerBuilder.OnContainerBuilt += Initialize;
}
private void Initialize(Container container)
{
GameplaySceneEnvironment env = (GameplaySceneEnvironment)container.Resolve<CurrentSceneEnvironment>();
ILoadingManager loadingManager = container.Resolve<ILoadingManager>();
GameplaySceneEnvironment env = (GameplaySceneEnvironment)container.Resolve<CurrentSceneEnvironment>();
env.TransitVariables(_gameplaySceneEnvironment);
loadingManager
.UnregisterLoading(LoadingWork.LoadScene);
}
}
}
@@ -1,8 +1,8 @@
using Code.App.Loading;
using Code.Scenes;
using Code.Scenes.SceneEnvironments;
using Reflex.Core;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine;
namespace Code.App.SceneInstallers
{
@@ -22,6 +22,11 @@ namespace Code.App.SceneInstallers
MainMenuEnvironment env = (MainMenuEnvironment)container.Resolve<CurrentSceneEnvironment>();
env.TransitVariables(_mainMenuEnvironment);
ILoadingManager loadingManager = container.Resolve<ILoadingManager>();
loadingManager
.UnregisterLoading(LoadingWork.LoadScene);
}
}
}
@@ -1,3 +1,4 @@
using Code.App.Loading;
using Code.Audio;
using Code.Gameplay.Camera;
using Code.Gameplay.Player;
@@ -10,6 +11,7 @@ namespace Code.App.StateMachine
{
public class AppStateMachineContext
{
[Inject] public ILoadingManager LoadingManager { get; private set; }
[Inject] public ISceneLoaderService SceneLoaderService { get; private set; }
[Inject] public IInputService InputService { get; private set; }
[Inject] public AppStateMachine StateMachine { get; private set; }
@@ -16,8 +16,16 @@ namespace Code.Audio
}
public enum DispatcherSounds
{
Absolutely,
AbsolutelyNot,
AhFreeman
Recieve1,
Recieve2,
TakeDamage1,
TakeDamage2,
TakeDamage3,
TakeDamage4,
Late1,
Late2,
Late3,
Late4,
Late5
}
}
@@ -62,8 +62,8 @@ namespace Code.Audio
public async UniTask WarmGameplayMusic( )
{
_actionMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_actionSoundtrack, OnActionTrackLoaded, Addressables.MergeMode.None);
_peacefulMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_peacefulSoundtrack, OnPeacefulTrackLoaded, Addressables.MergeMode.None);
_actionMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_actionSoundtrack, OnActionTrackLoaded, Addressables.MergeMode.Union);
_peacefulMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_peacefulSoundtrack, OnPeacefulTrackLoaded, Addressables.MergeMode.Union);
await UniTask.WhenAll(_actionMusicHandle.ToUniTask(), _peacefulMusicHandle.ToUniTask());
}
@@ -79,7 +79,7 @@ namespace Code.Audio
}
public async UniTask WarmMenuMusic( )
{
_menuMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_menuSoundtrack, OnMenuTrackLoaded, Addressables.MergeMode.None);
_menuMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_menuSoundtrack, OnMenuTrackLoaded, Addressables.MergeMode.Union);
// foreach (var assetReference in _menuSoundtrack) MenuMusic.Add(await assetReference.LoadAssetAsync<AudioClip>());
await _menuMusicHandle.ToUniTask();
@@ -92,7 +92,7 @@ namespace Code.Audio
}
public async UniTask WarmSFX( )
{
_SFXHandle = Addressables.LoadAssetsAsync<AudioClip>(_SFX, OnSFXLoaded, Addressables.MergeMode.None);
_SFXHandle = Addressables.LoadAssetsAsync<AudioClip>(_SFX, OnSFXLoaded, Addressables.MergeMode.Union);
await _SFXHandle.ToUniTask();
@@ -104,7 +104,7 @@ namespace Code.Audio
}
public async UniTask WarmEnemies( )
{
_enemiesHandle = Addressables.LoadAssetsAsync<AudioClip>(_enemies, OnEnemiesLoaded, Addressables.MergeMode.None);
_enemiesHandle = Addressables.LoadAssetsAsync<AudioClip>(_enemies, OnEnemiesLoaded, Addressables.MergeMode.Union);
await _enemiesHandle.ToUniTask();
@@ -118,7 +118,7 @@ namespace Code.Audio
public async UniTask WarmDispatcher( )
{
_dispatcherHandle = Addressables.LoadAssetsAsync<AudioClip>(_dispatcher, OnDispatcherLoaded, Addressables.MergeMode.None);
_dispatcherHandle = Addressables.LoadAssetsAsync<AudioClip>(_dispatcher, OnDispatcherLoaded, Addressables.MergeMode.Union);
await _dispatcherHandle.ToUniTask();
@@ -31,13 +31,16 @@ namespace Code.Audio
_courierGroup,
_enemiesGroup;
private readonly AudioSourcePool _audioSourcePool = new();
private readonly AudioSourcePool _audioSourcePool;
private Dictionary<AudioSnapshotState, AudioMixerSnapshot> _snapshots = new();
public AudioService(IAudioFactory audioFactory)
private Dictionary<AudioSourceType, AudioSourceSettingsConfig> _settings;
public AudioService(IAudioFactory audioFactory, Dictionary<AudioSourceType,AudioSourceSettingsConfig> settings)
{
_audioFactory = audioFactory;
_audioSourcePool = new(settings);
_settings = settings;
}
public async UniTask Initialize()
@@ -86,7 +89,7 @@ namespace Code.Audio
if(!_musicAudioSources[musicType])
{
_musicAudioSources[musicType] = _audioSourcePool.GetSource();
_musicAudioSources[musicType].spatialBlend = 0f;
_musicAudioSources[musicType].spatialBlend = _settings[AudioSourceType.NoBlend].spatialBlend;
_musicAudioSources[musicType].outputAudioMixerGroup = _musicAudioGroups[musicType];
}
@@ -164,9 +167,13 @@ namespace Code.Audio
_audioSourcePool.PlayOneShot(_audioFactory.EnemiesAudios[(int)enemySoundId], position, _enemiesGroup);
}
// Чинить долго и дорого пусть Артёмов будет много, ведь он наш друг
public event IAudioService.OnAudioPlayingDelegate OnDispatcherStarted;
public event IAudioService.OnAudioPlayingDelegate OnDispatcherEnded;
public void PlayDispatcher(DispatcherSounds dispatcherSoundId)
{
_audioSourcePool.PlayShizo(_audioFactory.DispatcherAudios[(int)dispatcherSoundId], _dispatcherGroup);
OnDispatcherStarted?.Invoke();
_audioSourcePool.PlayOneShot(_audioFactory.DispatcherAudios[(int)dispatcherSoundId], _dispatcherGroup, AudioSourceType.NoBlend, () => OnDispatcherEnded?.Invoke());
}
}
}
@@ -1,119 +0,0 @@
using System.Collections.Generic;
using Code.Constants;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Serialization;
namespace Code.Audio
{
public class AudioServiceDebug : MonoBehaviour
{
[SerializeField] private AudioMixer mixer;
private AudioSource _actionMusicSource;
private AudioSource _peacefulMusicSource;
[SerializeField] private AudioSource prefab;
[SerializeField] private AudioResource[] peacefulAudio;
[SerializeField] private AudioResource[] actionAudio;
private AudioMixerGroup _masterGroup,
_musicGroup,
_actionMusicGroup,
_peacefulMusicGroup,
_SFXGroup,
_creaturesGroup,
_dispatcherGroup,
_courierGroup,
_enemiesGroup;
private readonly AudioSourcePool _audioSourcePool = new();
private Dictionary<AudioSnapshotState, AudioMixerSnapshot> _snapshots = new();
[FormerlySerializedAs("sfxAudio")] [SerializeField] private AudioClip[] sfxAudios;
[SerializeField] private AudioClip[] enemiesAudios;
[SerializeField] private AudioClip[] dispatcherAudios;
private void MixerCreated()
{
_masterGroup = mixer.FindMatchingGroups(AudioGroups.MasterGroup)[0];
_actionMusicGroup = mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0];
_peacefulMusicGroup = mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0];
_SFXGroup = mixer.FindMatchingGroups(AudioGroups.SFXGroup)[0];
_musicGroup = mixer.FindMatchingGroups(AudioGroups.MusicGroup)[0];
_creaturesGroup = mixer.FindMatchingGroups(AudioGroups.CreaturesGroup)[0];
_dispatcherGroup = mixer.FindMatchingGroups(AudioGroups.DispatcherMusicGroup)[0];
_courierGroup = mixer.FindMatchingGroups(AudioGroups.CourierMusicGroup)[0];
_enemiesGroup = mixer.FindMatchingGroups(AudioGroups.EnemiesMusicGroup)[0];
_snapshots[AudioSnapshotState.Peaceful] = mixer.FindSnapshot(AudioGroups.PeacefulSnapshot);
_snapshots[AudioSnapshotState.Action] = mixer.FindSnapshot(AudioGroups.ActionSnapshot);
// _audioSourcePool.Initialize(10,prefab);
InitializeMusicSources();
}
private void InitializeMusicSources()
{
_actionMusicSource = _audioSourcePool.GetSource();
_actionMusicSource.outputAudioMixerGroup = _actionMusicGroup;
_actionMusicSource.spatialBlend = 0f;
_peacefulMusicSource = _audioSourcePool.GetSource();
_peacefulMusicSource.outputAudioMixerGroup = _peacefulMusicGroup;
_peacefulMusicSource.spatialBlend = 0f;
}
private void Start()
{
MixerCreated();
}
public void PlayRandomGameplayMusic()
{
_peacefulMusicSource.resource = peacefulAudio[Random.Range(0, peacefulAudio.Length)];
_actionMusicSource.resource = actionAudio[Random.Range(0, actionAudio.Length)];
_peacefulMusicSource.Play();
_actionMusicSource.Play();
}
public void TransitToSnapshot(AudioSnapshotState state)
{
_snapshots[state].TransitionTo(1f);
}
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
public void PlaySFX(SFXSounds sfxId, Vector3 position)
{
_audioSourcePool.PlayOneShot(sfxAudios[(int)sfxId], position, _SFXGroup);
}
public void PlayDebugSFX()
{
_audioSourcePool.PlayOneShot(sfxAudios[(int)SFXSounds.Crowbar], transform.position, _SFXGroup);
}
public void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position)
{
_audioSourcePool.PlayOneShot(enemiesAudios[(int)enemySoundId], position, _enemiesGroup);
}
public void PlayDebugEnemySFX()
{
_audioSourcePool.PlayOneShot(enemiesAudios[(int)EnemiesSounds.Bastard], transform.position, _enemiesGroup);
}
public void PlayDispatcher(DispatcherSounds dispatcherSoundId)
{
_audioSourcePool.PlayShizo(dispatcherAudios[(int)dispatcherSoundId], _dispatcherGroup);
}
public void PlayDebugDispatcherSFX()
{
_audioSourcePool.PlayShizo(dispatcherAudios[(int)DispatcherSounds.AhFreeman], _dispatcherGroup);
}
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
}
}
@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: a42cad8f28f54a53bef23d9313014abd
timeCreated: 1762805867
@@ -1,7 +1,11 @@
using System;
using System.Collections.Generic;
using Code.Configs;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Pool;
using Object = UnityEngine.Object;
namespace Code.Audio
{
@@ -10,7 +14,11 @@ namespace Code.Audio
// The pool holds plain GameObjects (you can swap this for any component type).
private IObjectPool<AudioSource> _pool;
private GameObject _sourcePrefab;
private Dictionary<AudioSourceType, AudioSourceSettingsConfig> _settings;
public AudioSourcePool(Dictionary<AudioSourceType, AudioSourceSettingsConfig> settings) => _settings = settings;
public void Initialize(GameObject sourcePrefab)
{
_sourcePrefab = sourcePrefab;
@@ -54,30 +62,30 @@ namespace Code.Audio
{
Object.Destroy(source.gameObject);
}
public async UniTaskVoid PlayOneShot(AudioClip clip, Vector3 position, AudioMixerGroup audioMixerGroup)
public async UniTaskVoid PlayOneShot(AudioClip clip, Vector3 position, AudioMixerGroup audioMixerGroup, AudioSourceType audioSourceType = AudioSourceType.NoBlend, Action onComplete = null)
{
AudioSource source = _pool.Get();
source.PlayOneShot(clip);
source.spatialBlend = 1f;
source.spatialBlend = _settings[audioSourceType].spatialBlend;
source.transform.position = position;
source.outputAudioMixerGroup = audioMixerGroup;
await UniTask.WaitUntilValueChanged(source, x => x.isPlaying);
onComplete?.Invoke();
_pool.Release(source);
}
public async UniTaskVoid PlayShizo(AudioClip clip, AudioMixerGroup audioMixerGroup)
public async UniTaskVoid PlayOneShot(AudioClip clip, AudioMixerGroup audioMixerGroup, AudioSourceType audioSourceType = AudioSourceType.NoBlend, Action onComplete = null)
{
AudioSource source = _pool.Get();
source.PlayOneShot(clip);
source.spatialBlend = 0f;
source.spatialBlend = _settings[audioSourceType].spatialBlend;
source.outputAudioMixerGroup = audioMixerGroup;
await UniTask.WaitUntilValueChanged(source, x => x.isPlaying);
onComplete?.Invoke();
_pool.Release(source);
}
}
public AudioSource GetSource() => _pool.Get();
public void ReleaseSource(AudioSource source) => _pool.Release(source);
}
@@ -0,0 +1,8 @@
namespace Code.Audio
{
public enum AudioSourceType
{
Full3D,
NoBlend
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 260bbb19b55049928b9ab4d55b32fc3f
timeCreated: 1763849966
@@ -14,6 +14,11 @@ namespace Code.Audio
void TransitToSnapshot(AudioSnapshotState state, float time = 1f);
void PlaySFX(SFXSounds sfxId, Vector3 position);
void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position);
delegate void OnAudioPlayingDelegate();
event OnAudioPlayingDelegate OnDispatcherStarted;
event OnAudioPlayingDelegate OnDispatcherEnded;
void PlayDispatcher(DispatcherSounds dispatcherSoundId);
}
}
@@ -0,0 +1,14 @@
using Code.Audio;
using UnityEngine;
namespace Code.Configs
{
[CreateAssetMenu(fileName = "AudioSourceSettingsConfig", menuName = "Audio/AudioSourceSettingsConfig")]
public class AudioSourceSettingsConfig : ScriptableObject
{
// Дополнять по мере необходимости
public float spatialBlend;
public AudioSourceType sourceType;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e6406ab390b74d5ca336d7d4d0e1a732
timeCreated: 1763850008
@@ -0,0 +1,14 @@
using Code.Gameplay.Camera;
using UnityEngine;
namespace Code.Configs
{
[CreateAssetMenu(fileName = "CameraSettingsConfig", menuName = "Config/CameraSettingsConfig")]
public class CameraSettingsConfig : ScriptableObject
{
// Дополнять по мере необходимости
public float fov;
public CameraMode cameraMode;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6610b94e9823401c94533e1756a97195
timeCreated: 1763846744
@@ -0,0 +1,12 @@
using UnityEngine;
namespace Code.Configs
{
[CreateAssetMenu(menuName = "Config/Gameplay/OrderBox", fileName = "OrderBoxConfig")]
public class OrderBoxConfig : ScriptableObject
{
public float activationTime;
public AnimationCurve floatingCurve;
public float curveLength;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6af4f53d425a41c78ef889fd7e5c3197
timeCreated: 1763735968
@@ -0,0 +1,11 @@
using UnityEngine;
namespace Code.Configs
{
[CreateAssetMenu(fileName = "OrderServiceConfig", menuName = "Config/Gameplay/OrderServiceConfig")]
public class OrderServiceConfig : ScriptableObject
{
public Vector2 timeBounds;
public float koefRooms, koefOvertime;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ee2550c3e4874575ac3aecadfcc42475
timeCreated: 1763559999
@@ -9,5 +9,6 @@ namespace Code.Configs
public int maxHealth;
public AssetReference characterPrefab;
public AssetReference armsMeshPrefab;
}
}
@@ -10,8 +10,9 @@ namespace Code.Gameplay.Camera
*/
public enum CameraMode
{
Bogdan,
None,
Static,
MainMenu,
FirstPerson,
ThirdPerson,
Cinematic
@@ -9,13 +9,16 @@ namespace Code.Gameplay.Camera
// Текущий режим работы камеры
public override void Initialize()
{
States.Add(CameraMode.None, new NoneState(StateMachineContext));
States.Add(CameraMode.Static, new StaticState(StateMachineContext));
States.Add(CameraMode.MainMenu, new MainMenuState(StateMachineContext));
States.Add(CameraMode.FirstPerson, new FirstPersonState(StateMachineContext));
States.Add(CameraMode.ThirdPerson, new ThirdPersonState(StateMachineContext));
CurrentBaseState = States[CameraMode.Static];
CurrentBaseState = States[CameraMode.None];
}
public UnityEngine.Camera Camera => StateMachineContext.Camera;
protected override bool CheckTransitionAllowed(CameraMode nextState) => true;
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using Code.Configs;
using Code.Input;
using Reflex.Attributes;
@@ -9,5 +10,6 @@ namespace Code.Gameplay.Camera
[Inject] public UnityEngine.Camera Camera;
[Inject] public CameraConfig Config;
[Inject] public IInputService InputService;
[Inject] public Dictionary<CameraMode,CameraSettingsConfig> CameraSettingsConfigs;
}
}
@@ -14,14 +14,16 @@ namespace Code.Gameplay.Camera.CameraStates
public override void EnterState()
{
base.EnterState();
// В FirstPerson режиме дистанция всегда равна 0
MinDistance = 0f;
MaxDistance = 0f;
DefaultDistance = 0f;
TargetDistance = 0f;
CurrentDistance = 0f;
base.EnterState();
Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.FirstPerson].fov;
}
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
@@ -0,0 +1,30 @@
using UnityEngine;
namespace Code.Gameplay.Camera.CameraStates
{
public class MainMenuState : BaseCameraState, ICameraState
{
public MainMenuState(CameraStateMachineContext context) : base(context) { }
public override void EnterState()
{
base.EnterState();
Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.MainMenu].fov;
}
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
{
Camera.transform.position = FollowTransform.position;
}
public CameraMode GetCameraMode() => CameraMode.MainMenu;
protected override void HandleRotationInput(float deltaTime, Vector3 rotationInput,
out Quaternion targetRotation)
{
if(FollowTransform) Camera.transform.rotation = FollowTransform.rotation;
targetRotation = Camera.transform.rotation;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8e4b2fa3af4b4ba78ab79ca154f05fb4
timeCreated: 1763547110
@@ -0,0 +1,21 @@
using UnityEngine;
namespace Code.Gameplay.Camera.CameraStates
{
public class NoneState : BaseCameraState, ICameraState
{
public NoneState(CameraStateMachineContext context) : base(context) { }
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
{
}
public CameraMode GetCameraMode() => CameraMode.None;
protected override void HandleRotationInput(float deltaTime, Vector3 rotationInput,
out Quaternion targetRotation)
{
targetRotation = Quaternion.identity;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d8fa6119113f4f12a35365fd27387124
timeCreated: 1763847889
@@ -9,8 +9,9 @@ namespace Code.Gameplay.Camera.CameraStates
public override void EnterState()
{
Debug.Log("Static State Enter");
base.EnterState();
Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.Static].fov;
}
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
@@ -14,13 +14,13 @@ namespace Code.Gameplay.Camera.CameraStates
public override void EnterState()
{
base.EnterState();
// Восстанавливаем исходные значения дистанции
MinDistance = OriginalMinDistance;
MaxDistance = OriginalMaxDistance;
DefaultDistance = OriginalDefaultDistance;
TargetDistance = DefaultDistance;
base.EnterState();
}
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
@@ -180,7 +180,6 @@ namespace Code.Gameplay.Character.Controller
// Заготовка на будущее (если понадобится)
case CameraMode.Static:
case CameraMode.Cinematic:
case CameraMode.Bogdan: // Скорее всего юзлес, но пускай будет
default:
break;
}
@@ -1,6 +1,7 @@
using Code.Gameplay.Camera;
using Code.Gameplay.Camera.CameraStates;
using Code.Gameplay.Character.Controller;
using Code.Gameplay.Player;
using Code.Input;
using Reflex.Attributes;
using UnityEngine;
@@ -18,6 +19,9 @@ namespace Code.Gameplay.Character.Core
[Inject] private IInputService _inputService; // Сервис ввода через DI
[SerializeField] private PlayerAnimator _animator;
public PlayerAnimator PlayerAnimator => _animator;
public void Teleport(Vector3 position, Quaternion rotation)
{
customCharacterController.SetPosition(position);
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b7ba7b62b1aa47c48dc82ac8d8e8530e
timeCreated: 1763548306
@@ -0,0 +1,48 @@
using DG.Tweening;
using UnityEngine;
namespace Code.Gameplay.Door
{
public class CinematicDoorOpening
{
private MainMenuDoor _mainMenuDoor;
private Light _doorLight;
public CinematicDoorOpening(MainMenuDoor mainMenuDoor, Light doorLight)
{
_mainMenuDoor = mainMenuDoor;
_doorLight = doorLight;
}
public void PreOpen(int type)
{
switch (type)
{
case 0:
_doorLight.DOColor(Color.green, 0.2f);
break;
case 1:
_doorLight.DOColor(Color.yellow, 0.2f);
break;
case 2:
_doorLight.DOColor(Color.red, 0.2f);
break;
}
_mainMenuDoor.Petlya.DORotate(new Vector3(0, -10, 0), 1f);
}
public void Close()
{
_mainMenuDoor.Petlya.DORotate(new Vector3(0, 0, 0), 1f);
}
}
[System.Serializable]
public class MainMenuUIVariables
{
public MainMenuDoor MainMenuDoor;
public Light DoorLight;
public Color ButtonDefaultColor;
public Color ButtonHoverColor;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: deda0339570d44609dd62eafd9c6215f
timeCreated: 1763548908
@@ -0,0 +1,16 @@
using UnityEngine;
namespace Code.Gameplay.Door
{
public class MainMenuDoor : MonoBehaviour
{
[SerializeField] Rigidbody rigidbody;
[SerializeField] private Transform petlya;
public Transform Petlya => petlya;
public void SetPhysics(bool active)
{
rigidbody.isKinematic = active;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 50a6b5e332704611b19f5a209d4dbffe
timeCreated: 1763548314
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e41c28f7828a44b7bc26d87886064d99
timeCreated: 1763556651
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4911436131e345ada949f2418595bbd8
timeCreated: 1763559099
@@ -0,0 +1,25 @@
namespace Code.Gameplay.Orders.Order
{
public interface IOrderService
{
delegate void OrderFailureDelegate();
delegate void OrderProgressDelegate(float time);
event OrderProgressDelegate OnOrderGiven;
event OrderProgressDelegate OnOrderRecieved;
event OrderFailureDelegate OnOrderFailure;
delegate void OrderDeliveredDelegate(int score, float time);
event OrderDeliveredDelegate OnOrderDelivered;
OrderState OrderState { get; }
float DeliveryTimer { get; }
void RoomPassed();
void DecreaseTimer(float delta);
void OrderGive();
void OrderRecieved();
void OrderDelivered();
void OrderFailed();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8b4467951c884c8dafeb633020696c24
timeCreated: 1763561686
@@ -0,0 +1,65 @@
using System;
using Code.Configs;
using Code.Gameplay.Orders.Order;
using Cysharp.Threading.Tasks;
using Reflex.Attributes;
using UnityEngine;
namespace Code.Gameplay.Orders.Order
{
public class OrderBox : MonoBehaviour
{
[Inject] private IOrderService _orderService;
public Rigidbody rigidbody;
private bool _pickupMode;
// [SerializeField] private AnimationCurve debugCurve;
//DEBUG
// private void Start()
// {
// _capturedPosition = transform.position;
// _floatingCurve = debugCurve;
// _curveLength = 1f;
// }
// DEBUG
private float _activationTime;
[Inject]
private void Construct(OrderBoxConfig config)
{
_floatingCurve = config.floatingCurve;
_activationTime = config.activationTime;
_curveLength = config.curveLength;
}
public void OnTriggerEnter(Collider other)
{
if (!_pickupMode) return;
_orderService.OrderRecieved();
Destroy(gameObject);
}
public async UniTaskVoid SwitchMode()
{
await UniTask.WaitForSeconds(_activationTime);
_pickupMode = true;
rigidbody.isKinematic = true;
_capturedPosition = transform.position;
}
private Vector3 _capturedPosition;
private float _timeForMoving;
private AnimationCurve _floatingCurve;
private float _curveLength;
private void FixedUpdate()
{
if (!_pickupMode) return;
_timeForMoving += Time.fixedDeltaTime;
if (_timeForMoving > _curveLength) _timeForMoving = 0;
transform.position = _capturedPosition + new Vector3(0, _floatingCurve.Evaluate(_timeForMoving), 0);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 067bc72af86a4fb8ac44d0c1fcfd25d5
timeCreated: 1763573681
@@ -0,0 +1,19 @@
using System;
using Reflex.Attributes;
using UnityEngine;
namespace Code.Gameplay.Orders.Order
{
public class OrderDeliveryTrigger : MonoBehaviour
{
[Inject] private IOrderService _orderService;
private bool _playerEntered;
private void OnTriggerEnter(Collider other)
{
if (_playerEntered) return;
_playerEntered = true;
_orderService.OrderDelivered();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 47fbefab729047e5a11d8761e26f75a6
timeCreated: 1763737623
@@ -0,0 +1,31 @@
using DG.Tweening;
using UnityEngine;
namespace Code.Gameplay.Orders.Order
{
public class OrderDispenser : MonoBehaviour
{
[SerializeField] private Transform hatch;
[SerializeField] private OrderBox order;
private bool _activated;
public void ThrowOrder()
{
hatch.DORotate(new Vector3(-130f, 0, 0), 0.2f);
order.rigidbody.isKinematic = false;
order.rigidbody.AddForce(-transform.forward * 10f, ForceMode.Impulse);
}
// DEBUG TODO ДИМКА УДАЛИ И ПРОПИШИ В СВОЕЙ ЛОГИКЕ
public void OnTriggerEnter(Collider other)
{
if(_activated) return;
_activated = true;
ThrowOrder();
order.SwitchMode();
}
// DEBUG
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e50e3c42f5ee45e0b1087e0dbf7dd0f4
timeCreated: 1763556675
@@ -0,0 +1,18 @@
using Reflex.Attributes;
using UnityEngine;
namespace Code.Gameplay.Orders.Order
{
public class OrderGiveTrigger : MonoBehaviour
{
[Inject] private IOrderService _orderService;
private bool _playerEntered;
private void OnTriggerEnter(Collider other)
{
if (_playerEntered) return;
_playerEntered = true;
_orderService.OrderGive();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d3966e4798d243abba9d85b9ad8aef33
timeCreated: 1763742374
@@ -0,0 +1,68 @@
using Code.Configs;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Code.Gameplay.Orders.Order
{
public class OrderService : IOrderService
{
public event IOrderService.OrderProgressDelegate OnOrderGiven;
public event IOrderService.OrderProgressDelegate OnOrderRecieved;
public event IOrderService.OrderDeliveredDelegate OnOrderDelivered;
public event IOrderService.OrderFailureDelegate OnOrderFailure;
private OrderState _orderState;
public OrderState OrderState => _orderState;
private float _deliveryTimer;
public float DeliveryTimer => _deliveryTimer;
private Vector2 _timeBounds;
private float _koefRooms, _koefOvertime;
private int _roomsPassed;
public OrderService(OrderServiceConfig config)
{
_orderState = OrderState.Delivered;
_timeBounds = config.timeBounds;
_koefRooms = config.koefRooms;
_koefOvertime = config.koefOvertime;
}
public void RoomPassed() => _roomsPassed++;
public void DecreaseTimer(float delta) => _deliveryTimer -= delta;
// Вызываются триггерами
public void OrderGive()
{
_orderState = OrderState.Given;
_roomsPassed = 0;
_deliveryTimer = Random.Range(_timeBounds.x, _timeBounds.y);
OnOrderGiven?.Invoke(_deliveryTimer);
}
public void OrderRecieved()
{
_orderState = OrderState.Recieved;
OnOrderRecieved?.Invoke(_deliveryTimer);
}
public void OrderFailed() => OnOrderFailure?.Invoke();
public void OrderDelivered()
{
if (_orderState != OrderState.Recieved)
{
OnOrderFailure?.Invoke();
return;
}
_orderState = OrderState.Delivered;
int score = (int)(_koefRooms * _roomsPassed + _deliveryTimer * _koefOvertime);
OnOrderDelivered?.Invoke(score, _deliveryTimer);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b324c2a1be1546868cddf779445b286a
timeCreated: 1763559110
@@ -0,0 +1,9 @@
namespace Code.Gameplay.Orders.Order
{
public enum OrderState
{
Delivered,
Given,
Recieved,
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0a8980a0cc034110ab3ccd948d40956b
timeCreated: 1763559535
@@ -0,0 +1,9 @@
using UnityEngine;
namespace Code.Gameplay.Player
{
public class ArmsMeshProvider : MonoBehaviour
{
[SerializeField] public Animator ArmsAnimator;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cfe65f613bc54b4098acdba0d3fdd2a2
timeCreated: 1763730814
@@ -7,9 +7,10 @@ namespace Code.Gameplay.Player
{
public interface IPlayerFactory
{
PlayerHealth CreatePlayerHealth(int count = -1);
PlayerMoney CreatePlayerMoney(int count = 0);
PlayerHealth CreatePlayerHealth(int count = -1);
UniTask<CharacterProvider> CreatePlayer();
void ReleasePlayer(CharacterProvider characterProvider);
UniTask<ArmsMeshProvider> CreateArms(Transform papochka);
void ReleaseArms(ArmsMeshProvider arms);
}
}
@@ -0,0 +1,10 @@
namespace Code.Gameplay.Player
{
public interface IPlayerScore
{
event PlayerScore.OnScoreGetDelegate OnScoreGet;
event PlayerScore.OnScoreLooseDelegate OnScoreLoose;
int Score { get; }
void UpdateScore(int amount);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5084b2568ebd4cddaef2154e5ad1f870
timeCreated: 1763890486
@@ -7,12 +7,13 @@ namespace Code.Gameplay.Player
{
private static readonly int Velocity = Animator.StringToHash("Velocity");
[SerializeField] private Animator playerAnimator;
private Animator _playerAnimator;
public void SetAnimator(Animator animator) => _playerAnimator = animator;
[SerializeField] private KinematicCharacterMotor kinematicCharacterMotor;
private void SetVelocity(float velocity)
{
playerAnimator.SetFloat(Velocity, velocity);
_playerAnimator.SetFloat(Velocity, velocity);
}
private void Update()
@@ -20,8 +20,7 @@ namespace Code.Gameplay.Player
if (count < 0) count = _playerConfig.maxHealth;
return new(count);
}
public PlayerMoney CreatePlayerMoney(int count = 0) => new(count);
}
public async UniTask<CharacterProvider> CreatePlayer()
{
@@ -35,5 +34,8 @@ namespace Code.Gameplay.Player
{
Addressables.ReleaseInstance(characterProvider.gameObject);
}
public async UniTask<ArmsMeshProvider> CreateArms(Transform papochka) => (await Addressables.InstantiateAsync(_playerConfig.armsMeshPrefab, papochka).ToUniTask()).GetComponent<ArmsMeshProvider>();
public void ReleaseArms(ArmsMeshProvider arms) => Addressables.ReleaseInstance(arms.gameObject);
}
}
@@ -28,5 +28,11 @@ namespace Code.Gameplay.Player
_healthPoints = maxHealthPoints;
MaxHealthPoints = maxHealthPoints;
}
public void InstaKill()
{
_healthPoints = 0;
OnDeath?.Invoke();
}
}
}
@@ -1,26 +0,0 @@
namespace Code.Gameplay.Player
{
public class PlayerMoney
{
public delegate void OnMoneyGetDelegate(int count, int money);
public event OnMoneyGetDelegate OnMoneyGet;
public delegate void OnMoneyLooseDelegate(int count, int money);
public event OnMoneyLooseDelegate OnMoneyLoose;
private int _money;
public int Money => _money;
public void GiveMoney(int amount)
{
_money += amount;
OnMoneyGet?.Invoke(amount, _money);
}
public void LooseMoney(int amount)
{
_money -= amount;
OnMoneyLoose?.Invoke(amount, _money);
}
public PlayerMoney(int money) => _money = money;
}
}
@@ -0,0 +1,24 @@
namespace Code.Gameplay.Player
{
public class PlayerScore : IPlayerScore
{
public delegate void OnScoreGetDelegate(int count, int score);
public event OnScoreGetDelegate OnScoreGet;
public delegate void OnScoreLooseDelegate(int count, int score);
public event OnScoreLooseDelegate OnScoreLoose;
private int _score;
public int Score => _score;
public void UpdateScore(int amount)
{
_score += amount;
if (amount > 0) OnScoreGet?.Invoke(amount, _score);
else OnScoreLoose?.Invoke(amount, _score);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b32d6ce440f44fd3abadaa489a44890c
timeCreated: 1762797763
@@ -0,0 +1,11 @@
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace Code.Generator
{
[CreateAssetMenu(menuName = "Config/GeneratorConfig", fileName = "GeneratorConfig")]
public class GeneratorConfig : ScriptableObject
{
public AssetReference[] roomAssetReferences;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1a7c77305de54155b5b94b607531ee3c
timeCreated: 1762453750
@@ -0,0 +1,12 @@
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace Code.Generator
{
public interface IRoomGeneratorFactory
{
UniTask PreloadRooms();
GameObject GetCachedPrefab(int index);
UniTask<Room> CreateRoomByIndex(int index);
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f3fca4115e714519b869eb72d856e89f
timeCreated: 1762453657
@@ -0,0 +1,28 @@
using System;
using Code.UI;
using UnityEngine;
namespace Code.Generator
{
public class Room : MonoBehaviour
{
[SerializeField] private RoomType roomType;
public RoomType RoomType => roomType;
[SerializeField] private float roomTimer;
public float RoomTimer => roomTimer;
[SerializeField] private Transform enterMarker;
public Transform EnterMarker => enterMarker;
[SerializeField] private Transform exitMarker;
public Transform ExitMarker => exitMarker;
private void Awake()
{
if (EnterMarker == null || ExitMarker == null)
{
Debug.LogError($"Але маркеры не найдены у комнаты {gameObject.name}");
}
}
//PIZDEC
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5ba1a19c534f4401aa287d4b68ce470c
timeCreated: 1762014278
@@ -0,0 +1,199 @@
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace Code.Generator
{
public class RoomGenerator : MonoBehaviour
{
[SerializeField] private GeneratorConfig generatorConfig;
private RoomGeneratorFactory _factory;
private float _timer;
private List<int> _roomIndexesStack;
private List<Room> _spawnedRooms;
private async void Awake()
{
_factory = new RoomGeneratorFactory(generatorConfig);
_spawnedRooms = new List<Room>();
_roomIndexesStack = new List<int>();
_timer = Random.Range(60, 120f);
Debug.LogWarning($"КОТЛЫ ГЕНЕРАЛЬСКИЕ{_timer}");
await _factory.PreloadRooms();
CreateRoomsStack();
await GenerateRoomsAsync();
}
private void CreateRoomsStack()
{
_roomIndexesStack.Clear();
var remainingTime = _timer;
float ladderTimer = 0f;
int totalRooms = generatorConfig.roomAssetReferences.Length;
List<int> availableIndexes = new List<int>();
for (int i = 0; i < totalRooms; i++)
availableIndexes.Add(i);
int saveIndex = FindRoomIndexByType(RoomType.Save);
if (saveIndex != -1)
{
var prefab = _factory.GetCachedPrefab(saveIndex);
if (prefab != null)
{
Room saveRoom = prefab.GetComponent<Room>();
if (saveRoom != null)
{
_roomIndexesStack.Add(saveIndex);
availableIndexes.Remove(saveIndex);
Debug.Log($"Первая комната: {saveRoom.name}");
}
}
}
while (remainingTime > 0 && availableIndexes.Count > 0)
{
int randomIndex = Random.Range(0, availableIndexes.Count);
int chosenOne = availableIndexes[randomIndex];
var prefab = _factory.GetCachedPrefab(chosenOne);
if (prefab == null)
continue;
Room room = prefab.GetComponent<Room>();
if (room == null)
continue;
switch (room.RoomType)
{
case RoomType.Save or RoomType.PickUp:
availableIndexes.RemoveAt(randomIndex);
continue;
case RoomType.Basic:
float currentRoomTime = room.RoomTimer;
if (remainingTime >= currentRoomTime && ladderTimer < 30f)
{
_roomIndexesStack.Add(chosenOne);
remainingTime -= currentRoomTime;
ladderTimer += currentRoomTime;
Debug.Log($"комната {room.name} время {currentRoomTime} осталось: {remainingTime}");
}
availableIndexes.RemoveAt(randomIndex);
break;
case RoomType.Ladder:
if (ladderTimer >= 30f)
{
_roomIndexesStack.Add(chosenOne);
ladderTimer = 0f;
availableIndexes.RemoveAt(randomIndex);
Debug.Log($"Лестница ура {room.name}");
}
break;
default:
Debug.Log($"тип комнаты {room.RoomType}");
availableIndexes.RemoveAt(randomIndex);
break;
}
}
AddPickupRoom();
Debug.Log($"стек комнат: {_roomIndexesStack.Count}");
}
private async UniTask GenerateRoomsAsync()
{
for (int i = 0; i < _roomIndexesStack.Count; i++)
{
int index = _roomIndexesStack[i];
Room room = await _factory.CreateRoomByIndex(index);
if (i == 0)
{
room.transform.position = Vector3.zero;
room.transform.rotation = Quaternion.identity;
}
else
{
Room previousRoom = _spawnedRooms[i - 1];
PlaceRoom(room, previousRoom);
}
_spawnedRooms.Add(room);
}
}
private int FindRoomIndexByType(RoomType neededType)
{
int totalRooms = generatorConfig.roomAssetReferences.Length;
for (int i = 0; i < totalRooms; i++)
{
var prefab = _factory.GetCachedPrefab(i);
if (prefab == null)
continue;
Room room = prefab.GetComponent<Room>();
if (room == null)
continue;
if (room.RoomType == neededType)
return i;
}
return -1;
}
private void AddPickupRoom()
{
int pickupIndex = FindRoomIndexByType(RoomType.PickUp);
if (pickupIndex == -1)
{
Debug.Log("PickUp комнат не найдено але");
return;
}
var prefab = _factory.GetCachedPrefab(pickupIndex);
if (prefab == null)
return;
Room pickupRoom = prefab.GetComponent<Room>();
if (pickupRoom == null)
return;
if (_roomIndexesStack.Count == 0)
{
Debug.LogWarning("стек пуст, нет позиции после первой");
return;
}
int insertPos = Random.Range(1, _roomIndexesStack.Count + 1);
_roomIndexesStack.Insert(insertPos, pickupIndex);
Debug.Log($"PickUp комната '{pickupRoom.name}' позиция {insertPos}");
}
private void PlaceRoom(Room current, Room previous)
{
if (current.EnterMarker == null || previous.ExitMarker == null)
return;
Transform enter = current.EnterMarker;
Transform exit = previous.ExitMarker;
Quaternion rotationDiff = Quaternion.FromToRotation(enter.forward, exit.forward);
current.transform.rotation = rotationDiff * current.transform.rotation;
Vector3 offset = enter.localPosition;
current.transform.position = exit.position - offset;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 353230beca35458dafc91c6409c25ab3
timeCreated: 1762014615
@@ -0,0 +1,52 @@
using Code.Configs;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace Code.Generator
{
public class RoomGeneratorFactory : IRoomGeneratorFactory
{
private readonly AssetReference[] _roomAssetReferences;
private readonly GameObject[] _cashedRooms;
private bool _isInitialized;
public RoomGeneratorFactory(GeneratorConfig generatorConfig)
{
_roomAssetReferences = generatorConfig.roomAssetReferences;
_cashedRooms = new GameObject[_roomAssetReferences.Length];
}
public async UniTask PreloadRooms()
{
if (_isInitialized)
return;
for (int i = 0; i < _roomAssetReferences.Length; i++)
{
var reference = _roomAssetReferences[i];
var prefab = await reference.LoadAssetAsync<GameObject>().ToUniTask();
_cashedRooms[i] = prefab;
}
_isInitialized = true;
Debug.Log($"комнат в памяти есть: {_cashedRooms.Length}");
}
public GameObject GetCachedPrefab(int index)
{
if (index < 0 || index >= _cashedRooms.Length)
return null;
return _cashedRooms[index];
}
public async UniTask<Room> CreateRoomByIndex(int index)
{
if (!_isInitialized)
await PreloadRooms();
Room room = Object.Instantiate(_cashedRooms[index]).GetComponent<Room>();
return room;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d6e5b72284354ba79ec5b89cf06f1203
timeCreated: 1762454256
@@ -0,0 +1,10 @@
namespace Code.Generator
{
public enum RoomType
{
Basic,
Ladder,
Save,
PickUp
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 304fa5ed27cc4bc3aabcfeb272206d89
timeCreated: 1762945420
@@ -2,6 +2,6 @@ namespace Code.Input
{
public enum UIActions
{
Continue
}
}
@@ -1,3 +1,4 @@
using Code.Gameplay.Orders.Order;
using UnityEngine;
using UnityEngine.Serialization;
@@ -8,11 +9,13 @@ namespace Code.Scenes.SceneEnvironments
{
[FormerlySerializedAs("sfxTarget")] public Transform debugSfxTarget;
public Transform playerSpawnPoint;
public OrderDispenser debugTube;
public void TransitVariables(GameplaySceneEnvironment env)
{
debugSfxTarget = env.debugSfxTarget;
playerSpawnPoint = env.playerSpawnPoint;
debugTube = env.debugTube;
}
}
}
@@ -1,4 +1,7 @@
using Code.Gameplay.Door;
using Code.UI.Panels.Etc;
using UnityEngine;
using UnityEngine.Experimental.GlobalIllumination;
using UnityEngine.Serialization;
namespace Code.Scenes.SceneEnvironments
@@ -6,13 +9,21 @@ namespace Code.Scenes.SceneEnvironments
[System.Serializable]
public class MainMenuEnvironment : CurrentSceneEnvironment
{
public Transform cameraTarget;
public Transform cameraPosition;
public MainMenuUIVariables uiVariables;
public MainMenuButton startButton;
public MainMenuButton settingButton;
public MainMenuButton exitButton;
public Canvas menuButtonsCanvas;
public void TransitVariables(MainMenuEnvironment env)
{
cameraTarget = env.cameraTarget;
cameraPosition = env.cameraPosition;
uiVariables = env.uiVariables;
startButton = env.startButton;
settingButton = env.settingButton;
exitButton = env.exitButton;
menuButtonsCanvas = env.menuButtonsCanvas;
}
}
}
@@ -30,7 +30,7 @@ namespace Code.Scenes
callBack?.Invoke();
}
public async UniTask LoadSceneAsyncAwaitable(int sceneId, float waitFor = 0)
public async UniTask LoadSceneAsyncAwaitable(int sceneId, float waitFor = 0f)
{
await UniTask.WhenAll(
UniTask.Delay(TimeSpan.FromSeconds(waitFor)),
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Code.Audio;
using Code.Configs;
using Code.Gameplay.Camera;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
@@ -21,6 +23,10 @@ namespace Code.StaticData
SFXListConfig SFXListConfig { get; }
DispatcherSoundListConfig DispatcherSoundListConfig { get; }
EnemiesSoundListConfig EnemiesSoundListConfig { get; }
OrderServiceConfig OrderServiceConfig { get; }
OrderBoxConfig OrderBoxConfig { get; }
Dictionary<CameraMode, CameraSettingsConfig> CameraSettingsConfigs { get; }
Dictionary<AudioSourceType, AudioSourceSettingsConfig> AudioSourceSettingsConfigs { get; }
void Load();
Task<T> InstantiateAsset<T>(AssetReference assetReference) where T : Behaviour;
}
@@ -1,6 +1,10 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Code.Audio;
using Code.Configs;
using Code.Constants;
using Code.Gameplay.Camera;
using Cysharp.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
@@ -20,16 +24,28 @@ namespace Code.StaticData
public SFXListConfig SFXListConfig { get; private set; }
public DispatcherSoundListConfig DispatcherSoundListConfig { get; private set; }
public EnemiesSoundListConfig EnemiesSoundListConfig { get; private set; }
public OrderServiceConfig OrderServiceConfig { get; private set; }
public OrderBoxConfig OrderBoxConfig { get; private set; }
public Dictionary<CameraMode, CameraSettingsConfig> CameraSettingsConfigs { get; private set; } = new();
public Dictionary<AudioSourceType, AudioSourceSettingsConfig> AudioSourceSettingsConfigs { get; private set; } = new();
public void Load()
{
InputConfig = Resources.Load<InputConfig>(string.Format(StringPaths.ConfigSingle, "App", "InputConfig"));
AppConfig = Resources.Load<AppConfig>(string.Format(StringPaths.ConfigSingle, "App", "AppConfig"));
CameraConfig = Resources.Load<CameraConfig>(string.Format(StringPaths.ConfigSingle, "App", "CameraConfig"));
CharacterConfig = Resources.Load<CharacterConfig>(string.Format(StringPaths.ConfigSingle, "App", "CharacterConfig"));
UIConfig = Resources.Load<UIConfig>(string.Format(StringPaths.ConfigSingle, "App", "UIConfig"));
PlayerConfig = Resources.Load<PlayerConfig>(string.Format(StringPaths.ConfigSingle, "App", "PlayerConfig"));
OrderServiceConfig = Resources.Load<OrderServiceConfig>(string.Format(StringPaths.ConfigSingle, "Gameplay", "OrderServiceConfig"));
OrderBoxConfig = Resources.Load<OrderBoxConfig>(string.Format(StringPaths.ConfigSingle, "Gameplay", "OrderBoxConfig"));
CameraConfig = Resources.Load<CameraConfig>(string.Format(StringPaths.ConfigSingle, "Camera", "CameraConfig"));
CameraSettingsConfigs = Resources
.LoadAll<CameraSettingsConfig>(string.Format(StringPaths.ConfigMultiple, "Camera"))
.ToDictionary(x => x.cameraMode);
LoadAudioConfigs();
}
@@ -40,11 +56,14 @@ namespace Code.StaticData
SFXListConfig = Resources.Load<SFXListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "SFXListConfig"));
DispatcherSoundListConfig = Resources.Load<DispatcherSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "DispatcherSoundListConfig"));
EnemiesSoundListConfig = Resources.Load<EnemiesSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "EnemiesSoundListConfig"));
AudioSourceSettingsConfigs = Resources
.LoadAll<AudioSourceSettingsConfig>(string.Format(StringPaths.ConfigMultiple, "Audio"))
.ToDictionary(x => x.sourceType);
}
public async Task<T> InstantiateAsset<T>(AssetReference assetReference) where T : Behaviour
{
return (await Addressables.InstantiateAsync(assetReference).ToUniTask()).GetComponent<T>();
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 14bf9dd380324bf49ea98fbeb8c94186
timeCreated: 1763550884
@@ -0,0 +1,16 @@
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace Code.UI.Panels.Etc
{
public class HoverButton : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public Button button;
public Action OnPointerEnterEvent, OnPointerExitEvent;
public virtual void OnPointerEnter(PointerEventData eventData) => OnPointerEnterEvent?.Invoke();
public virtual void OnPointerExit(PointerEventData eventData) => OnPointerExitEvent?.Invoke();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f97de34a1f6042128921ad728f153909
timeCreated: 1763550895
Loaded 100 of 433 files, more files were not shown because too many files have changed in this diff. Show more