12 Commits
359 changed files with 918178 additions and 15817 deletions

No files matched your search

@@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: d447fc60305c17a17bf20948ab295a45 m_DefaultGroup: d447fc60305c17a17bf20948ab295a45
m_currentHash: m_currentHash:
serializedVersion: 2 serializedVersion: 2
Hash: 1290af012af335115858ec31670d830d Hash: 1ec1ee985689145b755c859b69691cb0
m_OptimizeCatalogSize: 0 m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0 m_BuildRemoteCatalog: 0
m_CatalogRequestsTimeout: 0 m_CatalogRequestsTimeout: 0
@@ -32,8 +32,8 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 19bfe93240786974ea9d7cd70a7bb635 - m_GUID: 1cc66c0b13a946e1c9ec37026268e144
m_Address: Prefabs/Rooms/Level5 m_Address: Audio/Enemies/pl_metal2
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
@@ -57,6 +57,11 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 26d4e4c556527924490b8018cd510eda
m_Address: Assets/Resources_moved/Audio/Enemies/bc_bite2.wav
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 28a6c7a4124141341ab7c2b7dfd3e95b - m_GUID: 28a6c7a4124141341ab7c2b7dfd3e95b
m_Address: Assets/Resources_moved/Prefabs/Levels/Level1 2.prefab m_Address: Assets/Resources_moved/Prefabs/Levels/Level1 2.prefab
m_ReadOnly: 0 m_ReadOnly: 0
@@ -72,6 +77,11 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 2c6a984e4a1b42647b48e6b7bc69b158
m_Address: Prefabs/Levels/Level6
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 2ed2d93a9f39d4edba511cb7396c7bb6 - m_GUID: 2ed2d93a9f39d4edba511cb7396c7bb6
m_Address: Assets/Resources_moved/Prefabs/Enemies/Cockroach.prefab m_Address: Assets/Resources_moved/Prefabs/Enemies/Cockroach.prefab
m_ReadOnly: 0 m_ReadOnly: 0
@@ -92,8 +102,8 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 4283d6553fc7f3f4583b9bb0be9d7979 - m_GUID: 3f8f2171cc252d953b82083cc16bd1ae
m_Address: Prefabs/Rooms/Box1 m_Address: Assets/Resources_moved/Prefabs/Levels/Level6_1.prefab
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
@@ -102,6 +112,11 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 4b279429428a13040b6d1713122cd0de
m_Address: Assets/Resources_moved/Audio/SFX/pl_pain5.wav
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 4bd64d1fcecc9c6b09d81e78b7dcfebe - m_GUID: 4bd64d1fcecc9c6b09d81e78b7dcfebe
m_Address: Audio/Dispatcher/take_damage1 m_Address: Audio/Dispatcher/take_damage1
m_ReadOnly: 0 m_ReadOnly: 0
@@ -168,18 +183,18 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: a1d9e5a04ac11a1468c744b27d442a00
m_Address: Prefabs/Rooms/Stars1
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: a306df57f348ce7cf900d0b9431739ee - m_GUID: a306df57f348ce7cf900d0b9431739ee
m_Address: launch_selectmenu m_Address: launch_selectmenu
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: ab5926b5200bedc49aec36c0afe6b028 - m_GUID: aa138b2e21adfbf4bbbfa5bf9d54b8f2
m_Address: Prefabs/Rooms/Level3_Big m_Address: Assets/Resources_moved/Audio/UI/buttonclickrelease.wav
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: ae6ab2c88ae248ce1b6efca892f17659
m_Address: Assets/Resources_moved/Audio/Music/TestDeath.ogg
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
@@ -193,8 +208,13 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: b3471d165fe389f479380f61034bea57 - m_GUID: b37ea8c61cc322afdad529d678612d22
m_Address: Assets/Resources_moved/Prefabs/Levels/Level1 1.prefab m_Address: Assets/Resources_moved/Audio/Enemies/zo_attack2.wav
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: bf87bc9ac43df86be8c818de81d44a54
m_Address: Assets/Resources_moved/Audio/SFX/pl_step1.wav
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
@@ -203,6 +223,11 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: c5a0ad8a615841547ac2ee613af526d8
m_Address: Assets/Resources_moved/Audio/SFX/pl_pain2.wav
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: c938de3174f184741925c407a43a47f2 - m_GUID: c938de3174f184741925c407a43a47f2
m_Address: Prefabs/Rooms/Level1 m_Address: Prefabs/Rooms/Level1
m_ReadOnly: 0 m_ReadOnly: 0
@@ -213,26 +238,16 @@ MonoBehaviour:
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: d4eaf1439c2788c458127b9ba67e4fbf
m_Address: Prefabs/Levels/Level1
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: d5b22c0e6700543419ae667d77aadaa2
m_Address: Prefabs/Rooms/Level2_Down
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: dc328d8aadb0e8545978741d451e0544
m_Address: Prefabs/Rooms/Level4_Parkur
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: e3a3840a7963bf841872cddb02e90151 - m_GUID: e3a3840a7963bf841872cddb02e90151
m_Address: Prefabs/Levels/MainMenu 1 m_Address: Prefabs/Levels/MainMenu 1
m_ReadOnly: 0 m_ReadOnly: 0
m_SerializedLabels: [] m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0 FlaggedDuringContentUpdateRestriction: 0
- m_GUID: e84e3a3c26ccbd50d92f13627403f148
m_Address: Audio/Enemies/rch_walk
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: ebe18293a5ef86704b23dad3a1786476 - m_GUID: ebe18293a5ef86704b23dad3a1786476
m_Address: Half-Life01 m_Address: Half-Life01
m_ReadOnly: 0 m_ReadOnly: 0
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d36aab6707c518f5abfd60065165eb35
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d982316b2b4c99747b9e953ae7b9b42f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,6 +1,9 @@
using Code.App.StateMachine; using Code.App.StateMachine;
using Code.Audio;
using Code.Gameplay.Player; using Code.Gameplay.Player;
using Code.Input; using Code.Input;
using Code.Scenes;
using Code.Scenes.SceneEnvironments;
using Code.StateMachine; using Code.StateMachine;
using Code.UI; using Code.UI;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
@@ -30,7 +33,11 @@ namespace Code.App.AppStates
Context.InputService.EnableMap(ActionMappings.UI); Context.InputService.EnableMap(ActionMappings.UI);
Context.InputService.DebugBindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit); Context.InputService.DebugBindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
GameOver(); Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Death);
Context.AudioService.ApplyStun(5000,0.5f);
GameOver().Forget();
base.EnterState(); base.EnterState();
} }
@@ -45,7 +52,7 @@ namespace Code.App.AppStates
await Context.UIService.AsyncSwitchPanelTo(UIPanel.GameOver); await Context.UIService.AsyncSwitchPanelTo(UIPanel.GameOver);
_gameOverPanel = (GameOverPanel)Context.UIService.CurrentPanel; _gameOverPanel = (GameOverPanel)Context.UIService.CurrentPanel;
_gameOverPanel.Show();
} }
private void ToMainMenu() private void ToMainMenu()
@@ -71,6 +78,8 @@ namespace Code.App.AppStates
Context.InputService.DisableMap(ActionMappings.UI); Context.InputService.DisableMap(ActionMappings.UI);
Context.InputService.DebugUnbindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit); Context.InputService.DebugUnbindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
Context.AudioService.GladlyAskToStopMusic(MusicType.Death, callback: Context.AudioFactory.ReleaseDeathMusic);
Context.AudioService.TransitToSnapshot(AudioSnapshotState.None);
base.ExitState(); base.ExitState();
} }
} }
@@ -13,10 +13,12 @@ using Code.StateMachine;
using Code.UI; using Code.UI;
using Code.UI.Panels; using Code.UI.Panels;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using DG.Tweening;
using Reflex.Core; using Reflex.Core;
using Reflex.Extensions; using Reflex.Extensions;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem; using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
namespace Code.App.AppStates namespace Code.App.AppStates
@@ -42,26 +44,18 @@ namespace Code.App.AppStates
.RegisterLoading(LoadingWork.LoadUI) .RegisterLoading(LoadingWork.LoadUI)
.RegisterLoading(LoadingWork.LoadModelResource) .RegisterLoading(LoadingWork.LoadModelResource)
.RegisterLoading(LoadingWork.LoadAudio); .RegisterLoading(LoadingWork.LoadAudio);
//_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
//_playerHealth.OnDamage += PlayerDamageTaken;
//_playerHealth.OnDeath += EndGame;
Context.AudioService.TransitToSnapshot(AudioSnapshotState.None); Context.AudioService.TransitToSnapshot(AudioSnapshotState.None);
Context.InputService.EnableMap(ActionMappings.Gameplay); Context.InputService.EnableMap(ActionMappings.Gameplay);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG); 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.Debug4, TakeGamageDEBUG);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.DevGen); Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.DevGen);
Context.LoadingManager.OnLoadingEnded += AfterSceneLoaded; 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 WaitForLoad().Forget();
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 UniTask WaitForPlayerCharacterLoad() => _playerCharacter = await Context.PlayerFactory.CreatePlayer();
@@ -70,8 +64,11 @@ namespace Code.App.AppStates
await UniTask.WhenAll( await UniTask.WhenAll(
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay), Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
Context.AudioFactory.WarmGameplayMusic(), Context.AudioFactory.WarmGameplayMusic(),
Context.AudioFactory.WarmDeathMusic(),
Context.AudioFactory.WarmSFX(), Context.AudioFactory.WarmSFX(),
Context.AudioFactory.WarmDispatcher() Context.AudioFactory.WarmDispatcher(),
Context.AudioFactory.WarmEnemies(),
Context.AudioFactory.WarmCourier()
); );
Context.LoadingManager Context.LoadingManager
@@ -87,10 +84,13 @@ namespace Code.App.AppStates
{ {
Context.LoadingManager Context.LoadingManager
.RegisterLoading(LoadingWork.LoadModelResource); .RegisterLoading(LoadingWork.LoadModelResource);
Context.LoadingManager.OnLoadingEnded -= AfterSceneLoaded; Context.LoadingManager.OnLoadingEnded -= AfterSceneLoaded;
Context.LoadingManager.OnLoadingEnded += AfterPlayerLoaded; Context.LoadingManager.OnLoadingEnded += AfterPlayerLoaded;
Context.PlayerProvider = SceneManager.GetActiveScene().GetSceneContainer().Resolve<IPlayerProvider>();
Context.PlayerFactory = SceneManager.GetActiveScene().GetSceneContainer().Resolve<IPlayerFactory>();
await UniTask.WhenAll( await UniTask.WhenAll(
WaitForPlayerArmsToInitialize(), WaitForPlayerArmsToInitialize(),
WaitForPlayerCharacterLoad() WaitForPlayerCharacterLoad()
@@ -112,6 +112,8 @@ namespace Code.App.AppStates
GameplaySceneEnvironment sceneEnvironment = SceneEnvironmentVariables(sceneContainer); GameplaySceneEnvironment sceneEnvironment = SceneEnvironmentVariables(sceneContainer);
_volume = sceneEnvironment.volume;
PlayerInitialize(sceneEnvironment); PlayerInitialize(sceneEnvironment);
CameraInitialize(); CameraInitialize();
@@ -153,22 +155,31 @@ namespace Code.App.AppStates
private void PlayerDamageTaken(int damage, PlayerHealth health) private void PlayerDamageTaken(int damage, PlayerHealth health)
{ {
Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.TakeDamage1,(int)DispatcherSounds.TakeDamage4)); Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.TakeDamage1,(int)DispatcherSounds.TakeDamage4));
Context.AudioService.PlayCourier((CourierSounds)Random.Range((int)CourierSounds.Damage1,(int)CourierSounds.Damage2));
DamageEffectProcess().Forget();
}
// TODO В конфиг
private async UniTaskVoid DamageEffectProcess()
{
_damagePanel.Show();
Context.AudioService.ApplyStun(200, 0.5f);
DOTween.To(() => _volume.weight, x => _volume.weight = x, 1f, 0.5f);
await UniTask.WaitForSeconds(3f);
DOTween.To(() => _volume.weight, x => _volume.weight = x, 0f, 1f);
Context.AudioService.ApplyStun(5000, 1f);
_damagePanel.Hide();
} }
// DEBUG // DEBUG
private void InstaKillDEBUG(InputAction.CallbackContext context) private void InstaKillDEBUG(InputAction.CallbackContext context)
{ {
_playerHealth.InstaKill(); _playerHealth.InstaKill();
} }
private void RoomPassedDEBUG(InputAction.CallbackContext context) private void TakeGamageDEBUG(InputAction.CallbackContext context)
{ {
_orderService.RoomPassed(); _playerHealth.GetDamage(1);
} }
private OrderDispenser _debugTube;
private void Tube(InputAction.CallbackContext context)
{
_debugTube.ThrowOrder();
}
// DEBUG // DEBUG
private bool _tickEnabled; private bool _tickEnabled;
public override void Tick() public override void Tick()
@@ -201,13 +212,16 @@ namespace Code.App.AppStates
Context.AudioService.OnDispatcherEnded -= _gameplayPanel.CloseDispatcher; Context.AudioService.OnDispatcherEnded -= _gameplayPanel.CloseDispatcher;
Context.InputService.DisableMap(ActionMappings.Gameplay); Context.InputService.DisableMap(ActionMappings.Gameplay);
Context.AudioService.GladlyAskToStopMusic(MusicType.Action, callback: Context.AudioFactory.ReleaseActionMusic); Context.AudioService.GladlyAskToStopMusic(MusicType.Action, time: 0f, callback: Context.AudioFactory.ReleaseActionMusic);
Context.AudioService.GladlyAskToStopMusic(MusicType.Peaceful, callback: Context.AudioFactory.ReleasePeacefulMusic); Context.AudioService.GladlyAskToStopMusic(MusicType.Peaceful, time: 0f, callback: Context.AudioFactory.ReleasePeacefulMusic);
Context.AudioFactory.ReleaseCourier();
Context.AudioFactory.ReleaseDispatcher();
Context.AudioFactory.ReleaseEnemies();
Context.AudioFactory.ReleaseSFX();
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG); 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.Debug4, TakeGamageDEBUG);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
base.ExitState(); base.ExitState();
} }
@@ -224,13 +238,15 @@ namespace Code.App.AppStates
private GameplayPanel _gameplayPanel; private GameplayPanel _gameplayPanel;
private ArmsMeshProvider _armsMesh; private ArmsMeshProvider _armsMesh;
private DamagePanel _damagePanel;
private void UIInitialize() private void UIInitialize()
{ {
_gameplayPanel = (GameplayPanel)Context.UIService.CurrentPanel; _gameplayPanel = (GameplayPanel)Context.UIService.CurrentPanel;
_gameplayPanel.Initialize(_playerScore, _playerHealth, _orderService); _gameplayPanel.Initialize(_playerScore, _playerHealth, _orderService);
Context.AudioService.OnDispatcherStarted += _gameplayPanel.SummonDispatcher; Context.AudioService.OnDispatcherStarted += _gameplayPanel.SummonDispatcher;
Context.AudioService.OnDispatcherEnded += _gameplayPanel.CloseDispatcher; Context.AudioService.OnDispatcherEnded += _gameplayPanel.CloseDispatcher;
_damagePanel = _gameplayPanel.DamagePanel;
} }
private void MusicInitialize() private void MusicInitialize()
{ {
@@ -252,10 +268,11 @@ namespace Code.App.AppStates
_orderService.OnOrderDelivered += OrderDelivered; _orderService.OnOrderDelivered += OrderDelivered;
_orderService.OnOrderFailure += OrderFailure; _orderService.OnOrderFailure += OrderFailure;
} }
private Volume _volume;
private GameplaySceneEnvironment SceneEnvironmentVariables(Container sceneContainer) private GameplaySceneEnvironment SceneEnvironmentVariables(Container sceneContainer)
{ {
var sceneEnvironment = (GameplaySceneEnvironment)sceneContainer.Resolve<CurrentSceneEnvironment>(); var sceneEnvironment = (GameplaySceneEnvironment)sceneContainer.Resolve<CurrentSceneEnvironment>();
return sceneEnvironment; return sceneEnvironment;
} }
@@ -33,11 +33,7 @@ namespace Code.App
containerBuilder.AddSingleton(typeof(LoadingManager), typeof(ILoadingManager)); containerBuilder.AddSingleton(typeof(LoadingManager), typeof(ILoadingManager));
containerBuilder.AddSingleton(typeof(InputService), typeof(IInputService)); containerBuilder.AddSingleton(typeof(InputService), typeof(IInputService));
// Перенести нахуй в контейнер геймплея
containerBuilder.AddSingleton(typeof(PlayerFactory), typeof(IPlayerFactory));
containerBuilder.AddSingleton(typeof(EnemyFactory), typeof(IEnemyFactory));
containerBuilder.AddSingleton(typeof(PlayerProvider), typeof(IPlayerProvider));
//
InitializeCamera(containerBuilder, staticDataService); InitializeCamera(containerBuilder, staticDataService);
containerBuilder.AddSingleton(typeof(UIFactory), typeof(IUIFactory)); containerBuilder.AddSingleton(typeof(UIFactory), typeof(IUIFactory));
@@ -71,6 +67,7 @@ namespace Code.App
containerBuilder.AddSingleton(infrastructureUnit.AddComponent<CameraStateMachine>()); containerBuilder.AddSingleton(infrastructureUnit.AddComponent<CameraStateMachine>());
} }
// TODO Часть в сцены
private void InstallStaticData(ContainerBuilder containerBuilder, out IStaticDataService staticDataService) private void InstallStaticData(ContainerBuilder containerBuilder, out IStaticDataService staticDataService)
{ {
staticDataService = new StaticDataService(); staticDataService = new StaticDataService();
@@ -97,9 +94,12 @@ namespace Code.App
containerBuilder.AddSingleton(staticDataService.SoundtrackListConfig, typeof(SoundtrackListConfig)); containerBuilder.AddSingleton(staticDataService.SoundtrackListConfig, typeof(SoundtrackListConfig));
containerBuilder.AddSingleton(staticDataService.AudioTestClipsConfig, typeof(AudioTestClipsConfig)); containerBuilder.AddSingleton(staticDataService.AudioTestClipsConfig, typeof(AudioTestClipsConfig));
containerBuilder.AddSingleton(staticDataService.SFXListConfig, typeof(SFXListConfig)); containerBuilder.AddSingleton(staticDataService.SFXListConfig, typeof(SFXListConfig));
containerBuilder.AddSingleton(staticDataService.CourierSoundListConfig, typeof(CourierSoundListConfig));
containerBuilder.AddSingleton(staticDataService.DispatcherSoundListConfig, typeof(DispatcherSoundListConfig)); containerBuilder.AddSingleton(staticDataService.DispatcherSoundListConfig, typeof(DispatcherSoundListConfig));
containerBuilder.AddSingleton(staticDataService.EnemiesSoundListConfig, typeof(EnemiesSoundListConfig)); containerBuilder.AddSingleton(staticDataService.EnemiesSoundListConfig, typeof(EnemiesSoundListConfig));
containerBuilder.AddSingleton(staticDataService.AudioSourceSettingsConfigs, typeof(Dictionary<AudioSourceType, AudioSourceSettingsConfig>)); containerBuilder.AddSingleton(staticDataService.AudioSourceSettingsConfigs, typeof(Dictionary<AudioSourceType, AudioSourceSettingsConfig>));
containerBuilder.AddSingleton(staticDataService.DefaultAudioSettingsConfig, typeof(DefaultAudioSettingsConfig));
containerBuilder.AddSingleton(staticDataService.OrderServiceConfig, typeof(OrderServiceConfig)); containerBuilder.AddSingleton(staticDataService.OrderServiceConfig, typeof(OrderServiceConfig));
containerBuilder.AddSingleton(staticDataService.OrderBoxConfig, typeof(OrderBoxConfig)); containerBuilder.AddSingleton(staticDataService.OrderBoxConfig, typeof(OrderBoxConfig));
@@ -119,9 +119,7 @@ namespace Code.App
AttributeInjector.Inject(cameraStateMachine.StateMachineContext, container); AttributeInjector.Inject(cameraStateMachine.StateMachineContext, container);
cameraStateMachine.Initialize(); cameraStateMachine.Initialize();
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed BootstrapFinish(container).Forget();
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) private async UniTaskVoid BootstrapFinish(Container container)
{ {
@@ -1,4 +1,5 @@
using Code.App.Loading; using Code.App.Loading;
using Code.Gameplay.Enemies;
using Code.Gameplay.Orders.Order; using Code.Gameplay.Orders.Order;
using Code.Gameplay.Player; using Code.Gameplay.Player;
using Code.Generator; using Code.Generator;
@@ -21,6 +22,9 @@ namespace Code.App.SceneInstallers
containerBuilder.AddScoped(typeof(PlayerScore), typeof(IPlayerScore)); containerBuilder.AddScoped(typeof(PlayerScore), typeof(IPlayerScore));
containerBuilder.AddScoped(typeof(OrderService), typeof(IOrderService)); containerBuilder.AddScoped(typeof(OrderService), typeof(IOrderService));
containerBuilder.AddScoped(typeof(RoomGeneratorFactory), typeof(IRoomGeneratorFactory)); containerBuilder.AddScoped(typeof(RoomGeneratorFactory), typeof(IRoomGeneratorFactory));
containerBuilder.AddScoped(typeof(PlayerProvider), typeof(IPlayerProvider));
containerBuilder.AddScoped(typeof(PlayerFactory), typeof(IPlayerFactory));
containerBuilder.AddScoped(typeof(EnemyFactory), typeof(IEnemyFactory));
containerBuilder.AddScoped(typeof(RoomGenerator)); containerBuilder.AddScoped(typeof(RoomGenerator));
containerBuilder.OnContainerBuilt += Initialize; containerBuilder.OnContainerBuilt += Initialize;
@@ -37,7 +41,7 @@ namespace Code.App.SceneInstallers
loadingManager loadingManager
.UnregisterLoading(LoadingWork.LoadScene); .UnregisterLoading(LoadingWork.LoadScene);
LoadRooms(container,loadingManager); LoadRooms(container,loadingManager).Forget();
} }
private async UniTaskVoid LoadRooms(Container container, ILoadingManager loadingManager) private async UniTaskVoid LoadRooms(Container container, ILoadingManager loadingManager)
@@ -19,10 +19,10 @@ namespace Code.App.StateMachine
[Inject] public AppStateMachine StateMachine { get; private set; } [Inject] public AppStateMachine StateMachine { get; private set; }
[Inject] public CameraStateMachine CameraStateMachine { get; private set; } [Inject] public CameraStateMachine CameraStateMachine { get; private set; }
[Inject] public IUIService UIService { get; private set; } [Inject] public IUIService UIService { get; private set; }
[Inject] public IPlayerFactory PlayerFactory { get; private set; }
[Inject] public IPlayerProvider PlayerProvider { get; private set; }
[Inject] public IAudioFactory AudioFactory { get; private set; } [Inject] public IAudioFactory AudioFactory { get; private set; }
[Inject] public IAudioService AudioService { get; private set; } [Inject] public IAudioService AudioService { get; private set; }
[Inject] public IEnemyFactory EnemyFactory { get; private set; } /*[Inject]*/public IPlayerFactory PlayerFactory { get; set; }
/*[Inject]*/public IPlayerProvider PlayerProvider { get; set; }
// [Inject] public IEnemyFactory EnemyFactory { get; private set; }
} }
} }
@@ -11,8 +11,10 @@ namespace Code.Audio
} }
public enum EnemiesSounds public enum EnemiesSounds
{ {
Bastard, GrandpaAttack,
Bravo RoachAttack,
RoachStep,
GrandpaStep
} }
public enum DispatcherSounds public enum DispatcherSounds
{ {
@@ -28,4 +30,10 @@ namespace Code.Audio
Late4, Late4,
Late5 Late5
} }
public enum CourierSounds
{
Step,
Damage1,
Damage2
}
} }
@@ -19,24 +19,28 @@ namespace Code.Audio
private AssetReference[] _audioTestClipsReferences; private AssetReference[] _audioTestClipsReferences;
private AssetReference[] _peacefulSoundtrack; private AssetReference[] _peacefulSoundtrack;
private AssetReference[] _actionSoundtrack; private AssetReference[] _actionSoundtrack;
private AssetReference[] _deathSoundtrack;
private AssetReference[] _menuSoundtrack; private AssetReference[] _menuSoundtrack;
private AssetReference[] _SFX; private AssetReference[] _SFX;
private AssetReference[] _enemies; private AssetReference[] _enemies;
private AssetReference[] _dispatcher; private AssetReference[] _dispatcher;
private AssetReference[] _character; private AssetReference[] _courier;
private AsyncOperationHandle<IList<AudioClip>> _audioTestClipsHandle; private AsyncOperationHandle<IList<AudioClip>> _audioTestClipsHandle;
private AsyncOperationHandle<IList<AudioClip>> _menuMusicHandle; private AsyncOperationHandle<IList<AudioClip>> _menuMusicHandle;
private AsyncOperationHandle<IList<AudioClip>> _deathMusicHandle;
private AsyncOperationHandle<IList<AudioClip>> _actionMusicHandle; private AsyncOperationHandle<IList<AudioClip>> _actionMusicHandle;
private AsyncOperationHandle<IList<AudioClip>> _peacefulMusicHandle; private AsyncOperationHandle<IList<AudioClip>> _peacefulMusicHandle;
private AsyncOperationHandle<IList<AudioClip>> _SFXHandle; private AsyncOperationHandle<IList<AudioClip>> _SFXHandle;
private AsyncOperationHandle<IList<AudioClip>> _enemiesHandle; private AsyncOperationHandle<IList<AudioClip>> _enemiesHandle;
private AsyncOperationHandle<IList<AudioClip>> _dispatcherHandle; private AsyncOperationHandle<IList<AudioClip>> _dispatcherHandle;
private AsyncOperationHandle<IList<AudioClip>> _courierHandle;
public Dictionary<AudioType, AudioClip> AudioTestClips { get; private set; } = new(); public Dictionary<AudioType, AudioClip> AudioTestClips { get; private set; } = new();
public Dictionary<MusicType, List<AudioClip>> MusicDictionary { get; private set; } = new(); public Dictionary<MusicType, List<AudioClip>> MusicDictionary { get; private set; } = new();
public List<AudioClip> SFXAudios { get; private set; } = new(); public List<AudioClip> SFXAudios { get; private set; } = new();
public List<AudioClip> EnemiesAudios { get; private set; } = new(); public List<AudioClip> EnemiesAudios { get; private set; } = new();
public List<AudioClip> CourierAudios { get; private set; } = new();
public List<AudioClip> DispatcherAudios { get; private set; } = new(); public List<AudioClip> DispatcherAudios { get; private set; } = new();
public AudioFactory(AudioMixerConfig audioMixerConfig, public AudioFactory(AudioMixerConfig audioMixerConfig,
@@ -44,7 +48,8 @@ namespace Code.Audio
SFXListConfig sfxListConfig, SFXListConfig sfxListConfig,
EnemiesSoundListConfig enemiesSoundListConfig, EnemiesSoundListConfig enemiesSoundListConfig,
DispatcherSoundListConfig dispatcherSoundListConfig, DispatcherSoundListConfig dispatcherSoundListConfig,
AudioTestClipsConfig audioTestClipsConfig AudioTestClipsConfig audioTestClipsConfig,
CourierSoundListConfig courierSoundListConfig
) )
{ {
AudioMixer = audioMixerConfig.audioMixerAsset; AudioMixer = audioMixerConfig.audioMixerAsset;
@@ -52,15 +57,18 @@ namespace Code.Audio
_peacefulSoundtrack = soundtrackListConfig.peacefulSoundtrack; _peacefulSoundtrack = soundtrackListConfig.peacefulSoundtrack;
_actionSoundtrack = soundtrackListConfig.actionSoundtrack; _actionSoundtrack = soundtrackListConfig.actionSoundtrack;
_deathSoundtrack = soundtrackListConfig.deathSoundtrack;
_menuSoundtrack = soundtrackListConfig.menuSoundtrack; _menuSoundtrack = soundtrackListConfig.menuSoundtrack;
_SFX = sfxListConfig.SFX; _SFX = sfxListConfig.SFX;
_enemies = enemiesSoundListConfig.enemies; _enemies = enemiesSoundListConfig.enemies;
_dispatcher = dispatcherSoundListConfig.dispatcher; _dispatcher = dispatcherSoundListConfig.dispatcher;
_courier = courierSoundListConfig.courierSounds;
_audioTestClipsReferences = audioTestClipsConfig.audioTestClips; _audioTestClipsReferences = audioTestClipsConfig.audioTestClips;
MusicDictionary.Add(MusicType.Menu, new ()); MusicDictionary.Add(MusicType.Menu, new ());
MusicDictionary.Add(MusicType.Peaceful, new ()); MusicDictionary.Add(MusicType.Death, new ());
MusicDictionary.Add(MusicType.Action, new ()); MusicDictionary.Add(MusicType.Action, new ());
MusicDictionary.Add(MusicType.Peaceful, new ());
} }
public async UniTask LoadAudioSourcePrefab(Action<GameObject> callback) => public async UniTask LoadAudioSourcePrefab(Action<GameObject> callback) =>
@@ -112,6 +120,16 @@ namespace Code.Audio
// foreach (var assetReference in _menuSoundtrack) assetReference.ReleaseAsset(); // foreach (var assetReference in _menuSoundtrack) assetReference.ReleaseAsset();
_menuMusicHandle.Release(); _menuMusicHandle.Release();
} }
public async UniTask WarmDeathMusic()
{
_deathMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_deathSoundtrack, OnDeathTrackLoaded, Addressables.MergeMode.Union);
await _deathMusicHandle.ToUniTask();
}
public void ReleaseDeathMusic()
{
MusicDictionary[MusicType.Death].Clear();
_deathMusicHandle.Release();
}
public async UniTask WarmSFX( ) public async UniTask WarmSFX( )
{ {
_SFXHandle = Addressables.LoadAssetsAsync<AudioClip>(_SFX, OnSFXLoaded, Addressables.MergeMode.Union); _SFXHandle = Addressables.LoadAssetsAsync<AudioClip>(_SFX, OnSFXLoaded, Addressables.MergeMode.Union);
@@ -137,6 +155,18 @@ namespace Code.Audio
EnemiesAudios.Clear(); EnemiesAudios.Clear();
_enemiesHandle.Release(); _enemiesHandle.Release();
} }
public async UniTask WarmCourier()
{
_courierHandle = Addressables.LoadAssetsAsync<AudioClip>(_courier, OnCourierLoaded, Addressables.MergeMode.Union);
await _courierHandle.ToUniTask();
}
public void ReleaseCourier()
{
CourierAudios.Clear();
_courierHandle.Release();
}
public async UniTask WarmDispatcher( ) public async UniTask WarmDispatcher( )
{ {
@@ -156,6 +186,10 @@ namespace Code.Audio
{ {
MusicDictionary[MusicType.Menu].Add(audioClip); MusicDictionary[MusicType.Menu].Add(audioClip);
} }
private void OnDeathTrackLoaded(AudioClip audioClip)
{
MusicDictionary[MusicType.Death].Add(audioClip);
}
// private int _audioTestClipCounter; // private int _audioTestClipCounter;
private void OnAudioTestClipLoaded(AudioClip audioClip) private void OnAudioTestClipLoaded(AudioClip audioClip)
@@ -182,5 +216,9 @@ namespace Code.Audio
{ {
DispatcherAudios.Add(audioClip); DispatcherAudios.Add(audioClip);
} }
private void OnCourierLoaded(AudioClip audioClip)
{
CourierAudios.Add(audioClip);
}
} }
} }
+90 -182
View File
@@ -22,134 +22,104 @@ namespace Code.Audio
private AudioSource _actionMusicSource; private AudioSource _actionMusicSource;
private AudioSource _peacefulMusicSource; private AudioSource _peacefulMusicSource;
private AudioMixerGroup _masterGroup, private Dictionary<AudioType, AudioMixerGroup> _audioMixerGroups = new();
// _musicGroup,
_actionMusicGroup,
_menuMusicGroup,
_peacefulMusicGroup,
_SFXGroup,
_creaturesGroup,
_dispatcherGroup,
_courierGroup,
_enemiesGroup;
private readonly AudioSourcePool _audioSourcePool; private readonly AudioSourcePool _audioSourcePool;
private Dictionary<AudioSnapshotState, AudioMixerSnapshot> _snapshots = new(); // Юнити не может - говнокод поможет.
private Dictionary<AudioSnapshotState, Dictionary<AudioType, float>> _snapshotsVolumes = new();
private Dictionary<AudioSourceType, AudioSourceSettingsConfig> _settings; private Dictionary<AudioSourceType, AudioSourceSettingsConfig> _settings;
public AudioService(IAudioFactory audioFactory, Dictionary<AudioSourceType, AudioSourceSettingsConfig> settings) public AudioService(IAudioFactory audioFactory,
Dictionary<AudioSourceType, AudioSourceSettingsConfig> settings,
DefaultAudioSettingsConfig defaultAudioSettingsConfig)
{ {
_audioFactory = audioFactory; _audioFactory = audioFactory;
_audioSourcePool = new(settings); _audioSourcePool = new(settings);
_settings = settings; _settings = settings;
_snapshotsVolumes.Add(AudioSnapshotState.None,defaultAudioSettingsConfig.noneVolume);
_snapshotsVolumes.Add(AudioSnapshotState.Menu,defaultAudioSettingsConfig.menuVolume);
_snapshotsVolumes.Add(AudioSnapshotState.Action,defaultAudioSettingsConfig.actionVolume);
_snapshotsVolumes.Add(AudioSnapshotState.Peaceful,defaultAudioSettingsConfig.peacefulVolume);
} }
// TODO Грязно, убрать снапшоты НАХУЙ
public float GetSetting(AudioType type) public float GetSetting(AudioType type)
{ {
float value; _mixer.GetFloat(_audioMixerGroups[type].name, out float value);
switch (type)
{
case AudioType.SFX:
_snapshots[AudioSnapshotState.Peaceful].audioMixer.GetFloat(_SFXGroup.name, out value);
break;
case AudioType.Master:
_snapshots[AudioSnapshotState.Menu].audioMixer.GetFloat(_masterGroup.name, out value);
break;
case AudioType.Creatures:
_snapshots[AudioSnapshotState.Peaceful].audioMixer.GetFloat(_creaturesGroup.name, out value);
break;
case AudioType.GameplayMusic:
_snapshots[AudioSnapshotState.Peaceful].audioMixer.GetFloat(_peacefulMusicGroup.name, out value);
break;
case AudioType.MenuMusic:
_snapshots[AudioSnapshotState.Menu].audioMixer.GetFloat(_menuMusicGroup.name, out value);
break;
case AudioType.DispatcherSounds:
_snapshots[AudioSnapshotState.Action].audioMixer.GetFloat(_dispatcherGroup.name, out value);
break;
default:
value = 1;
break;
}
value = Mathf.Pow(10f, value / 20); value = Mathf.Pow(10f, value / 20);
return value; return value;
} }
// TODO Грязно, убрать снапшоты НАХУЙ
public void ChangeSetting(AudioType type, float value) public void ChangeSetting(AudioType type, float value)
{ {
float volume = Mathf.Log10(value) * 20; float volume = Mathf.Log10(value) * 20;
switch (type) switch (type)
{ {
case AudioType.SFX: case AudioType.DeathMusic:
_snapshots[AudioSnapshotState.Peaceful].audioMixer.SetFloat(_SFXGroup.name, volume);
_snapshots[AudioSnapshotState.Action].audioMixer.SetFloat(_SFXGroup.name, volume);
break;
case AudioType.Master: case AudioType.Master:
_snapshots[AudioSnapshotState.Menu].audioMixer.SetFloat(_masterGroup.name, volume); _snapshotsVolumes[AudioSnapshotState.Menu][type] = value;
_snapshots[AudioSnapshotState.Peaceful].audioMixer.SetFloat(_masterGroup.name, volume); _snapshotsVolumes[AudioSnapshotState.Action][type] = value;
_snapshots[AudioSnapshotState.Action].audioMixer.SetFloat(_masterGroup.name, volume); _snapshotsVolumes[AudioSnapshotState.Peaceful][type] = value;
_mixer.SetFloat(_audioMixerGroups[type].name, volume);
break; break;
case AudioType.Creatures: case AudioType.ActionMusic:
_snapshots[AudioSnapshotState.Peaceful].audioMixer.SetFloat(_creaturesGroup.name, volume); _snapshotsVolumes[AudioSnapshotState.Action][type] = value;
_snapshots[AudioSnapshotState.Action].audioMixer.SetFloat(_creaturesGroup.name, volume); _mixer.SetFloat(_audioMixerGroups[type].name, volume);
break; break;
case AudioType.GameplayMusic: case AudioType.PeacefulMusic:
_snapshots[AudioSnapshotState.Peaceful].audioMixer.SetFloat(_peacefulMusicGroup.name, volume); _snapshotsVolumes[AudioSnapshotState.Peaceful][type] = value;
_snapshots[AudioSnapshotState.Action].audioMixer.SetFloat(_actionMusicGroup.name, volume); _mixer.SetFloat(_audioMixerGroups[type].name, volume);
break; break;
case AudioType.MenuMusic: case AudioType.MenuMusic:
_snapshots[AudioSnapshotState.Menu].audioMixer.SetFloat(_menuMusicGroup.name, volume); _snapshotsVolumes[AudioSnapshotState.Menu][type] = value;
break; _mixer.SetFloat(_audioMixerGroups[type].name, volume);
case AudioType.DispatcherSounds: break;
_snapshots[AudioSnapshotState.Peaceful].audioMixer.SetFloat(_dispatcherGroup.name, volume); case AudioType.SFX:
_snapshots[AudioSnapshotState.Action].audioMixer.SetFloat(_dispatcherGroup.name, volume); case AudioType.Dispatcher:
case AudioType.Courier:
case AudioType.Enemies:
_snapshotsVolumes[AudioSnapshotState.Action][type] = value;
_snapshotsVolumes[AudioSnapshotState.Peaceful][type] = value;
_mixer.SetFloat(_audioMixerGroups[type].name, volume);
break; break;
} }
// _mixer.FindSnapshot("Action").audioMixer.SetFloat("music", volume);
} }
public async UniTask Initialize() public async UniTask Initialize()
{ {
// _mixer = await _audioFactory.CreateMixer();
_mixer = _audioFactory.AudioMixer; _mixer = _audioFactory.AudioMixer;
_masterGroup = _mixer.FindMatchingGroups(AudioGroups.MasterGroup)[0];
_menuMusicGroup = _mixer.FindMatchingGroups(AudioGroups.MenuMusicGroup)[0];
_actionMusicGroup = _mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0];
_peacefulMusicGroup = _mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0];
// _musicGroup = _mixer.FindMatchingGroups(AudioGroups.MusicGroup)[0];
_musicAudioGroups.Add(MusicType.Menu, _mixer.FindMatchingGroups(AudioGroups.MenuMusicGroup)[0]); _musicAudioGroups.Add(MusicType.Menu, _mixer.FindMatchingGroups(AudioGroups.MenuMusicGroup)[0]);
_musicAudioGroups.Add(MusicType.Death, _mixer.FindMatchingGroups(AudioGroups.DeathMusicGroup)[0]);
_musicAudioGroups.Add(MusicType.Action, _mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0]); _musicAudioGroups.Add(MusicType.Action, _mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0]);
_musicAudioGroups.Add(MusicType.Peaceful, _mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0]); _musicAudioGroups.Add(MusicType.Peaceful, _mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0]);
_cancellationTokenSources.Add(MusicType.Menu, new()); _cancellationTokenSources.Add(MusicType.Menu, new());
_cancellationTokenSources.Add(MusicType.Death, new());
_cancellationTokenSources.Add(MusicType.Action, new()); _cancellationTokenSources.Add(MusicType.Action, new());
_cancellationTokenSources.Add(MusicType.Peaceful, new()); _cancellationTokenSources.Add(MusicType.Peaceful, new());
_musicAudioSources.Add(MusicType.Menu, null); _musicAudioSources.Add(MusicType.Menu, null);
_musicAudioSources.Add(MusicType.Death, null);
_musicAudioSources.Add(MusicType.Action, null); _musicAudioSources.Add(MusicType.Action, null);
_musicAudioSources.Add(MusicType.Peaceful, null); _musicAudioSources.Add(MusicType.Peaceful, null);
_SFXGroup = _mixer.FindMatchingGroups(AudioGroups.SFXGroup)[0]; _audioMixerGroups.Add(AudioType.Master, _mixer.FindMatchingGroups(AudioGroups.MasterGroup)[0]);
_creaturesGroup = _mixer.FindMatchingGroups(AudioGroups.CreaturesGroup)[0]; _audioMixerGroups.Add(AudioType.SFX, _mixer.FindMatchingGroups(AudioGroups.SFXGroup)[0]);
_dispatcherGroup = _mixer.FindMatchingGroups(AudioGroups.DispatcherMusicGroup)[0]; _audioMixerGroups.Add(AudioType.Dispatcher, _mixer.FindMatchingGroups(AudioGroups.DispatcherMusicGroup)[0]);
_courierGroup = _mixer.FindMatchingGroups(AudioGroups.CourierMusicGroup)[0]; _audioMixerGroups.Add(AudioType.Courier, _mixer.FindMatchingGroups(AudioGroups.CourierGroup)[0]);
_enemiesGroup = _mixer.FindMatchingGroups(AudioGroups.EnemiesMusicGroup)[0]; _audioMixerGroups.Add(AudioType.Enemies, _mixer.FindMatchingGroups(AudioGroups.EnemiesGroup)[0]);
_audioMixerGroups.Add(AudioType.MenuMusic, _musicAudioGroups[MusicType.Menu]);
_audioMixerGroups.Add(AudioType.DeathMusic, _musicAudioGroups[MusicType.Death]);
_audioMixerGroups.Add(AudioType.ActionMusic, _musicAudioGroups[MusicType.Action]);
_audioMixerGroups.Add(AudioType.PeacefulMusic, _musicAudioGroups[MusicType.Peaceful]);
_snapshots[AudioSnapshotState.None] = _mixer.FindSnapshot(AudioGroups.NoneSnapshot);
_snapshots[AudioSnapshotState.Peaceful] = _mixer.FindSnapshot(AudioGroups.PeacefulSnapshot);
_snapshots[AudioSnapshotState.Action] = _mixer.FindSnapshot(AudioGroups.ActionSnapshot);
_snapshots[AudioSnapshotState.Menu] = _mixer.FindSnapshot(AudioGroups.MenuSnapshot);
await _audioFactory.LoadAudioSourcePrefab(_audioSourcePool.Initialize); await _audioFactory.LoadAudioSourcePrefab(_audioSourcePool.Initialize);
} }
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
private Dictionary<MusicType, CancellationTokenSource> _cancellationTokenSources = new(); private Dictionary<MusicType, CancellationTokenSource> _cancellationTokenSources = new();
private Dictionary<MusicType, AudioSource> _musicAudioSources = new(); private Dictionary<MusicType, AudioSource> _musicAudioSources = new();
private Dictionary<MusicType, AudioMixerGroup> _musicAudioGroups = new(); private Dictionary<MusicType, AudioMixerGroup> _musicAudioGroups = new();
@@ -169,19 +139,13 @@ namespace Code.Audio
_musicAudioSources[musicType].Play(); _musicAudioSources[musicType].Play();
// await UniTask.WaitUntilValueChanged(_musicAudioSources[musicType],
// _ => !_musicAudioSources[musicType].isPlaying,
// cancellationToken: _cancellationTokenSources[musicType].Token);
await UniTask.NextFrame(); await UniTask.NextFrame();
// Debug.Log($"Playing {musicType}");
var (isCanceled, _) = await UniTask.WaitUntilValueChanged(_musicAudioSources[musicType], var (isCanceled, _) = await UniTask.WaitUntilValueChanged(_musicAudioSources[musicType],
_ => !_musicAudioSources[musicType].isPlaying, _ => !_musicAudioSources[musicType].isPlaying,
cancellationToken: _cancellationTokenSources[musicType].Token).SuppressCancellationThrow(); cancellationToken: _cancellationTokenSources[musicType].Token).SuppressCancellationThrow();
// Debug.Log($"Finished {musicType}"); Debug.LogError("Music skipping");
if (isCanceled) if (isCanceled)
{ {
// Debug.Log($"Cancelled {musicType}");
_cancellationTokenSources[musicType].Dispose(); _cancellationTokenSources[musicType].Dispose();
_cancellationTokenSources[musicType] = new(); _cancellationTokenSources[musicType] = new();
@@ -191,13 +155,13 @@ namespace Code.Audio
return; return;
} }
PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(musicType); PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(musicType).Forget();
} }
public async UniTaskVoid GladlyAskToStopMusic(MusicType musicType, public async UniTaskVoid GladlyAskToStopMusic(MusicType musicType,
AudioSnapshotState audioSnapshotState = AudioSnapshotState.None, float time = 1f, Action callback = null) AudioSnapshotState audioSnapshotState = AudioSnapshotState.None, float time = 1f, Action callback = null)
{ {
TransitToSnapshot(audioSnapshotState, time); //TransitToSnapshot(audioSnapshotState, time);
await UniTask.WaitForSeconds(time); await UniTask.WaitForSeconds(time);
@@ -205,39 +169,56 @@ namespace Code.Audio
callback?.Invoke(); callback?.Invoke();
} }
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
public void StopMusic() public void StopMusic()
{ {
_peacefulMusicSource.Stop(); _peacefulMusicSource.Stop();
_actionMusicSource.Stop(); _actionMusicSource.Stop();
_cancellationTokenSources[MusicType.Peaceful].Cancel();
_cancellationTokenSources[MusicType.Action].Cancel();
} }
public void GladlyAskToStopMusic(Action callback = null) public void GladlyAskToStopMusic(Action callback = null)
{ {
TransitToSnapshot(AudioSnapshotState.None); // TransitToSnapshot(AudioSnapshotState.None);
_peacefulMusicSource.Stop(); _peacefulMusicSource.Stop();
_actionMusicSource.Stop(); _actionMusicSource.Stop();
callback?.Invoke(); callback?.Invoke();
} }
public void TransitToSnapshot(AudioSnapshotState state, float time = 1f) public void TransitToSnapshot(AudioSnapshotState state, float time = 1)
{ {
_snapshots[state].TransitionTo(time); foreach (var key in _audioMixerGroups.Keys)
_mixer.DOSetFloat(_audioMixerGroups[key].name, Mathf.Log10(_snapshotsVolumes[state][key]) * 20, time);
} }
#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) public void PlaySFX(SFXSounds sfxId, Vector3 position)
{ {
_audioSourcePool.PlayOneShot(_audioFactory.SFXAudios[(int)sfxId], position, _SFXGroup); _audioSourcePool
.PlayOneShot(_audioFactory.SFXAudios[(int)sfxId], position, _audioMixerGroups[AudioType.SFX]).Forget();
}
public void ApplyStun(float value, float time)
{
_mixer.DOSetFloat("Stun", value, time);
} }
public void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position) public void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position)
{ {
_audioSourcePool.PlayOneShot(_audioFactory.EnemiesAudios[(int)enemySoundId], position, _enemiesGroup); _audioSourcePool.PlayOneShot(_audioFactory.EnemiesAudios[(int)enemySoundId], position,
_audioMixerGroups[AudioType.Enemies]).Forget();
} }
public AudioSource GetSourceOfGroup(AudioType group)
{
AudioSource source = _audioSourcePool.GetSource();
source.outputAudioMixerGroup = _audioMixerGroups[group];
return source;
}
public void ReleaseSourceOfGroup(AudioSource source) => _audioSourcePool.ReleaseSource(source);
// Чинить долго и дорого пусть Артёмов будет много, ведь он наш друг // Чинить долго и дорого пусть Артёмов будет много, ведь он наш друг
public event IAudioService.OnAudioPlayingDelegate OnDispatcherStarted; public event IAudioService.OnAudioPlayingDelegate OnDispatcherStarted;
public event IAudioService.OnAudioPlayingDelegate OnDispatcherEnded; public event IAudioService.OnAudioPlayingDelegate OnDispatcherEnded;
@@ -245,108 +226,35 @@ namespace Code.Audio
public void PlayDispatcher(DispatcherSounds dispatcherSoundId) public void PlayDispatcher(DispatcherSounds dispatcherSoundId)
{ {
OnDispatcherStarted?.Invoke(); OnDispatcherStarted?.Invoke();
_audioSourcePool.PlayOneShot(_audioFactory.DispatcherAudios[(int)dispatcherSoundId], _dispatcherGroup, _audioSourcePool.PlayOneShot(_audioFactory.DispatcherAudios[(int)dispatcherSoundId],
AudioSourceType.NoBlend, () => OnDispatcherEnded?.Invoke()); _audioMixerGroups[AudioType.Dispatcher],
AudioSourceType.NoBlend, () => OnDispatcherEnded?.Invoke()).Forget();
} }
public void PlayCourier(CourierSounds courierSounds)
{
_audioSourcePool.PlayOneShot(_audioFactory.CourierAudios[(int)courierSounds],
_audioMixerGroups[AudioType.Courier],
AudioSourceType.NoBlend).Forget();
}
private CancellationTokenSource _testClipCancellationTokenSource = new(); private CancellationTokenSource _testClipCancellationTokenSource = new();
private void ResetCurrentTestAudioSource() => _currentTestClipAudioType = AudioType.Master; private void ResetCurrentTestAudioSource() => _currentTestClipAudioType = AudioType.Master;
private AudioType _currentTestClipAudioType;
// TODO Засунуть в словарь // TODO Засунуть в словарь
public void PlayTestClip(AudioType audioType) public void PlayTestClip(AudioType audioType)
{ {
if(_currentTestClipAudioType == audioType) return; if (_currentTestClipAudioType == audioType) return;
_testClipCancellationTokenSource.Cancel(); _testClipCancellationTokenSource.Cancel();
_testClipCancellationTokenSource = new(); _testClipCancellationTokenSource = new();
_currentTestClipAudioType = audioType; _currentTestClipAudioType = audioType;
switch (audioType) _audioSourcePool.PlayOneShot(_audioFactory.AudioTestClips[audioType],
{ _audioMixerGroups[audioType], _testClipCancellationTokenSource,
case AudioType.SFX: AudioSourceType.NoBlend, ResetCurrentTestAudioSource).Forget();
_audioSourcePool.PlayOneShot(_audioFactory.AudioTestClips[audioType],
_SFXGroup, _testClipCancellationTokenSource,
AudioSourceType.NoBlend, ResetCurrentTestAudioSource);
break;
case AudioType.Master:
_audioSourcePool.PlayOneShot(_audioFactory.AudioTestClips[audioType],
_masterGroup, _testClipCancellationTokenSource,
AudioSourceType.NoBlend, ResetCurrentTestAudioSource);
break;
case AudioType.Creatures:
_audioSourcePool.PlayOneShot( _audioFactory.AudioTestClips[audioType],
_creaturesGroup, _testClipCancellationTokenSource,
AudioSourceType.NoBlend, ResetCurrentTestAudioSource);
break;
case AudioType.GameplayMusic:
_audioSourcePool.PlayOneShot(_audioFactory.AudioTestClips[audioType],
_actionMusicGroup, _testClipCancellationTokenSource,
AudioSourceType.NoBlend, ResetCurrentTestAudioSource);
break;
case AudioType.MenuMusic:
_audioSourcePool.PlayOneShot(_audioFactory.AudioTestClips[audioType],
_menuMusicGroup, _testClipCancellationTokenSource,
AudioSourceType.NoBlend, ResetCurrentTestAudioSource);
break;
case AudioType.DispatcherSounds:
_audioSourcePool.PlayOneShot(_audioFactory.AudioTestClips[audioType],
_dispatcherGroup, _testClipCancellationTokenSource,
AudioSourceType.NoBlend, ResetCurrentTestAudioSource);
break;
}
}
private AudioSource _testClipAudioSource;
private AudioType _currentTestClipAudioType;
// Эффективно и просто, может не так хитровыебано
private void ReleaseTestAudioClipSource()
{
_testClipAudioSource = null;
}
// TODO Засунуть в словарь
public void PlayTestClipDeprecated(AudioType audioType)
{
if (!_testClipAudioSource) _testClipAudioSource = _audioSourcePool.GetSource();
else if (_currentTestClipAudioType != audioType) _testClipAudioSource.Stop();
else return;
_currentTestClipAudioType = audioType;
switch (audioType)
{
case AudioType.SFX:
_audioSourcePool.PlayOneShot(_testClipAudioSource, _audioFactory.AudioTestClips[audioType],
_SFXGroup,
AudioSourceType.NoBlend, ReleaseTestAudioClipSource);
break;
case AudioType.Master:
_audioSourcePool.PlayOneShot(_testClipAudioSource, _audioFactory.AudioTestClips[audioType],
_masterGroup,
AudioSourceType.NoBlend, ReleaseTestAudioClipSource);
break;
case AudioType.Creatures:
_audioSourcePool.PlayOneShot(_testClipAudioSource, _audioFactory.AudioTestClips[audioType],
_creaturesGroup,
AudioSourceType.NoBlend, ReleaseTestAudioClipSource);
break;
case AudioType.GameplayMusic:
_audioSourcePool.PlayOneShot(_testClipAudioSource, _audioFactory.AudioTestClips[audioType],
_actionMusicGroup,
AudioSourceType.NoBlend, ReleaseTestAudioClipSource);
break;
case AudioType.MenuMusic:
_audioSourcePool.PlayOneShot(_testClipAudioSource, _audioFactory.AudioTestClips[audioType],
_menuMusicGroup,
AudioSourceType.NoBlend, ReleaseTestAudioClipSource);
break;
case AudioType.DispatcherSounds:
_audioSourcePool.PlayOneShot(_testClipAudioSource, _audioFactory.AudioTestClips[audioType],
_dispatcherGroup,
AudioSourceType.NoBlend, ReleaseTestAudioClipSource);
break;
}
} }
} }
} }
@@ -14,6 +14,7 @@ namespace Code.Audio
List<AudioClip> SFXAudios { get; } List<AudioClip> SFXAudios { get; }
List<AudioClip> EnemiesAudios { get; } List<AudioClip> EnemiesAudios { get; }
List<AudioClip> DispatcherAudios { get; } List<AudioClip> DispatcherAudios { get; }
List<AudioClip> CourierAudios { get; }
UniTask LoadAudioSourcePrefab(Action<GameObject> callback); UniTask LoadAudioSourcePrefab(Action<GameObject> callback);
UniTask WarmGameplayMusic( ); UniTask WarmGameplayMusic( );
void ReleaseActionMusic(); void ReleaseActionMusic();
@@ -28,5 +29,9 @@ namespace Code.Audio
void ReleaseEnemies(); void ReleaseEnemies();
UniTask WarmDispatcher( ); UniTask WarmDispatcher( );
void ReleaseDispatcher(); void ReleaseDispatcher();
UniTask WarmCourier();
void ReleaseCourier();
UniTask WarmDeathMusic( );
void ReleaseDeathMusic();
} }
} }
@@ -23,5 +23,9 @@ namespace Code.Audio
void ChangeSetting(AudioType type, float value); void ChangeSetting(AudioType type, float value);
float GetSetting(AudioType type); float GetSetting(AudioType type);
void PlayTestClip(AudioType audioType); void PlayTestClip(AudioType audioType);
AudioSource GetSourceOfGroup(AudioType group);
void ReleaseSourceOfGroup(AudioSource source);
void PlayCourier(CourierSounds range);
void ApplyStun(float value, float time);
} }
} }
+10 -6
View File
@@ -4,15 +4,19 @@ namespace Code.Audio
{ {
Menu, Menu,
Peaceful, Peaceful,
Action Action,
Death
} }
public enum AudioType public enum AudioType
{ {
Master, Master,
MenuMusic, MenuMusic,
GameplayMusic, Dispatcher,
Creatures, SFX,
DispatcherSounds, Courier,
SFX Enemies,
ActionMusic,
PeacefulMusic,
DeathMusic
} }
} }
@@ -1,6 +1,6 @@
using UnityEngine; using UnityEngine;
using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets;
using UnityEngine.Audio; using UnityEngine.Audio;
namespace Code.Configs namespace Code.Configs
{ {
@@ -1,11 +0,0 @@
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace Code.Configs
{
[CreateAssetMenu(menuName = "Config/Audio/CharacterSoundList", fileName = "CharacterSoundListConfig")]
public class CharacterSoundListConfig : ScriptableObject
{
public AssetReference[] character;
}
}
@@ -0,0 +1,11 @@
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace Code.Configs
{
[CreateAssetMenu(menuName = "Config/Audio/CourierSoundListConfig", fileName = "CourierSoundListConfig")]
public class CourierSoundListConfig : ScriptableObject
{
public AssetReference[] courierSounds;
}
}
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using AYellowpaper.SerializedCollections;
using UnityEngine;
using AudioType = Code.Audio.AudioType;
namespace Code.Configs
{
[CreateAssetMenu(fileName = "DefaultAudioSettingsConfig", menuName = "Audio/DefaultAudioSettings")]
public class DefaultAudioSettingsConfig : ScriptableObject
{
[Header("Menu")]
[SerializedDictionary("AudioType", "Volume")]
public SerializedDictionary<Audio.AudioType, float> menuVolume = new();
[Header("Action")]
[SerializedDictionary("AudioType", "Volume")]
public SerializedDictionary<Audio.AudioType, float> actionVolume = new();
[Header("Peaceful")]
[SerializedDictionary("AudioType", "Volume")]
public SerializedDictionary<Audio.AudioType, float> peacefulVolume = new();
[Header("None")]
[SerializedDictionary("AudioType", "Volume")]
public SerializedDictionary<Audio.AudioType, float> noneVolume = new();
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 36d35c52933d4d4ba836f75b05c4810f
timeCreated: 1764754933
@@ -0,0 +1,10 @@
using UnityEngine;
namespace Code.Configs
{
[CreateAssetMenu(menuName = "Config/Audio/MusicPlayer", fileName = "MusicPlayerConfig")]
public class MusicPlayerConfig : ScriptableObject
{
public float threshold = 0.5f;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8708e3c129d241b08563f1a170bd3a44
timeCreated: 1764585060
@@ -8,6 +8,7 @@ namespace Code.Configs
{ {
public AssetReference[] peacefulSoundtrack; public AssetReference[] peacefulSoundtrack;
public AssetReference[] actionSoundtrack; public AssetReference[] actionSoundtrack;
public AssetReference[] deathSoundtrack;
public AssetReference[] menuSoundtrack; public AssetReference[] menuSoundtrack;
} }
} }
@@ -19,13 +19,14 @@ namespace Code.Constants
public const string PeacefulMusicGroup = "Peaceful"; public const string PeacefulMusicGroup = "Peaceful";
public const string ActionMusicGroup = "Action"; public const string ActionMusicGroup = "Action";
public const string DispatcherMusicGroup = "Dispatcher"; public const string DispatcherMusicGroup = "Dispatcher";
public const string CourierMusicGroup = "Courier"; public const string CourierGroup = "Courier";
public const string EnemiesMusicGroup = "Enemies"; public const string EnemiesGroup = "Enemies";
public const string PeacefulSnapshot = "Peaceful"; public const string PeacefulSnapshot = "Peaceful";
public const string ActionSnapshot = "Action"; public const string ActionSnapshot = "Action";
public const string NoneSnapshot = "None"; public const string NoneSnapshot = "None";
public const string MenuSnapshot = "Menu"; public const string MenuSnapshot = "Menu";
public const string MenuMusicGroup = "Menu"; public const string MenuMusicGroup = "Menu";
public const string DeathMusicGroup = "Death";
} }
} }
@@ -24,6 +24,8 @@ namespace Code.Gameplay.Camera.CameraStates
CurrentDistance = 0f; CurrentDistance = 0f;
Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.FirstPerson].fov; Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.FirstPerson].fov;
Cursor.lockState = CursorLockMode.Locked;
} }
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation) protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
@@ -11,6 +11,7 @@ namespace Code.Gameplay.Camera.CameraStates
base.EnterState(); base.EnterState();
Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.MainMenu].fov; Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.MainMenu].fov;
Cursor.lockState = CursorLockMode.None;
} }
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation) protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
@@ -12,6 +12,7 @@ namespace Code.Gameplay.Camera.CameraStates
base.EnterState(); base.EnterState();
Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.Static].fov; Camera.fieldOfView = Context.CameraSettingsConfigs[CameraMode.Static].fov;
Cursor.lockState = CursorLockMode.None;
} }
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation) protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
@@ -1,9 +1,13 @@
using UnityEngine; using DG.Tweening;
using UnityEngine;
namespace Code.Gameplay.Door namespace Code.Gameplay.Door
{ {
public class Door : MonoBehaviour public class Door : MonoBehaviour
{ {
[SerializeField] private Transform doorPolotno;
private Vector3 _doorInitialPosition;
private Quaternion _doorInitialRotation;
[SerializeField] private Transform hingeJointAnchor; [SerializeField] private Transform hingeJointAnchor;
[SerializeField] private HingeJoint hingeJoint; [SerializeField] private HingeJoint hingeJoint;
[SerializeField] private Rigidbody rigidbody; [SerializeField] private Rigidbody rigidbody;
@@ -15,9 +19,19 @@ namespace Code.Gameplay.Door
rigidbody.isKinematic = true; rigidbody.isKinematic = true;
return; return;
} }
_doorInitialPosition = doorPolotno.position;
_doorInitialRotation = doorPolotno.rotation;
rigidbody.isKinematic = false; rigidbody.isKinematic = false;
hingeJoint.autoConfigureConnectedAnchor = false; hingeJoint.autoConfigureConnectedAnchor = false;
hingeJoint.connectedAnchor = hingeJointAnchor.position; hingeJoint.connectedAnchor = hingeJointAnchor.position;
} }
public void CloseTheDoor()
{
TranslationMode(true);
doorPolotno.DORotate(_doorInitialRotation.eulerAngles, 0.5f);
doorPolotno.DOMove(_doorInitialPosition, 0.5f);
}
} }
} }
@@ -0,0 +1,53 @@
using System;
using DG.Tweening;
using UnityEngine;
namespace Code.Gameplay.Door
{
public class DoorDebug : MonoBehaviour
{
[SerializeField] private Transform doorSelf;
[SerializeField] private Transform doorPolotno;
private Vector3 _doorInitialPosition;
private Quaternion _doorInitialRotation;
[SerializeField] private Transform hingeJointAnchor;
[SerializeField] private HingeJoint hingeJoint;
[SerializeField] private Rigidbody rigidbody;
[SerializeField] private bool debug;
[SerializeField] private bool closed;
private void Start()
{
_doorInitialPosition = doorPolotno.position;
_doorInitialRotation = doorPolotno.rotation;
}
private void Update()
{
if(debug && !closed)
{
CloseTheDoor();
}
}
public void TranslationMode(bool on)
{
if (on)
{
rigidbody.isKinematic = true;
return;
}
_doorInitialPosition = doorPolotno.position;
_doorInitialRotation = doorPolotno.rotation;
rigidbody.isKinematic = false;
hingeJoint.autoConfigureConnectedAnchor = false;
hingeJoint.connectedAnchor = hingeJointAnchor.position;
}
public void CloseTheDoor()
{
// TranslationMode(true);
doorPolotno.DORotate(_doorInitialRotation.eulerAngles, 0.5f);
doorPolotno.DOMove(_doorInitialPosition, 0.5f);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: ed06ed70c7924ca9bc59f33ee7e6cdfa
timeCreated: 1764533216
@@ -0,0 +1,7 @@
namespace Code.Gameplay.Door
{
public class DoorPooler
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: acfad6f51f224b51abb761fc22e4356f
timeCreated: 1764521809
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f17ace0fa75741f2a730ff21181c6e8c
timeCreated: 1764575680
@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.AI;
namespace Code.Gameplay.Enemies.Animators
{
public class EnemyAnimator : MonoBehaviour
{
private static readonly int Velocity = Animator.StringToHash("Velocity");
[SerializeField] private Animator animator;
[SerializeField] private NavMeshAgent agent;
private void SetVelocity(float velocity)
{
animator.SetFloat(Velocity, velocity);
}
private void Update()
{
if(agent) SetVelocity(agent.velocity.magnitude);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 936125a7ed844674b0e0586a484253ce
timeCreated: 1764575708
@@ -1,8 +1,10 @@
using Code.Audio;
using UnityEngine; using UnityEngine;
using UnityEngine.AI; using UnityEngine.AI;
using Code.Gameplay.Player; using Code.Gameplay.Player;
using Code.Gameplay.Character.Controller; using Code.Gameplay.Character.Controller;
using Code.Gameplay.Character.Core; using Code.Gameplay.Character.Core;
using Code.Gameplay.Enemies.Animators;
using Reflex.Attributes; using Reflex.Attributes;
using Reflex.Core; using Reflex.Core;
using Reflex.Injectors; using Reflex.Injectors;
@@ -12,7 +14,8 @@ namespace Code.Gameplay.Enemies
public abstract class BaseEnemy : MonoBehaviour public abstract class BaseEnemy : MonoBehaviour
{ {
[SerializeField] protected NavMeshAgent agent; [SerializeField] protected NavMeshAgent agent;
[SerializeField] protected Collider enemyCollider; [SerializeField] protected Collider enemyCollider;
[Inject] protected IAudioService audioService;
protected int Damage; protected int Damage;
protected float AttackCooldown; protected float AttackCooldown;
@@ -35,7 +38,7 @@ namespace Code.Gameplay.Enemies
private bool _isStunned; private bool _isStunned;
private float _currentStunTimer; private float _currentStunTimer;
private bool _canAttack = true; protected bool _canAttack = true;
private float _attackCooldownTimer; private float _attackCooldownTimer;
private enum IdleState { Moving, Paused } private enum IdleState { Moving, Paused }
@@ -50,16 +53,17 @@ namespace Code.Gameplay.Enemies
protected virtual void Awake() protected virtual void Awake()
{ {
if (_playerProvider == null) // // TODO Мешает
{ // if (_playerProvider == null)
AttributeInjector.Inject(this, Container.ProjectContainer); // {
} // AttributeInjector.Inject(this, Container.ProjectContainer);
// }
} }
protected virtual void Update() protected virtual void Update()
{ {
if (!Player) return; if (!Player) return;
HandleStun(); HandleStun();
HandleAttackCooldown(); HandleAttackCooldown();
if (_isStunned) return; if (_isStunned) return;
@@ -164,19 +168,19 @@ namespace Code.Gameplay.Enemies
protected virtual void HandleAttackCooldown() protected virtual void HandleAttackCooldown()
{ {
if (!_canAttack) if (_canAttack) return;
_attackCooldownTimer -= Time.deltaTime;
if (_attackCooldownTimer <= 0)
{ {
_attackCooldownTimer -= Time.deltaTime; _canAttack = true;
if (_attackCooldownTimer <= 0)
{
_canAttack = true;
}
} }
} }
protected virtual void DealDamage() protected virtual void DealDamage()
{ {
if (!_canAttack || PlayerHealth == null) return; if (PlayerHealth == null) return;
PlayerHealth.GetDamage(Damage); PlayerHealth.GetDamage(Damage);
ApplyEffectsToPlayer(); ApplyEffectsToPlayer();
@@ -184,11 +188,10 @@ namespace Code.Gameplay.Enemies
_canAttack = false; _canAttack = false;
_attackCooldownTimer = AttackCooldown; _attackCooldownTimer = AttackCooldown;
} }
protected virtual void ApplyEffectsToPlayer() protected virtual void ApplyEffectsToPlayer()
{ {
if (PlayerController) if (PlayerController)
PlayerController.BlockAbilities(3f); PlayerController.BlockAbilities(3f); // TODO в конфиг
} }
private void OnDrawGizmosSelected() private void OnDrawGizmosSelected()
@@ -1,3 +1,4 @@
using Code.Audio;
using Code.Configs; using Code.Configs;
using Reflex.Attributes; using Reflex.Attributes;
using UnityEngine; using UnityEngine;
@@ -35,7 +36,7 @@ namespace Code.Gameplay.Enemies
{ {
base.Awake(); base.Awake();
if (agent == null) return; if (!agent) return;
var walkableArea = NavMesh.GetAreaFromName("Cockroach"); var walkableArea = NavMesh.GetAreaFromName("Cockroach");
agent.areaMask = 1 << walkableArea; agent.areaMask = 1 << walkableArea;
@@ -43,12 +44,14 @@ namespace Code.Gameplay.Enemies
protected override void HandleAttack() protected override void HandleAttack()
{ {
if (!Player) return; if (!Player || !_canAttack) return;
var distance = Vector3.Distance(transform.position, Player.transform.position); var distance = Vector3.Distance(transform.position, Player.transform.position);
if (!(distance <= AttackRange)) return; if (!(distance <= AttackRange)) return;
audioService.PlayEnemy(EnemiesSounds.RoachAttack, agent.transform.position);
DealDamage(); DealDamage();
} }
} }
@@ -1,4 +1,6 @@
using Code.Audio;
using Code.Configs; using Code.Configs;
using Code.Gameplay.Enemies.Animators;
using Reflex.Attributes; using Reflex.Attributes;
using UnityEngine; using UnityEngine;
using UnityEngine.AI; using UnityEngine.AI;
@@ -38,17 +40,18 @@ namespace Code.Gameplay.Enemies
if (agent == null) return; if (agent == null) return;
var walkableArea = NavMesh.GetAreaFromName("Walkable"); var walkableArea = NavMesh.GetAreaFromName("Walkable");
agent.areaMask = 1 << walkableArea; agent.areaMask = 1 << walkableArea;
} }
protected override void HandleAttack() protected override void HandleAttack()
{ {
if (!Player) return; if (!Player || !_canAttack) return;
var distance = Vector3.Distance(transform.position, Player.transform.position); var distance = Vector3.Distance(transform.position, Player.transform.position);
if (!(distance <= AttackRange)) return; if (!(distance <= AttackRange)) return;
audioService.PlayEnemy(EnemiesSounds.GrandpaAttack,agent.transform.position);
if (Player.CustomCharacterController.IsSliding) if (Player.CustomCharacterController.IsSliding)
ApplyStun(); ApplyStun();
else else
@@ -0,0 +1,34 @@
using Code.Audio;
using Reflex.Attributes;
using UnityEngine;
namespace Code.Gameplay.Enemies
{
public class EnemyAudio : MonoBehaviour
{
private IAudioService _audioService;
private IAudioFactory _audioFactory;
[SerializeField] private AudioSource _audioSource;
[SerializeField] private EnemiesSounds stepId;
[Inject]
private void Construct(IAudioService audioService, IAudioFactory audioFactory)
{
_audioService = audioService;
_audioSource = audioService.GetSourceOfGroup(Audio.AudioType.Enemies);
_audioSource.transform.position = transform.position;
_audioSource.spatialBlend = 0;
_audioFactory = audioFactory;
}
public void PlayStep()
{
_audioSource.transform.position = transform.position;
_audioSource.PlayOneShot(_audioFactory.EnemiesAudios[(int)stepId]);
}
private void OnDestroy()
{
_audioService.ReleaseSourceOfGroup(_audioSource);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 91cb250df1b24fc4825ee791a12dda11
timeCreated: 1764695102
@@ -3,9 +3,11 @@ using Code.Configs;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using Reflex.Attributes; using Reflex.Attributes;
using Reflex.Core; using Reflex.Core;
using Reflex.Extensions;
using Reflex.Injectors; using Reflex.Injectors;
using UnityEngine; using UnityEngine;
using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;
namespace Code.Gameplay.Enemies namespace Code.Gameplay.Enemies
{ {
@@ -27,14 +29,14 @@ namespace Code.Gameplay.Enemies
) )
.ToUniTask(); .ToUniTask();
AttributeInjector.Inject(enemyObj, Container.ProjectContainer); GameObjectInjector.InjectRecursive(enemyObj, SceneManager.GetActiveScene().GetSceneContainer());
return enemyObj.GetComponent<BaseEnemy>(); return enemyObj.GetComponent<BaseEnemy>();
} }
public void ReleaseEnemy(BaseEnemy enemy) public void ReleaseEnemy(BaseEnemy enemy)
{ {
if (enemy == null) return; if (!enemy) return;
enemy.gameObject.SetActive(false); enemy.gameObject.SetActive(false);
@@ -1,8 +1,6 @@
using Code.Gameplay.Player; using Code.Gameplay.Player;
using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks;
using Reflex.Attributes; using Reflex.Attributes;
using Reflex.Core;
using Reflex.Injectors;
using UnityEngine; using UnityEngine;
namespace Code.Gameplay.Enemies namespace Code.Gameplay.Enemies
@@ -20,13 +18,14 @@ namespace Code.Gameplay.Enemies
private bool _isSpawning; private bool _isSpawning;
private bool _isPlayerInRange; private bool _isPlayerInRange;
private void Awake() // GameObjectSelfInjector существует
{ // private void Awake()
if (_playerProvider == null || _enemyFactory == null) // {
{ // if (_playerProvider == null || _enemyFactory == null)
AttributeInjector.Inject(this, Container.ProjectContainer); // {
} // AttributeInjector.Inject(this, Container.ProjectContainer);
} // }
// }
private void Update() private void Update()
{ {
@@ -64,9 +63,14 @@ namespace Code.Gameplay.Enemies
_isSpawning = false; _isSpawning = false;
} }
private void OnDestroy()
{
Despawn();
}
private void Despawn() private void Despawn()
{ {
if (_spawnedEnemy == null) return; if (!_spawnedEnemy) return;
_enemyFactory.ReleaseEnemy(_spawnedEnemy); _enemyFactory.ReleaseEnemy(_spawnedEnemy);
_spawnedEnemy = null; _spawnedEnemy = null;
@@ -0,0 +1,32 @@
using Code.Audio;
using Reflex.Attributes;
using UnityEngine;
using AudioType = Code.Audio.AudioType;
namespace Code.Gameplay.Player
{
public class PlayerAudio : MonoBehaviour
{
private IAudioService _audioService;
private IAudioFactory _audioFactory;
private AudioSource _audioSource;
[Inject]
private void Construct(IAudioService audioService, IAudioFactory audioFactory)
{
_audioService = audioService;
_audioSource = audioService.GetSourceOfGroup(AudioType.Courier);
_audioFactory = audioFactory;
}
public void PlayStep()
{
_audioSource.PlayOneShot(_audioFactory.CourierAudios[(int)CourierSounds.Step]);
}
private void OnDestroy()
{
_audioService.ReleaseSourceOfGroup(_audioSource);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 64f99dccce9d41df98accae0f355dbca
timeCreated: 1764584350
@@ -21,7 +21,7 @@ namespace Code.Gameplay.Player
if (count < 0) count = _playerConfig.maxHealth; if (count < 0) count = _playerConfig.maxHealth;
return new(count); return new(count);
} }
public async UniTask<CharacterProvider> CreatePlayer() public async UniTask<CharacterProvider> CreatePlayer()
{ {
@@ -42,7 +42,13 @@ namespace Code.Gameplay.Player
Addressables.ReleaseInstance(characterProvider.gameObject); Addressables.ReleaseInstance(characterProvider.gameObject);
} }
public async UniTask<ArmsMeshProvider> CreateArms(Transform papochka) => (await Addressables.InstantiateAsync(_playerConfig.armsMeshPrefab, papochka).ToUniTask()).GetComponent<ArmsMeshProvider>(); public async UniTask<ArmsMeshProvider> CreateArms(Transform papochka)
{
var armsMesh = (await Addressables.InstantiateAsync(_playerConfig.armsMeshPrefab, papochka).ToUniTask());
GameObjectInjector.InjectRecursive(armsMesh, Container.ProjectContainer);
return armsMesh.GetComponent<ArmsMeshProvider>();
}
public void ReleaseArms(ArmsMeshProvider arms) => Addressables.ReleaseInstance(arms.gameObject); public void ReleaseArms(ArmsMeshProvider arms) => Addressables.ReleaseInstance(arms.gameObject);
} }
} }
@@ -12,5 +12,6 @@ namespace Code.Generator
Room CreateRoomByIndex(int index, RoomType roomType); Room CreateRoomByIndex(int index, RoomType roomType);
void ReleaseRooms(); void ReleaseRooms();
GameObject GetRandomCachedPrefabOfType(RoomType roomType, out int index); GameObject GetRandomCachedPrefabOfType(RoomType roomType, out int index);
int GetRandomIndexOfType(RoomType roomType);
} }
} }
+11 -12
View File
@@ -1,11 +1,12 @@
using System; using System;
using Code.Gameplay.Door; using Code.Gameplay.Door;
using Code.Gameplay.Orders.Order;
using Code.UI; using Code.UI;
using UnityEngine; using UnityEngine;
namespace Code.Generator namespace Code.Generator
{ {
[RequireComponent(typeof(Transform))] // Для написания нормальной системы комнат нужен другой подход в корне, это уже не исправить, только залатать большие дыры
public class Room : MonoBehaviour public class Room : MonoBehaviour
{ {
[SerializeField] protected RoomType roomType; [SerializeField] protected RoomType roomType;
@@ -15,19 +16,17 @@ namespace Code.Generator
[SerializeField] protected Transform enterMarker; [SerializeField] protected Transform enterMarker;
public Transform EnterMarker => enterMarker; public Transform EnterMarker => enterMarker;
[SerializeField] protected Transform exitMarker; [SerializeField] protected Transform exitMarker;
[SerializeField] protected Transform doorSlot;
public Transform ExitMarker => exitMarker; public Transform ExitMarker => exitMarker;
[SerializeField] protected Door door; [SerializeField] protected Door door;
protected void Awake() public void Initialize(IOrderService orderService)
{ {
if (EnterMarker == null || ExitMarker == null) door.TranslationMode(false);
{
Debug.LogError($"Але маркеры не найдены у комнаты {gameObject.name}"); if(roomTrigger) roomTrigger.OrderService = orderService;
}
} }
public void Seal() => door.CloseTheDoor();
public void Initialize() => door.TranslationMode(false); [SerializeField] public RoomTrigger roomTrigger;
//PIZDEC
} }
} }
@@ -1,8 +1,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using Code.Gameplay.Orders.Order; using Code.Gameplay.Orders.Order;
using Code.Scenes; using Code.Scenes;
using Code.Scenes.SceneEnvironments; using Code.Scenes.SceneEnvironments;
using Cysharp.Threading.Tasks;
using Reflex.Attributes; using Reflex.Attributes;
using UnityEngine; using UnityEngine;
@@ -36,43 +35,22 @@ namespace Code.Generator
public void Initialize() public void Initialize()
{ {
// _orderService.OrderGive();
_spawnedRooms = new List<Room>(); _spawnedRooms = new List<Room>();
_roomIndexesStack = new(); _roomIndexesStack = new();
Debug.LogWarning($"КОТЛЫ ГЕНЕРАЛЬСКИЕ{_orderService.DeliveryTimer}");
// CreateRoomsStack();
// SpawnInitialRoomsAsync();
_orderService.OnOrderGiven += CreateRoomsStack; _orderService.OnOrderGiven += CreateRoomsStack;
RoomTrigger.PlayerEnteredRoom += OnPlayerEntered; CreateInitialRoom();
CreateInitialRoom();
SpawnNextRoomAsync();
} }
private void OnEnable() private void OnPlayerEntered()
{ {
RoomTrigger.PlayerEnteredRoom += OnPlayerEntered; SpawnNextRoom();
}
private void OnDisable()
{
RoomTrigger.PlayerEnteredRoom -= OnPlayerEntered;
}
public void OnPlayerEntered()
{
SpawnNextRoomAsync();
if (_spawnedRooms.Count > 3) if (_spawnedRooms.Count > 3)
{ {
Room roomToRemove = _spawnedRooms[0]; Room roomToRemove = _spawnedRooms[0];
_spawnedRooms.RemoveAt(0); _spawnedRooms.RemoveAt(0);
// _factory.ReleaseRoom(roomToRemove);
Object.Destroy(roomToRemove.gameObject); Object.Destroy(roomToRemove.gameObject);
} }
} }
@@ -92,45 +70,48 @@ namespace Code.Generator
_roomIndexesStack.Add(new(RoomType.Basic, roomIndex)); _roomIndexesStack.Add(new(RoomType.Basic, roomIndex));
remainingTime -= room.RoomTimer; remainingTime -= room.RoomTimer;
Debug.Log($"комната {room.name} время {room.RoomTimer} осталось: {remainingTime}");
} }
CreateSaveRoom();
AddPickupRoom(); AddPickupRoom();
AddSaveRoom();
Debug.Log($"стек комнат: {_roomIndexesStack.Count}"); SpawnNextRoom();
SpawnNextRoomAsync();
} }
private void CreateSaveRoom() private void AddSaveRoom()
{ {
var prefab = _factory.GetRandomCachedPrefabOfType(RoomType.Save, out int roomIndex); int saveRoomIndex = _factory.GetRandomIndexOfType(RoomType.Save);
Room saveRoom = prefab.GetComponent<Room>();
_roomIndexesStack.Add(new(RoomType.Save, roomIndex)); _roomIndexesStack.Add(new(RoomType.Save, saveRoomIndex));
Debug.Log($"Первая комната: {saveRoom.name}");
} }
private void AddPickupRoom()
{
int pickupIndex = _factory.GetRandomIndexOfType(RoomType.PickUp);
int insertPos = Random.Range(1, _roomIndexesStack.Count + 1);
_roomIndexesStack.Insert(insertPos, new(RoomType.PickUp, pickupIndex));
}
[Inject] private CurrentSceneEnvironment _currentSceneEnvironment; [Inject] private CurrentSceneEnvironment _currentSceneEnvironment;
private void CreateInitialRoom() private void CreateInitialRoom()
{ {
GameplaySceneEnvironment gameplaySceneEnvironment = (GameplaySceneEnvironment)_currentSceneEnvironment; GameplaySceneEnvironment gameplaySceneEnvironment = (GameplaySceneEnvironment)_currentSceneEnvironment;
_factory.GetRandomCachedPrefabOfType(RoomType.Initial, out int roomIndex); int roomIndex = _factory.GetRandomIndexOfType(RoomType.Initial);
// _roomIndexesStack.Add(new(RoomType.Initial, roomIndex));
InitialRoom instantiated = _factory.CreateRoomByIndex(roomIndex, RoomType.Initial).GetComponent<InitialRoom>(); InitialRoom instantiated = _factory.CreateRoomByIndex(roomIndex, RoomType.Initial).GetComponent<InitialRoom>();
_spawnedRooms.Add(instantiated); _spawnedRooms.Add(instantiated);
instantiated.transform.position = Vector3.zero; instantiated.transform.position = Vector3.zero;
instantiated.transform.rotation = Quaternion.identity; instantiated.transform.rotation = Quaternion.identity;
gameplaySceneEnvironment.playerSpawnPoint = instantiated.playerSpawn; gameplaySceneEnvironment.playerSpawnPoint = instantiated.playerSpawn;
instantiated.Initialize(); instantiated.Initialize(_orderService);
Debug.Log($"Первая комната: {instantiated.name}");
} }
private void SpawnNextRoomAsync() private void SpawnNextRoom()
{ {
if (_nextRoomStackIndex >= _roomIndexesStack.Count) if (_nextRoomStackIndex >= _roomIndexesStack.Count)
return; return;
@@ -149,23 +130,14 @@ namespace Code.Generator
PlaceRoom(room, previousRoom); PlaceRoom(room, previousRoom);
} }
// Отписываться можно, но Хатико никогда не дождётся вызова уничтоженного объекта.
room.roomTrigger.OnEnter += OnPlayerEntered;
room.roomTrigger.OnExit += _spawnedRooms[^1].Seal;
_spawnedRooms.Add(room); _spawnedRooms.Add(room);
_nextRoomStackIndex++; _nextRoomStackIndex++;
} }
private void AddPickupRoom()
{
var prefab = _factory.GetRandomCachedPrefabOfType(RoomType.PickUp, out int pickupIndex);
Room pickupRoom = prefab.GetComponent<Room>();
if (_roomIndexesStack.Count == 0) return;
int insertPos = Random.Range(1, _roomIndexesStack.Count + 1);
_roomIndexesStack.Insert(insertPos, new(RoomType.PickUp, pickupIndex));
}
private void PlaceRoom(Room current, Room previous) private void PlaceRoom(Room current, Room previous)
{ {
@@ -216,18 +188,8 @@ namespace Code.Generator
segmentOriginPosition.y -= randomDoorOriginPosition.y; segmentOriginPosition.y -= randomDoorOriginPosition.y;
current.transform.position = segmentOriginPosition; current.transform.position = segmentOriginPosition;
current.transform.rotation = Quaternion.Euler(0, segmentOriginYRotation, 0); current.transform.rotation = Quaternion.Euler(0, segmentOriginYRotation, 0);
// locationSegment.isNeedSomeDoors = true; current.Initialize(_orderService);
// locationSegment.AddBadDoorId(locationSegment.LocationSegment.GetDoorOrigins.IndexOf(randomDoorOrigin));
current.Initialize();
float frameOnTheBallRotation = segmentOriginYRotation + randomDoorOriginRotation.eulerAngles.y;
if (frameOnTheBallRotation > 305f) frameOnTheBallRotation -= 360f;
else if (frameOnTheBallRotation < -45f) frameOnTheBallRotation += 360f;
// heOnTheBall.AddSlaveLocationSegment(locationSegment.Id);
// heOnTheBall.ReplaceSlaveSegmentDoorOriginYRotation(frameOnTheBallRotation);
// heOnTheBall.isGotOnTheBall = false;
} }
} }
} }
@@ -59,6 +59,7 @@ namespace Code.Generator
index = Random.Range(0, _cashedRooms[roomType].Count); index = Random.Range(0, _cashedRooms[roomType].Count);
return _cashedRooms[roomType][index]; return _cashedRooms[roomType][index];
} }
public int GetRandomIndexOfType(RoomType roomType) => Random.Range(0, _cashedRooms[roomType].Count);
public Room CreateRoomByIndex(int index, RoomType roomType) public Room CreateRoomByIndex(int index, RoomType roomType)
{ {
@@ -1,32 +1,36 @@
using System; using System;
using Code.Gameplay.Orders.Order; using Code.Gameplay.Orders.Order;
using Reflex.Attributes;
using UnityEngine; using UnityEngine;
namespace Code.Generator namespace Code.Generator
{ {
public class RoomTrigger : MonoBehaviour public class RoomTrigger : MonoBehaviour
{ {
[Inject] private IOrderService _orderService; public IOrderService OrderService;
public event Action OnEnter;
public static event Action PlayerEnteredRoom; public event Action OnExit;
private bool _playerEntered; private bool _playerEntered, _playerExited;
// [Inject]
// private void Construct(IOrderService orderService)
// {
// _orderService = orderService;
// }
private void OnTriggerEnter(Collider other) private void OnTriggerEnter(Collider other)
{ {
if (_playerEntered) return; if (_playerEntered) return;
_playerEntered = true; _playerEntered = true;
_orderService.RoomPassed(); OrderService.RoomPassed();
OnEnter?.Invoke();
}
private void OnTriggerExit(Collider other)
{
if (_playerExited) return;
Debug.Log(other.name);
PlayerEnteredRoom?.Invoke(); _playerExited = true;
OnExit?.Invoke();
} }
} }
} }
@@ -1,3 +1,3 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 4207b7568dc3482393ac1860a31909b4 guid: 0d6940d73d544f0a8e4a45d956bc2364
timeCreated: 1764087485 timeCreated: 1764525516
@@ -1,5 +1,6 @@
using Code.Gameplay.Orders.Order; using Code.Gameplay.Orders.Order;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization; using UnityEngine.Serialization;
namespace Code.Scenes.SceneEnvironments namespace Code.Scenes.SceneEnvironments
@@ -7,11 +8,13 @@ namespace Code.Scenes.SceneEnvironments
[System.Serializable] [System.Serializable]
public class GameplaySceneEnvironment : CurrentSceneEnvironment public class GameplaySceneEnvironment : CurrentSceneEnvironment
{ {
public Transform playerSpawnPoint; public Transform playerSpawnPoint;
public Volume volume;
public void TransitVariables(GameplaySceneEnvironment env) public void TransitVariables(GameplaySceneEnvironment env)
{ {
playerSpawnPoint = env.playerSpawnPoint; playerSpawnPoint = env.playerSpawnPoint;
volume = env.volume;
} }
} }
} }
@@ -33,6 +33,8 @@ namespace Code.StaticData
Dictionary<AudioSourceType, AudioSourceSettingsConfig> AudioSourceSettingsConfigs { get; } Dictionary<AudioSourceType, AudioSourceSettingsConfig> AudioSourceSettingsConfigs { get; }
AudioTestClipsConfig AudioTestClipsConfig { get; } AudioTestClipsConfig AudioTestClipsConfig { get; }
GeneratorConfig GeneratorConfig { get; } GeneratorConfig GeneratorConfig { get; }
CourierSoundListConfig CourierSoundListConfig { get; }
DefaultAudioSettingsConfig DefaultAudioSettingsConfig { get; }
void Load(); void Load();
Task<T> InstantiateAsset<T>(AssetReference assetReference) where T : Behaviour; Task<T> InstantiateAsset<T>(AssetReference assetReference) where T : Behaviour;
} }
@@ -29,6 +29,8 @@ namespace Code.StaticData
public DispatcherSoundListConfig DispatcherSoundListConfig { get; private set; } public DispatcherSoundListConfig DispatcherSoundListConfig { get; private set; }
public EnemiesSoundListConfig EnemiesSoundListConfig { get; private set; } public EnemiesSoundListConfig EnemiesSoundListConfig { get; private set; }
public AudioTestClipsConfig AudioTestClipsConfig { get; private set; } public AudioTestClipsConfig AudioTestClipsConfig { get; private set; }
public CourierSoundListConfig CourierSoundListConfig { get; private set; }
public DefaultAudioSettingsConfig DefaultAudioSettingsConfig { get; private set; }
public DrunkenGrandpaConfig DrunkenGrandpaConfig {get; private set;} public DrunkenGrandpaConfig DrunkenGrandpaConfig {get; private set;}
public CockroachConfig CockroachConfig { get; private set; } public CockroachConfig CockroachConfig { get; private set; }
@@ -66,9 +68,11 @@ namespace Code.StaticData
private void LoadAudioConfigs() private void LoadAudioConfigs()
{ {
AudioMixerConfig = Resources.Load<AudioMixerConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "AudioMixerConfig")); AudioMixerConfig = Resources.Load<AudioMixerConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "AudioMixerConfig"));
DefaultAudioSettingsConfig = Resources.Load<DefaultAudioSettingsConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "DefaultAudioSettingsConfig"));
SoundtrackListConfig = Resources.Load<SoundtrackListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "SoundtrackListConfig")); SoundtrackListConfig = Resources.Load<SoundtrackListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "SoundtrackListConfig"));
AudioTestClipsConfig = Resources.Load<AudioTestClipsConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "AudioTestClipsConfig")); AudioTestClipsConfig = Resources.Load<AudioTestClipsConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "AudioTestClipsConfig"));
SFXListConfig = Resources.Load<SFXListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "SFXListConfig")); SFXListConfig = Resources.Load<SFXListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "SFXListConfig"));
CourierSoundListConfig = Resources.Load<CourierSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "CourierSoundListConfig"));
DispatcherSoundListConfig = Resources.Load<DispatcherSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "DispatcherSoundListConfig")); DispatcherSoundListConfig = Resources.Load<DispatcherSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "DispatcherSoundListConfig"));
EnemiesSoundListConfig = Resources.Load<EnemiesSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "EnemiesSoundListConfig")); EnemiesSoundListConfig = Resources.Load<EnemiesSoundListConfig>(string.Format(StringPaths.ConfigSingle, "Audio", "EnemiesSoundListConfig"));
AudioSourceSettingsConfigs = Resources AudioSourceSettingsConfigs = Resources
@@ -0,0 +1,25 @@
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
namespace Code.UI.Panels
{
public class DamagePanel : UIElement
{
[SerializeField] private Image background;
[SerializeField] private Color shownColor;
[SerializeField] private Color hiddenColor;
public override void Hide()
{
Shown = false;
// background.enabled = false;
background.DOColor(hiddenColor, 2f);
}
public override void Show()
{
Shown = true;
// background.enabled = true;
background.DOColor(shownColor, 0.3f);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b586dbc292c44261892460f578a38e50
timeCreated: 1764769541
@@ -1,3 +1,4 @@
using DG.Tweening;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@@ -9,21 +10,27 @@ namespace Code.UI
[SerializeField] private TMP_Text scoreText; [SerializeField] private TMP_Text scoreText;
[SerializeField] private TMP_Text gameOverText; [SerializeField] private TMP_Text gameOverText;
[SerializeField] private Image _background; [SerializeField] private Image _background;
[SerializeField] private Color shownColor;
[SerializeField] private Color hiddenColor;
public void UpdateScoreText(int score) => scoreText.text = score.ToString(); public void UpdateScoreText(int score) => scoreText.text = score.ToString();
public override void Hide() public override void Hide()
{ {
_background.enabled = false; _background.enabled = false;
scoreText.enabled = false; // scoreText.enabled = true;
gameOverText.enabled = false; // gameOverText.enabled = false;
scoreText.DOColor(hiddenColor, 3f);
// gameOverText.DOColor(hiddenColor, 3f);
base.Hide(); base.Hide();
} }
public override void Show() public override void Show()
{ {
_background.enabled = true; // _background.enabled = true;
scoreText.enabled = true; // scoreText.enabled = true;
gameOverText.enabled = true; // gameOverText.enabled = true;
scoreText.DOColor(shownColor, 5f);
// gameOverText.DOColor(shownColor, 5f);
base.Show(); base.Show();
} }
} }
@@ -26,6 +26,9 @@ namespace Code.UI.Panels
[Header("MoneyBar")] [Header("MoneyBar")]
[SerializeField] private TMP_Text moneyText; [SerializeField] private TMP_Text moneyText;
[SerializeField] private DamagePanel damagePanel;
public DamagePanel DamagePanel => damagePanel;
private void ScoreUpdate(int count, int money) private void ScoreUpdate(int count, int money)
{ {
// TODO Анимация получения\потери // TODO Анимация получения\потери
@@ -7,21 +7,24 @@ namespace Code.UI.Panels
public class LoadingScreen : UIElement public class LoadingScreen : UIElement
{ {
[SerializeField] private Image background; [SerializeField] private Image background;
[SerializeField] private TMP_Text loadingTitle; [SerializeField] private Image loadingImage;
[SerializeField] private TMP_Text vyapWatermark; // [SerializeField] private TMP_Text loadingTitle;
// [SerializeField] private TMP_Text vyapWatermark;
public override void Hide() public override void Hide()
{ {
Shown = false; Shown = false;
background.enabled = false; background.enabled = false;
loadingTitle.enabled = false; loadingImage.enabled = false;
vyapWatermark.enabled = false; // loadingTitle.enabled = false;
// vyapWatermark.enabled = false;
} }
public override void Show() public override void Show()
{ {
Shown = true; Shown = true;
background.enabled = true; background.enabled = true;
loadingTitle.enabled = true; loadingImage.enabled = true;
vyapWatermark.enabled = true; // loadingTitle.enabled = true;
// vyapWatermark.enabled = true;
} }
} }
} }
@@ -14,6 +14,7 @@ namespace Code.UI
[SerializeField] private Slider master; [SerializeField] private Slider master;
[SerializeField] private Slider sfx; [SerializeField] private Slider sfx;
[SerializeField] private Slider dispatcher; [SerializeField] private Slider dispatcher;
[SerializeField] private Slider courier;
[SerializeField] private Slider creatures; [SerializeField] private Slider creatures;
[SerializeField] private Slider menuMusic; [SerializeField] private Slider menuMusic;
[SerializeField] private Slider gameplayMusic; [SerializeField] private Slider gameplayMusic;
@@ -28,16 +29,19 @@ namespace Code.UI
sfx.value = _audioService.GetSetting(AudioType.SFX); sfx.value = _audioService.GetSetting(AudioType.SFX);
sfx.onValueChanged.AddListener(OnSFXUpdate); sfx.onValueChanged.AddListener(OnSFXUpdate);
dispatcher.value = _audioService.GetSetting(AudioType.DispatcherSounds); dispatcher.value = _audioService.GetSetting(AudioType.Dispatcher);
dispatcher.onValueChanged.AddListener(OnDispatcherUpdate); dispatcher.onValueChanged.AddListener(OnDispatcherUpdate);
creatures.value = _audioService.GetSetting(AudioType.Creatures); courier.value = _audioService.GetSetting(AudioType.Courier);
courier.onValueChanged.AddListener(OnCourierUpdate);
creatures.value = _audioService.GetSetting(AudioType.Enemies);
creatures.onValueChanged.AddListener(OnEnemiesUpdate); creatures.onValueChanged.AddListener(OnEnemiesUpdate);
menuMusic.value = _audioService.GetSetting(AudioType.MenuMusic); menuMusic.value = _audioService.GetSetting(AudioType.MenuMusic);
menuMusic.onValueChanged.AddListener(OnMenuMusicUpdate); menuMusic.onValueChanged.AddListener(OnMenuMusicUpdate);
gameplayMusic.value = _audioService.GetSetting(AudioType.GameplayMusic); gameplayMusic.value = _audioService.GetSetting(AudioType.ActionMusic);
gameplayMusic.onValueChanged.AddListener(OnGameplayUpdate); gameplayMusic.onValueChanged.AddListener(OnGameplayUpdate);
} }
@@ -51,25 +55,32 @@ namespace Code.UI
_audioService.ChangeSetting(AudioType.SFX, value); _audioService.ChangeSetting(AudioType.SFX, value);
_audioService.PlayTestClip(AudioType.SFX); _audioService.PlayTestClip(AudioType.SFX);
} }
private void OnCourierUpdate(float value)
{
_audioService.ChangeSetting(AudioType.Courier, value);
_audioService.PlayTestClip(AudioType.Courier);
}
private void OnDispatcherUpdate(float value) private void OnDispatcherUpdate(float value)
{ {
_audioService.ChangeSetting(AudioType.DispatcherSounds, value); _audioService.ChangeSetting(AudioType.Dispatcher, value);
_audioService.PlayTestClip(AudioType.DispatcherSounds); _audioService.PlayTestClip(AudioType.Dispatcher);
} }
private void OnEnemiesUpdate(float value) private void OnEnemiesUpdate(float value)
{ {
_audioService.ChangeSetting(AudioType.Creatures, value); _audioService.ChangeSetting(AudioType.Enemies, value);
_audioService.PlayTestClip(AudioType.Creatures); _audioService.PlayTestClip(AudioType.Enemies);
} }
private void OnMenuMusicUpdate(float value) private void OnMenuMusicUpdate(float value)
{ {
_audioService.ChangeSetting(AudioType.MenuMusic, value); _audioService.ChangeSetting(AudioType.MenuMusic, value);
_audioService.ChangeSetting(AudioType.DeathMusic, value);
_audioService.PlayTestClip(AudioType.MenuMusic); _audioService.PlayTestClip(AudioType.MenuMusic);
} }
private void OnGameplayUpdate(float value) private void OnGameplayUpdate(float value)
{ {
_audioService.ChangeSetting(AudioType.GameplayMusic, value); _audioService.ChangeSetting(AudioType.ActionMusic, value);
_audioService.PlayTestClip(AudioType.GameplayMusic); _audioService.ChangeSetting(AudioType.PeacefulMusic, value);
_audioService.PlayTestClip(AudioType.ActionMusic);
} }
public override void Hide() public override void Hide()
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45b4aa0e7c33e934493bb7d2a15a9add
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 767316a9a37abc34694c3086d846f668
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 43bd94852ddc6b34dbe9fec318fb54d8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
{
"name": "AYellowpaper.SerializedCollections.Editor",
"references": [
"GUID:d525ad6bd40672747bde77962f1c401e"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
@@ -0,0 +1,14 @@
fileFormatVersion: 2
guid: 234340c04eed5674a988bc6ebde7d248
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/AYellowpaper.SerializedCollections.Editor.asmdef
uploadId: 632226
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: edb739dfb1824234681f6480c75cd523
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,177 @@
fileFormatVersion: 2
guid: 8deddfed9f39d7740879d2cb0fcf7ce0
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 1
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 0
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 2
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: WebGL
maxTextureSize: 8192
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Assets/BurgerMenu@2x.png
uploadId: 632226
@@ -0,0 +1,110 @@
.sc-close-button {
background-image: resource('d_winbtn_win_close@2x');
width: 16px;
height: 16px;
position: absolute;
right: 2px;
top: 2px;
background-color: rgba(0, 0, 0, 0);
border-left-width: 0;
border-right-width: 0;
border-top-width: 0;
border-bottom-width: 0;
}
.sc-close-button:hover {
background-color: rgba(80, 80, 80, 255);
}
.sc-close-button:active {
background-color: rgba(0, 0, 0, 0);
}
.sc-text-toggle {
margin: 0;
padding: 0;
justify-content: center;
}
.sc-text-toggle:checked {
-unity-font-style: bold;
}
.sc-text-toggle > Label {
min-width: auto;
width: 100%;
height: 100%;
}
.sc-text-toggle > .unity-radio-button__input {
display: none;
}
.sc-title {
background-color: rgba(40, 40, 40, 0.35);
padding-left: 4px;
padding-right: 3px;
padding-top: 3px;
padding-bottom: 3px;
border-left-color: rgb(25, 25, 25);
border-right-color: rgb(25, 25, 25);
border-top-color: rgb(25, 25, 25);
border-bottom-color: rgb(25, 25, 25);
border-bottom-width: 1px;
-unity-font-style: bold;
}
.sc-generator-toggle {
padding-left: 3px;
padding-right: 3px;
padding-top: 3px;
padding-bottom: 3px;
}
.sc-generator-toggle:hover {
background-color: rgb(48, 48, 48);
}
.sc-generator-toggle:checked {
background-color: rgb(77, 77, 77);
}
.sc-modification-toggle {
flex-basis: 100%;
flex-shrink: 1;
border-left-color: rgb(41, 41, 41);
border-right-color: rgb(41, 41, 41);
border-top-color: rgb(41, 41, 41);
border-bottom-color: rgb(41, 41, 41);
border-left-width: 1px;
border-right-width: 1px;
border-top-width: 1px;
border-bottom-width: 1px;
-unity-font-style: normal;
-unity-text-align: middle-center;
padding-left: 2px;
padding-right: 2px;
padding-top: 2px;
padding-bottom: 2px;
}
.sc-modification-toggle:hover {
background-color: rgb(70, 70, 70);
}
.sc-modification-toggle:checked {
background-color: rgb(80, 80, 80);
}
.sc-radio-button-group {
padding: 0;
margin: 0;
}
.sc-radio-button-group > Label {
display: none;
}
#generators-group {
flex-direction: column;
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: df6c2ef835e40c94c976442569324029
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Assets/KeysGeneratorSelectorWindow.uss
uploadId: 632226
@@ -0,0 +1,26 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Assets/Plugins/SerializedCollections/Editor/Assets/KeysGeneratorSelectorWindow.uss?fileID=7433441132597879392&amp;guid=df6c2ef835e40c94c976442569324029&amp;type=3#KeysGeneratorSelectorWindow" />
<ui:VisualElement style="flex-direction: row; flex-grow: 1; border-left-color: rgb(97, 97, 97); border-right-color: rgb(97, 97, 97); border-top-color: rgb(97, 97, 97); border-bottom-color: rgb(97, 97, 97); border-left-width: 2px; border-right-width: 2px; border-top-width: 2px; border-bottom-width: 2px;">
<ui:VisualElement name="LeftContent" style="flex-basis: 66%; border-left-color: rgb(25, 25, 25); border-right-color: rgb(25, 25, 25); border-top-color: rgb(25, 25, 25); border-bottom-color: rgb(25, 25, 25); border-right-width: 1px;">
<ui:Label text="Generators" display-tooltip-when-elided="true" class="sc-title" />
<ui:ScrollView scroll-deceleration-rate="0,135" elasticity="0,1" name="generators-content" style="flex-grow: 1;" />
</ui:VisualElement>
<ui:VisualElement name="RightContent" style="flex-basis: 100%;">
<ui:Label text="Inspector" display-tooltip-when-elided="true" class="sc-title" />
<ui:IMGUIContainer name="imgui-inspector" style="flex-grow: 1; margin-left: 4px; margin-right: 4px; margin-top: 4px; margin-bottom: 4px;" />
<ui:Label text="4 Elements " display-tooltip-when-elided="true" name="generated-count-label" style="padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;" />
<ui:VisualElement style="flex-direction: row;">
<ui:RadioButtonGroup label="Radio Button Group" value="-1" name="modification-group" class="sc-radio-button-group" style="flex-grow: 1;">
<ui:RadioButton label="Add" name="add-modification" tooltip="Add the generated missing keys to the target." class="sc-text-toggle sc-modification-toggle" />
<ui:RadioButton label="Remove" name="remove-modification" tooltip="Remove the generated keys form the target." class="sc-text-toggle sc-modification-toggle" />
<ui:RadioButton label="Confine" name="confine-modification" tooltip="Remove all keys that are not part of the generated keys from the target." class="sc-text-toggle sc-modification-toggle" />
</ui:RadioButtonGroup>
</ui:VisualElement>
<ui:VisualElement style="flex-direction: row;">
<ui:Label display-tooltip-when-elided="true" name="result-label" style="flex-grow: 1; -unity-text-align: middle-left; padding-left: 2px; padding-right: 2px; padding-top: 2px; padding-bottom: 2px;" />
<ui:Button text="Apply" display-tooltip-when-elided="true" name="apply-button" style="width: 100px;" />
</ui:VisualElement>
</ui:VisualElement>
<ui:Button display-tooltip-when-elided="true" class="sc-close-button" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,17 @@
fileFormatVersion: 2
guid: 681c8a924c8b1e14b9fe53bb7397ec3d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Assets/KeysGeneratorSelectorWindow.uxml
uploadId: 632226
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6398825db0c1d5348b5ec85b0c12d9c0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 81bf46994f9232b4e8dcf467c109f046
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,23 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.Editor.Data
{
[System.Serializable]
internal class ElementData
{
[SerializeField]
private bool _isListToggleActive = false;
public ElementSettings Settings { get; }
public bool ShowAsList => Settings.HasListDrawerToggle && IsListToggleActive;
public bool IsListToggleActive { get => _isListToggleActive; set => _isListToggleActive = value; }
public DisplayType EffectiveDisplayType => ShowAsList ? DisplayType.List : Settings.DisplayType;
public ElementData(ElementSettings elementSettings)
{
Settings = elementSettings;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 650a80186cc93b54aa5627197c23ea6e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Data/ElementData.cs
uploadId: 632226
@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.Editor.Data
{
public class ElementSettings
{
public const string DefaultName = "Not Set";
public string DisplayName { get; set; } = DefaultName;
public DisplayType DisplayType { get; set; } = DisplayType.PropertyNoLabel;
public bool HasListDrawerToggle { get; set; } = false;
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 12edfc8006691b7498459540b832c5eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Data/ElementSettings.cs
uploadId: 632226
@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.Editor.Data
{
[System.Serializable]
internal class PropertyData
{
[SerializeField]
private float _keyLabelWidth;
[SerializeField]
private ElementData _keyData;
[SerializeField]
private ElementData _valueData;
[SerializeField]
private bool _alwaysShowSearch = false;
public bool AlwaysShowSearch
{
get => _alwaysShowSearch;
set => _alwaysShowSearch = value;
}
public float KeyLabelWidth
{
get => _keyLabelWidth;
set => _keyLabelWidth = value;
}
public ElementData GetElementData(bool fieldType)
{
return fieldType == SCEditorUtility.KeyFlag ? _keyData : _valueData;
}
public PropertyData() : this(new ElementSettings(), new ElementSettings()) { }
public PropertyData(ElementSettings keySettings, ElementSettings valueSettings)
{
_keyData = new ElementData(keySettings);
_valueData = new ElementData(valueSettings);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: ba2d792dfc6653e46bee7c027202acd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/Data/PropertyData.cs
uploadId: 632226
@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.Editor
{
public enum DisplayType
{
Property,
PropertyNoLabel,
List
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 37ee13dd67b545846b6b063923812943
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/DisplayType.cs
uploadId: 632226
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d74b279cd03ebfb4ca7d2606f3f4f11e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 10b0c99dadaea0e42b49e323700f2eb9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,15 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
[KeyListGenerator("Populate Enum", typeof(System.Enum), false)]
public class EnumGenerator : KeyListGenerator
{
public override IEnumerable GetKeys(System.Type type)
{
return System.Enum.GetValues(type);
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: d639de5d36bbeea4496c97cc3f1f4e81
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/Implementors/EnumGenerator.cs
uploadId: 632226
@@ -0,0 +1,24 @@
using System;
using System.Collections;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
[KeyListGenerator("Int Range", typeof(int))]
public class IntRangeGenerator : KeyListGenerator
{
[SerializeField]
private int _startValue = 1;
[SerializeField]
private int _endValue = 10;
public override IEnumerable GetKeys(Type type)
{
int dir = Math.Sign(_endValue - _startValue);
dir = dir == 0 ? 1 : dir;
for (int i = _startValue; i != _endValue; i += dir)
yield return i;
yield return _endValue;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a4203f3a582fa874fb035633bd9892b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/Implementors/IntRangeGenerator.cs
uploadId: 632226
@@ -0,0 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
[KeyListGenerator("Int Stepping", typeof(int))]
public class IntSteppingGenerator : KeyListGenerator
{
[SerializeField]
private int _startIndex = 0;
[SerializeField]
private int _stepDistance = 10;
[SerializeField, Min(0)]
private int _stepCount = 1;
public override IEnumerable GetKeys(Type type)
{
for (int i = 0; i <= _stepCount; i++)
{
yield return _startIndex + i * _stepDistance;
}
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 99302d4ff0ae27b4898ced57890ed32d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/Implementors/IntSteppingGenerator.cs
uploadId: 632226
@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
public abstract class KeyListGenerator : ScriptableObject
{
public abstract IEnumerable GetKeys(System.Type type);
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 08149f25a1b9c5e48a224a7c4d31a154
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/KeyListGenerator.cs
uploadId: 632226
@@ -0,0 +1,19 @@
using System;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
[AttributeUsage(AttributeTargets.Class)]
public class KeyListGeneratorAttribute : Attribute
{
public readonly string Name;
public readonly Type TargetType;
public readonly bool NeedsWindow;
public KeyListGeneratorAttribute(string name, Type targetType, bool needsWindow = true)
{
Name = name;
TargetType = targetType;
NeedsWindow = needsWindow;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 0f6065c936425ab478ecc8a8cf30d38f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/KeyListGeneratorAttribute.cs
uploadId: 632226
@@ -0,0 +1,36 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEngine;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
public static class KeyListGeneratorCache
{
private static List<KeyListGeneratorData> _populators;
private static Dictionary<Type, List<KeyListGeneratorData>> _populatorsByType;
static KeyListGeneratorCache()
{
_populators = new List<KeyListGeneratorData>();
_populatorsByType = new Dictionary<Type, List<KeyListGeneratorData>>();
var populatorTypes = TypeCache.GetTypesDerivedFrom<KeyListGenerator>();
foreach (var populatorType in populatorTypes.Where(x => !x.IsAbstract))
{
var attributes = populatorType.GetCustomAttributes<KeyListGeneratorAttribute>();
foreach (var attribute in attributes)
_populators.Add(new KeyListGeneratorData(attribute.Name, attribute.TargetType, populatorType, attribute.NeedsWindow));
}
}
public static IReadOnlyList<KeyListGeneratorData> GetPopulatorsForType(Type type)
{
if (!_populatorsByType.ContainsKey(type))
_populatorsByType.Add(type, new List<KeyListGeneratorData>(_populators.Where(x => x.TargetType.IsAssignableFrom(type))));
return _populatorsByType[type];
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 7936217ae19613d4bb5e46e73a4a587c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/KeyListGeneratorCache.cs
uploadId: 632226
@@ -0,0 +1,20 @@
using System;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
public class KeyListGeneratorData
{
public string Name { get; set; }
public Type TargetType { get; set; }
public Type GeneratorType { get; set; }
public bool NeedsWindow { get; set; }
public KeyListGeneratorData(string name, Type targetType, Type populatorType, bool needsWindow)
{
Name = name;
TargetType = targetType;
GeneratorType = populatorType;
NeedsWindow = needsWindow;
}
}
}
@@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 8992145ced672cd46a425fb2590b80bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 243052
packageName: Serialized Dictionary
packageVersion: 1.0.13
assetPath: Assets/Plugins/SerializedCollections/Editor/Scripts/KeyListGenerators/KeyListGeneratorData.cs
uploadId: 632226
@@ -0,0 +1,26 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace AYellowpaper.SerializedCollections.KeysGenerators
{
[CustomEditor(typeof(KeyListGenerator), true)]
public class KeyListGeneratorEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
{
var iterator = serializedObject.GetIterator();
if (iterator.Next(true))
{
// skip script name
iterator.NextVisible(true);
while (iterator.NextVisible(true))
{
EditorGUILayout.PropertyField(iterator);
}
}
serializedObject.ApplyModifiedProperties();
}
}
}
Loaded 100 of 359 files, more files were not shown because too many files have changed in this diff. Show more