Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
855108d88b | ||
|
|
388773129d | ||
|
|
5da64a7b3d | ||
|
|
c4ab11488b | ||
|
|
cb968d782b | ||
|
|
522f51be3f | ||
|
|
d3fbd4c5c3 | ||
|
|
5b09068b0c | ||
|
|
ddb76a5b93 | ||
|
|
0f708ff4cb | ||
|
|
721d5ebf9c | ||
|
|
3bb99aaf1e | ||
|
|
a2acea39dc | ||
|
|
5c1fd1510d | ||
|
|
e128ee59f9 | ||
|
|
5c81bde5db | ||
|
|
05449642d5 | ||
|
|
3020140360 | ||
|
|
e67fea2051 | ||
|
|
d1aad440f5 | ||
|
|
0e1c274677 | ||
|
|
346dc97fef | ||
|
|
557c4c3dee | ||
|
|
dbabd847c1 | ||
|
|
874280741c | ||
|
|
b13cf8cfc0 | ||
|
|
177464cc09 | ||
|
|
f8448ba922 | ||
|
|
0f8a629e4b | ||
|
|
0e188efe59 |
No files matched your search
@@ -13,4 +13,5 @@ MonoBehaviour:
|
|||||||
m_Name: AddressableAssetGroupSortSettings
|
m_Name: AddressableAssetGroupSortSettings
|
||||||
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.AddressableAssetGroupSortSettings
|
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.GroupSchemas.AddressableAssetGroupSortSettings
|
||||||
sortOrder:
|
sortOrder:
|
||||||
|
- 7e9d70e73e500eb9287683466ebf646f
|
||||||
- d447fc60305c17a17bf20948ab295a45
|
- d447fc60305c17a17bf20948ab295a45
|
||||||
@@ -15,7 +15,7 @@ MonoBehaviour:
|
|||||||
m_DefaultGroup: d447fc60305c17a17bf20948ab295a45
|
m_DefaultGroup: d447fc60305c17a17bf20948ab295a45
|
||||||
m_currentHash:
|
m_currentHash:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
Hash: 90c715b85c1e0904b3dc61a9ed460206
|
Hash: db97f0adbdaa5d76ea9341571ea44391
|
||||||
m_OptimizeCatalogSize: 0
|
m_OptimizeCatalogSize: 0
|
||||||
m_BuildRemoteCatalog: 0
|
m_BuildRemoteCatalog: 0
|
||||||
m_CatalogRequestsTimeout: 0
|
m_CatalogRequestsTimeout: 0
|
||||||
@@ -60,6 +60,7 @@ MonoBehaviour:
|
|||||||
m_BuildAddressablesWithPlayerBuild: 0
|
m_BuildAddressablesWithPlayerBuild: 0
|
||||||
m_overridePlayerVersion: '[UnityEditor.PlayerSettings.bundleVersion]'
|
m_overridePlayerVersion: '[UnityEditor.PlayerSettings.bundleVersion]'
|
||||||
m_GroupAssets:
|
m_GroupAssets:
|
||||||
|
- {fileID: 11400000, guid: ba51c0b85beab267d8f41a72df4fb657, type: 2}
|
||||||
- {fileID: 11400000, guid: 7c592a6445170e8379910601b962cb30, type: 2}
|
- {fileID: 11400000, guid: 7c592a6445170e8379910601b962cb30, type: 2}
|
||||||
m_BuildSettings:
|
m_BuildSettings:
|
||||||
m_LogResourceManagerExceptions: 1
|
m_LogResourceManagerExceptions: 1
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: bbb281ee3bf0b054c82ac2347e9e782c, type: 3}
|
||||||
|
m_Name: Audio
|
||||||
|
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.AddressableAssetGroup
|
||||||
|
m_GroupName: Audio
|
||||||
|
m_GUID: 7e9d70e73e500eb9287683466ebf646f
|
||||||
|
m_SerializeEntries: []
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_Settings: {fileID: 11400000, guid: 2588e84eb64800d0781c574a37fa48d8, type: 2}
|
||||||
|
m_SchemaSet:
|
||||||
|
m_Schemas: []
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ba51c0b85beab267d8f41a72df4fb657
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -15,16 +15,136 @@ MonoBehaviour:
|
|||||||
m_GroupName: Default Local Group
|
m_GroupName: Default Local Group
|
||||||
m_GUID: d447fc60305c17a17bf20948ab295a45
|
m_GUID: d447fc60305c17a17bf20948ab295a45
|
||||||
m_SerializeEntries:
|
m_SerializeEntries:
|
||||||
|
- m_GUID: 03e51c504fa7e0624ba855ec35b60bcc
|
||||||
|
m_Address: absolutely
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 111011400ce13ae859c52c757aef859e
|
||||||
|
m_Address: ahfreeman
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 144ab5188f8ad7a0a92c75703bd12e60
|
||||||
|
m_Address: launch_upmenu1
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 1d4767c722c05b5d6b96bb226d378c65
|
||||||
|
m_Address: Assets/Resources_moved/Prefabs/Player/ArmsMesh.prefab
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 1d7110a045075b22fa27d62bd5f2784e
|
||||||
|
m_Address: 357_shot1
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 1f79c7b1e492a4ea2a8d666cdead0c52
|
||||||
|
m_Address: Audio/Dispatcher/take_damage4
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 2301400160a23924eb27c4bdbe797739
|
||||||
|
m_Address: 'Audio/Music/Nightmargin (Oneshot OST) - The Prophecy '
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
- m_GUID: 23e11d2c8a4f12f4ea9a7a43d1118464
|
- m_GUID: 23e11d2c8a4f12f4ea9a7a43d1118464
|
||||||
m_Address: Gameplay
|
m_Address: Gameplay
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
m_SerializedLabels: []
|
m_SerializedLabels: []
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 29bff8011973e4e519906b9da8fca0fc
|
||||||
|
m_Address: Audio/Dispatcher/late3
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 29ee630aab7bbef8799dc76ed0c239f7
|
||||||
|
m_Address: Audio/Dispatcher/late4
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 2f6134357dc2a5641a846a7478ce4c2c
|
||||||
|
m_Address: bravo!
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 31f16c866d3224ab8a7e0fabf3745ec5
|
||||||
|
m_Address: Audio/Dispatcher/late5
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 3831a36e0c8e48f659517a6bb99378b6
|
||||||
|
m_Address: cbar_hit1
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
- m_GUID: 48aebfe8826dc0df79d047b5afbf8f5b
|
- m_GUID: 48aebfe8826dc0df79d047b5afbf8f5b
|
||||||
m_Address: Canvas
|
m_Address: Canvas
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
m_SerializedLabels: []
|
m_SerializedLabels: []
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 4bd64d1fcecc9c6b09d81e78b7dcfebe
|
||||||
|
m_Address: Audio/Dispatcher/take_damage1
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 735f38402ea347fa381408293503a24e
|
||||||
|
m_Address: Audio/Dispatcher/receiving_an_order1
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 751890caa1647ec6689f24933fbcb770
|
||||||
|
m_Address: "Prefabs/Furniture/\u0442\u0440\u0443\u0431\u0430"
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 7c5caf3ceee44f71588860c5c1fbdbe0
|
||||||
|
m_Address: Audio/Dispatcher/take_damage3
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 803e40b883c823b89a91aa8b9d9fc483
|
||||||
|
m_Address: valve_sound
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 81844a99f5b786b41b831174f8fb6d3a
|
||||||
|
m_Address: Prefabs/Player/CharacterController
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 82c71411174bfa86ca1f676b9d389f94
|
||||||
|
m_Address: bastard!
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 8c2be26d359d54063825fedfad7a493b
|
||||||
|
m_Address: Audio/Dispatcher/late2
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 8fa89a492fc3a3768a0f0ba1bb7080e0
|
||||||
|
m_Address: Audio/Dispatcher/late1
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: 9293380a88bf6736889be29722b94269
|
||||||
|
m_Address: Audio/AudioSource
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: a306df57f348ce7cf900d0b9431739ee
|
||||||
|
m_Address: launch_selectmenu
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: b2c9f83c47783069aabb564f68cb0cbb
|
||||||
|
m_Address: absolutelynot
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
- m_GUID: b2e8dc2aeb0311cd8a826b51cf8e94dc
|
- m_GUID: b2e8dc2aeb0311cd8a826b51cf8e94dc
|
||||||
m_Address: GameOver
|
m_Address: GameOver
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
@@ -35,11 +155,31 @@ MonoBehaviour:
|
|||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
m_SerializedLabels: []
|
m_SerializedLabels: []
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: cab4b1ff78dd6b1fba61aa165aa17b4d
|
||||||
|
m_Address: Audio/Dispatcher/receiving_an_order2
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: ebe18293a5ef86704b23dad3a1786476
|
||||||
|
m_Address: Half-Life01
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
- m_GUID: f23b9fce9594618e5b75845f1cae50de
|
- m_GUID: f23b9fce9594618e5b75845f1cae50de
|
||||||
m_Address: LoadingScreen
|
m_Address: LoadingScreen
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
m_SerializedLabels: []
|
m_SerializedLabels: []
|
||||||
FlaggedDuringContentUpdateRestriction: 0
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: f4b6fa54ecac6cc418f98824491aa17a
|
||||||
|
m_Address: Audio/Music/SANABI - JUSTICE Is Watching You
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
|
- m_GUID: f74a409bf11b25148ad305acc05b14f5
|
||||||
|
m_Address: Audio/Dispatcher/take_damage2
|
||||||
|
m_ReadOnly: 0
|
||||||
|
m_SerializedLabels: []
|
||||||
|
FlaggedDuringContentUpdateRestriction: 0
|
||||||
m_ReadOnly: 0
|
m_ReadOnly: 0
|
||||||
m_Settings: {fileID: 11400000, guid: 2588e84eb64800d0781c574a37fa48d8, type: 2}
|
m_Settings: {fileID: 11400000, guid: 2588e84eb64800d0781c574a37fa48d8, type: 2}
|
||||||
m_SchemaSet:
|
m_SchemaSet:
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 7e3976da977cb49238499ea3b4c237ae, type: 3}
|
||||||
|
m_Name: ProfileDataSourceSettings
|
||||||
|
m_EditorClassIdentifier: Unity.Addressables.Editor::UnityEditor.AddressableAssets.Settings.ProfileDataSourceSettings
|
||||||
|
profileGroupTypes:
|
||||||
|
- m_GroupTypePrefix: Built-In
|
||||||
|
m_Variables:
|
||||||
|
- m_Suffix: BuildPath
|
||||||
|
m_Value: '[UnityEngine.AddressableAssets.Addressables.BuildPath]/[BuildTarget]'
|
||||||
|
- m_Suffix: LoadPath
|
||||||
|
m_Value: '{UnityEngine.AddressableAssets.Addressables.RuntimePath}/[BuildTarget]'
|
||||||
|
environments: []
|
||||||
|
currentEnvironment:
|
||||||
|
id:
|
||||||
|
projectId:
|
||||||
|
projectGenesisId:
|
||||||
|
name:
|
||||||
|
isDefault: 0
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7e2b0e48c9649284a9541c4d1dad59c2
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,20 +1,39 @@
|
|||||||
|
using System.Globalization;
|
||||||
|
using System.Reflection.Emit;
|
||||||
using Code.App.StateMachine;
|
using Code.App.StateMachine;
|
||||||
|
using Code.Audio;
|
||||||
using Code.Gameplay.Camera;
|
using Code.Gameplay.Camera;
|
||||||
|
using Code.Gameplay.Camera.CameraStates;
|
||||||
|
using Code.Gameplay.Character.Core;
|
||||||
|
using Code.Gameplay.Orders.Order;
|
||||||
|
using Code.Gameplay.Orders.Order;
|
||||||
using Code.Gameplay.Player;
|
using Code.Gameplay.Player;
|
||||||
using Code.Input;
|
using Code.Input;
|
||||||
using Code.Scenes;
|
using Code.Scenes;
|
||||||
|
using Code.Scenes.SceneEnvironments;
|
||||||
using Code.StateMachine;
|
using Code.StateMachine;
|
||||||
using Code.UI;
|
using Code.UI;
|
||||||
|
using Code.UI.Panels;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using Reflex.Core;
|
||||||
|
using Reflex.Extensions;
|
||||||
|
using Reflex.Injectors;
|
||||||
|
using UnityEngine;
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace Code.App.AppStates
|
namespace Code.App.AppStates
|
||||||
{
|
{
|
||||||
public class GameplayState : BaseState<AppStateMachineContext>
|
public class GameplayState : BaseState<AppStateMachineContext>
|
||||||
{
|
{
|
||||||
|
|
||||||
private PlayerHealth _playerHealth;
|
private PlayerHealth _playerHealth;
|
||||||
private PlayerMoney _playerMoney;
|
private PlayerMoney _playerMoney;
|
||||||
|
|
||||||
private bool _uiLoaded, _sceneLoaded;
|
private IScoreService _scoreService;
|
||||||
|
private IOrderService _orderService;
|
||||||
|
|
||||||
|
private CharacterProvider _playerCharacter;
|
||||||
|
|
||||||
public GameplayState(AppStateMachineContext context) : base(context)
|
public GameplayState(AppStateMachineContext context) : base(context)
|
||||||
{
|
{
|
||||||
@@ -22,8 +41,6 @@ namespace Code.App.AppStates
|
|||||||
|
|
||||||
public override void EnterState()
|
public override void EnterState()
|
||||||
{
|
{
|
||||||
_uiLoaded = _sceneLoaded = false;
|
|
||||||
|
|
||||||
Context.UIService.LoadingScreen.Show();
|
Context.UIService.LoadingScreen.Show();
|
||||||
|
|
||||||
_playerMoney = Context.PlayerFactory.CreatePlayerMoney();
|
_playerMoney = Context.PlayerFactory.CreatePlayerMoney();
|
||||||
@@ -31,65 +48,105 @@ namespace Code.App.AppStates
|
|||||||
|
|
||||||
_playerHealth.OnDeath += EndGame;
|
_playerHealth.OnDeath += EndGame;
|
||||||
|
|
||||||
Context.SceneLoaderService.LoadSceneAsync((int)SceneIds.MovementDev, callBack: OnSceneLoaded); // TODO Фабрика игрока Nada
|
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Peaceful);
|
||||||
|
|
||||||
Context.UIService.SwitchPanelTo(UIPanel.Gameplay, callback: PostUILoaded);
|
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||||
|
|
||||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveHealth, GiveHealth);
|
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, GiveOrderDEBUG);
|
||||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveMoney, GiveMoney);
|
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug2, RecieveOrderDEBUG);
|
||||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseHealth, LooseHealth);
|
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug3, DeliverOrderDEBUG);
|
||||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseMoney, LooseMoney);
|
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
|
||||||
|
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
|
||||||
|
// Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug6, PlayDebugDispatcher);
|
||||||
|
|
||||||
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
|
WaitForSceneToLoad();
|
||||||
|
#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 void OnSceneLoaded()
|
private async UniTaskVoid WaitForSceneToLoad()
|
||||||
{
|
{
|
||||||
_sceneLoaded = true;
|
await Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.Gameplay);
|
||||||
CheckIfLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PostUILoaded()
|
await UniTask.WhenAll(
|
||||||
{
|
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
|
||||||
((GameplayPanel)Context.UIService.CurrentPanel).Initialize(_playerMoney, _playerHealth);
|
// TODO
|
||||||
_uiLoaded = true;
|
Context.AudioFactory.WarmGameplayMusic(),
|
||||||
CheckIfLoaded();
|
Context.AudioFactory.WarmSFX(),
|
||||||
}
|
Context.AudioFactory.WarmDispatcher(),
|
||||||
|
// TODO
|
||||||
|
WaitForPlayerArmsToInitialize(),
|
||||||
|
WaitForPlayerCharacterLoad()
|
||||||
|
);
|
||||||
|
MusicInitialize();
|
||||||
|
|
||||||
private void CheckIfLoaded()
|
Container sceneContainer = SceneManager.GetActiveScene().GetSceneContainer();
|
||||||
{
|
|
||||||
if(!_uiLoaded || !_sceneLoaded) return;
|
GameplaySceneEnvironment sceneEnvironment = SceneEnvironmentVariables(sceneContainer);
|
||||||
|
|
||||||
|
PlayerInitialize(sceneEnvironment);
|
||||||
|
|
||||||
|
UIInitialize();
|
||||||
|
|
||||||
|
CameraInitialize();
|
||||||
|
|
||||||
|
InputServiceInitialize();
|
||||||
|
|
||||||
|
GameplayServicesInitialize(sceneContainer);
|
||||||
|
|
||||||
|
_tickEnabled = true;
|
||||||
|
|
||||||
Context.UIService.LoadingScreen.Hide();
|
Context.UIService.LoadingScreen.Hide();
|
||||||
|
|
||||||
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
|
|
||||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async UniTask WaitForPlayerArmsToInitialize() => _armsMesh = await Context.PlayerFactory.CreateArms(Context.CameraStateMachine.Camera.transform);
|
||||||
|
|
||||||
// Debug
|
private void OrderGiven(float time)
|
||||||
private void GiveHealth(InputAction.CallbackContext context)
|
|
||||||
{
|
{
|
||||||
_playerHealth.GetDamage(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LooseHealth(InputAction.CallbackContext context)
|
}
|
||||||
|
private void OrderRecieved(float time)
|
||||||
{
|
{
|
||||||
_playerHealth.GetDamage(1);
|
Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.Recieve1,(int)DispatcherSounds.Recieve2));
|
||||||
}
|
}
|
||||||
|
private void OrderDelivered(int score, float time)
|
||||||
private void GiveMoney(InputAction.CallbackContext context)
|
|
||||||
{
|
{
|
||||||
_playerMoney.GiveMoney(100);
|
if(time < 0f) Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.Late1,(int)DispatcherSounds.Late2));
|
||||||
((GameplayPanel)(Context.UIService.CurrentPanel)).SummonDispatcher();
|
_playerMoney.GiveMoney(score);
|
||||||
}
|
}
|
||||||
|
// DEBUG
|
||||||
private void LooseMoney(InputAction.CallbackContext context)
|
private void GiveOrderDEBUG(InputAction.CallbackContext context)
|
||||||
{
|
{
|
||||||
_playerMoney.LooseMoney(100);
|
_orderService.OrderGive();
|
||||||
((GameplayPanel)(Context.UIService.CurrentPanel)).CloseDispatcher();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RecieveOrderDEBUG(InputAction.CallbackContext context)
|
||||||
|
{
|
||||||
|
_orderService.OrderRecieved();
|
||||||
|
}
|
||||||
|
private void DeliverOrderDEBUG(InputAction.CallbackContext context)
|
||||||
|
{
|
||||||
|
_orderService.OrderDelivered();
|
||||||
|
}
|
||||||
|
private void RoomPassedDEBUG(InputAction.CallbackContext context)
|
||||||
|
{
|
||||||
|
_orderService.RoomPassed();
|
||||||
|
}
|
||||||
|
private OrderDispenser _debugTube;
|
||||||
|
|
||||||
|
private void Tube(InputAction.CallbackContext context)
|
||||||
|
{
|
||||||
|
_debugTube.ThrowOrder();
|
||||||
|
}
|
||||||
|
// DEBUG
|
||||||
|
private bool _tickEnabled;
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
|
if (!_tickEnabled) return;
|
||||||
|
|
||||||
|
// TODO ГРЯЗь
|
||||||
|
_gameplayPanel.Timer.text = ((int)_orderService.DecreaseTimer(Time.deltaTime)).ToString(CultureInfo.CurrentCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EndGame()
|
private void EndGame()
|
||||||
@@ -103,14 +160,71 @@ namespace Code.App.AppStates
|
|||||||
_playerHealth = null;
|
_playerHealth = null;
|
||||||
_playerMoney = null;
|
_playerMoney = null;
|
||||||
|
|
||||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
_tickEnabled = false;
|
||||||
|
|
||||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.GiveHealth, GiveHealth);
|
Context.PlayerFactory.ReleasePlayer(_playerCharacter);
|
||||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.GiveMoney, GiveHealth);
|
_playerCharacter = null;
|
||||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.LooseHealth, LooseHealth);
|
Context.PlayerFactory.ReleaseArms(_armsMesh);
|
||||||
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.LooseMoney, LooseMoney);
|
_armsMesh = null;
|
||||||
|
|
||||||
|
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||||
|
Context.AudioService.GladlyAskToStopMusic(MusicType.Action, callback: Context.AudioFactory.ReleaseActionMusic);
|
||||||
|
Context.AudioService.GladlyAskToStopMusic(MusicType.Peaceful, callback: Context.AudioFactory.ReleasePeacefulMusic);
|
||||||
|
|
||||||
|
|
||||||
|
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, GiveOrderDEBUG);
|
||||||
|
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug2, RecieveOrderDEBUG);
|
||||||
|
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug3, DeliverOrderDEBUG);
|
||||||
|
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
|
||||||
|
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
|
||||||
|
// Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.Debug6, PlayDebugDispatcher);
|
||||||
|
|
||||||
base.ExitState();
|
base.ExitState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InputServiceInitialize()
|
||||||
|
{
|
||||||
|
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||||
|
}
|
||||||
|
private void CameraInitialize()
|
||||||
|
{
|
||||||
|
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
|
||||||
|
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(_playerCharacter.GetFollowTransform());
|
||||||
|
}
|
||||||
|
|
||||||
|
private GameplayPanel _gameplayPanel;
|
||||||
|
private ArmsMeshProvider _armsMesh;
|
||||||
|
|
||||||
|
private void UIInitialize()
|
||||||
|
{
|
||||||
|
_gameplayPanel = (GameplayPanel)Context.UIService.CurrentPanel;
|
||||||
|
_gameplayPanel.Initialize(_playerMoney, _playerHealth);
|
||||||
|
}
|
||||||
|
private void MusicInitialize()
|
||||||
|
{
|
||||||
|
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Peaceful);
|
||||||
|
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Action);
|
||||||
|
}
|
||||||
|
private void PlayerInitialize(GameplaySceneEnvironment sceneEnvironment)
|
||||||
|
{
|
||||||
|
_playerCharacter.Teleport(sceneEnvironment.playerSpawnPoint.position, sceneEnvironment.playerSpawnPoint.rotation);
|
||||||
|
_playerCharacter.PlayerAnimator.SetAnimator(_armsMesh.ArmsAnimator);
|
||||||
|
}
|
||||||
|
private void GameplayServicesInitialize(Container sceneContainer)
|
||||||
|
{
|
||||||
|
_scoreService = sceneContainer.Resolve<IScoreService>();
|
||||||
|
_orderService = sceneContainer.Resolve<IOrderService>();
|
||||||
|
|
||||||
|
_orderService.OnOrderGiven += OrderGiven;
|
||||||
|
_orderService.OnOrderRecieved += OrderRecieved;
|
||||||
|
_orderService.OnOrderDelivered += OrderDelivered;
|
||||||
|
}
|
||||||
|
private GameplaySceneEnvironment SceneEnvironmentVariables(Container sceneContainer)
|
||||||
|
{
|
||||||
|
var sceneEnvironment = (GameplaySceneEnvironment)sceneContainer.Resolve<CurrentSceneEnvironment>();
|
||||||
|
|
||||||
|
_debugTube = sceneEnvironment.debugTube;
|
||||||
|
return sceneEnvironment;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
using Code.App.StateMachine;
|
using Code.App.StateMachine;
|
||||||
|
using Code.Audio;
|
||||||
using Code.Gameplay.Camera;
|
using Code.Gameplay.Camera;
|
||||||
using Code.Gameplay.Camera.CameraStates;
|
using Code.Gameplay.Camera.CameraStates;
|
||||||
|
using Code.Gameplay.Door;
|
||||||
using Code.Input;
|
using Code.Input;
|
||||||
using Code.Scenes;
|
using Code.Scenes;
|
||||||
using Code.Scenes.SceneEnvironments;
|
using Code.Scenes.SceneEnvironments;
|
||||||
using Code.StateMachine;
|
using Code.StateMachine;
|
||||||
using Code.UI;
|
using Code.UI;
|
||||||
|
using Code.UI.Panels;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
using Reflex.Extensions;
|
using Reflex.Extensions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@@ -14,59 +18,50 @@ namespace Code.App.AppStates
|
|||||||
{
|
{
|
||||||
public class MainMenuState : BaseState<AppStateMachineContext>
|
public class MainMenuState : BaseState<AppStateMachineContext>
|
||||||
{
|
{
|
||||||
private bool _uiLoaded, _sceneLoaded;
|
|
||||||
public MainMenuState(AppStateMachineContext context) : base(context)
|
public MainMenuState(AppStateMachineContext context) : base(context)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void EnterState()
|
public override void EnterState()
|
||||||
{
|
{
|
||||||
_uiLoaded = _sceneLoaded = false;
|
|
||||||
|
|
||||||
Context.UIService.LoadingScreen.Show();
|
Context.UIService.LoadingScreen.Show();
|
||||||
|
|
||||||
Context.SceneLoaderService.LoadSceneAsync((int)SceneIds.MainMenu, callBack: SceneLoaded);
|
Context.CameraStateMachine.SwitchState(CameraMode.UltraStatic);
|
||||||
|
|
||||||
Context.UIService.SwitchPanelTo(UIPanel.MainMenu, PostUILoaded);
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
|
WaitForSceneToLoad();
|
||||||
Context.CameraStateMachine.SwitchState(CameraMode.Static);
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PostUILoaded()
|
private CinematicDoorOpening _damnDoor = new();
|
||||||
|
private async UniTaskVoid WaitForSceneToLoad()
|
||||||
{
|
{
|
||||||
((MainMenuPanel)Context.UIService.CurrentPanel).startButton.onClick.AddListener(StartGame);
|
await UniTask.WhenAll(
|
||||||
((MainMenuPanel)Context.UIService.CurrentPanel).exitButton.onClick.AddListener(ExitGame);
|
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.MainMenu),
|
||||||
|
Context.UIService.AsyncSwitchPanelTo(UIPanel.MainMenu),
|
||||||
|
Context.AudioFactory.WarmMenuMusic()
|
||||||
|
);
|
||||||
|
|
||||||
_uiLoaded = true;
|
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Menu);
|
||||||
|
Context.AudioService.PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType.Menu);
|
||||||
|
|
||||||
CheckIfLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SceneLoaded()
|
|
||||||
{
|
|
||||||
var hui = ((MainMenuEnvironment)SceneManager.GetActiveScene()
|
var hui = ((MainMenuEnvironment)SceneManager.GetActiveScene()
|
||||||
.GetSceneContainer().Resolve<CurrentSceneEnvironment>());
|
.GetSceneContainer().Resolve<CurrentSceneEnvironment>());
|
||||||
|
_damnDoor.DamnDoor = hui.damnDoor;
|
||||||
|
_damnDoor.DamnDoor.SetPhysics(false);
|
||||||
|
_damnDoor.DoorLight = hui.doorLight;
|
||||||
|
|
||||||
((StaticState)Context.CameraStateMachine.CurrentBaseState).LookTarget =
|
var menuPanel = (MainMenuPanel)Context.UIService.CurrentPanel;
|
||||||
hui.cameraTarget;
|
|
||||||
|
|
||||||
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(hui.cameraPosition);
|
menuPanel.startButton.button.onClick.AddListener(StartGame);
|
||||||
|
menuPanel.exitButton.button.onClick.AddListener(ExitGame);
|
||||||
|
menuPanel.CinematicDoorOpening = _damnDoor;
|
||||||
|
|
||||||
|
((UltraStaticState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(hui.cameraPosition);
|
||||||
_sceneLoaded = true;
|
|
||||||
|
|
||||||
CheckIfLoaded();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CheckIfLoaded()
|
|
||||||
{
|
|
||||||
if(!_uiLoaded || !_sceneLoaded) return;
|
|
||||||
|
|
||||||
Context.UIService.LoadingScreen.Hide();
|
Context.UIService.LoadingScreen.Hide();
|
||||||
|
|
||||||
Context.InputService.EnableMap(ActionMappings.MainMenu);
|
Context.InputService.EnableMap(ActionMappings.MainMenu);
|
||||||
|
|
||||||
base.EnterState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Tick()
|
public override void Tick()
|
||||||
@@ -87,6 +82,7 @@ namespace Code.App.AppStates
|
|||||||
public override void ExitState()
|
public override void ExitState()
|
||||||
{
|
{
|
||||||
Context.InputService.DisableMap(ActionMappings.MainMenu);
|
Context.InputService.DisableMap(ActionMappings.MainMenu);
|
||||||
|
Context.AudioService.GladlyAskToStopMusic(MusicType.Menu, callback: Context.AudioFactory.ReleaseMenuMusic);
|
||||||
|
|
||||||
base.ExitState();
|
base.ExitState();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using System.Threading.Tasks;
|
|
||||||
using Code.App.StateMachine;
|
using Code.App.StateMachine;
|
||||||
|
using Code.Audio;
|
||||||
using Code.Configs;
|
using Code.Configs;
|
||||||
using Code.Constants;
|
using Code.Constants;
|
||||||
using Code.Gameplay.Camera;
|
using Code.Gameplay.Camera;
|
||||||
|
using Code.Gameplay.Orders.Order;
|
||||||
using Code.Gameplay.Player;
|
using Code.Gameplay.Player;
|
||||||
using Code.Input;
|
using Code.Input;
|
||||||
using Code.Scenes;
|
using Code.Scenes;
|
||||||
@@ -13,7 +14,6 @@ using Cysharp.Threading.Tasks;
|
|||||||
using Reflex.Core;
|
using Reflex.Core;
|
||||||
using Reflex.Injectors;
|
using Reflex.Injectors;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.AddressableAssets;
|
|
||||||
using UnityEngine.InputSystem;
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
namespace Code.App
|
namespace Code.App
|
||||||
@@ -32,6 +32,10 @@ namespace Code.App
|
|||||||
InitializeCamera(containerBuilder, staticDataService);
|
InitializeCamera(containerBuilder, staticDataService);
|
||||||
containerBuilder.AddSingleton(typeof(UIFactory), typeof(IUIFactory));
|
containerBuilder.AddSingleton(typeof(UIFactory), typeof(IUIFactory));
|
||||||
containerBuilder.AddSingleton(typeof(UIService), typeof(IUIService));
|
containerBuilder.AddSingleton(typeof(UIService), typeof(IUIService));
|
||||||
|
|
||||||
|
containerBuilder.AddSingleton(typeof(AudioFactory), typeof(IAudioFactory));
|
||||||
|
containerBuilder.AddSingleton(typeof(AudioService), typeof(IAudioService));
|
||||||
|
|
||||||
containerBuilder.AddSingleton(typeof(SceneLoaderService), typeof(ISceneLoaderService));
|
containerBuilder.AddSingleton(typeof(SceneLoaderService), typeof(ISceneLoaderService));
|
||||||
|
|
||||||
containerBuilder.OnContainerBuilt += Bootstrap;
|
containerBuilder.OnContainerBuilt += Bootstrap;
|
||||||
@@ -63,18 +67,29 @@ namespace Code.App
|
|||||||
staticDataService.Load();
|
staticDataService.Load();
|
||||||
|
|
||||||
containerBuilder.AddSingleton(staticDataService, typeof(IStaticDataService));
|
containerBuilder.AddSingleton(staticDataService, typeof(IStaticDataService));
|
||||||
|
|
||||||
containerBuilder.AddSingleton(staticDataService.InputConfig.inputActionAsset, typeof(InputActionAsset));
|
containerBuilder.AddSingleton(staticDataService.InputConfig.inputActionAsset, typeof(InputActionAsset));
|
||||||
containerBuilder.AddSingleton(staticDataService.InputConfig, typeof(InputConfig));
|
containerBuilder.AddSingleton(staticDataService.InputConfig, typeof(InputConfig));
|
||||||
|
|
||||||
containerBuilder.AddSingleton(staticDataService.CameraConfig, typeof(CameraConfig));
|
containerBuilder.AddSingleton(staticDataService.CameraConfig, typeof(CameraConfig));
|
||||||
|
|
||||||
containerBuilder.AddSingleton(staticDataService.PlayerConfig, typeof(PlayerConfig));
|
containerBuilder.AddSingleton(staticDataService.PlayerConfig, typeof(PlayerConfig));
|
||||||
containerBuilder.AddSingleton(staticDataService.CharacterConfig, typeof(CharacterConfig));
|
containerBuilder.AddSingleton(staticDataService.CharacterConfig, typeof(CharacterConfig));
|
||||||
|
|
||||||
containerBuilder.AddSingleton(staticDataService.UIConfig, typeof(UIConfig));
|
containerBuilder.AddSingleton(staticDataService.UIConfig, typeof(UIConfig));
|
||||||
// containerBuilder.AddSingleton(staticDataService.UIConfig.canvasPrefab, typeof(Canvas));
|
|
||||||
// containerBuilder.AddSingleton(staticDataService.UIConfig.uiElementsPrefabs, typeof(UIElement[]));
|
containerBuilder.AddSingleton(staticDataService.AudioMixerConfig, typeof(AudioMixerConfig));
|
||||||
|
containerBuilder.AddSingleton(staticDataService.SoundtrackListConfig, typeof(SoundtrackListConfig));
|
||||||
|
containerBuilder.AddSingleton(staticDataService.SFXListConfig, typeof(SFXListConfig));
|
||||||
|
containerBuilder.AddSingleton(staticDataService.DispatcherSoundListConfig, typeof(DispatcherSoundListConfig));
|
||||||
|
containerBuilder.AddSingleton(staticDataService.EnemiesSoundListConfig, typeof(EnemiesSoundListConfig));
|
||||||
|
|
||||||
|
containerBuilder.AddSingleton(staticDataService.OrderServiceConfig, typeof(OrderServiceConfig));
|
||||||
|
containerBuilder.AddSingleton(staticDataService.OrderBoxConfig, typeof(OrderBoxConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _onUiLoaded;
|
|
||||||
private AppStateMachine _appStateMachine;
|
private AppStateMachine _appStateMachine;
|
||||||
|
|
||||||
private void Bootstrap(Container container)
|
private void Bootstrap(Container container)
|
||||||
{
|
{
|
||||||
_appStateMachine = container.Resolve<AppStateMachine>();
|
_appStateMachine = container.Resolve<AppStateMachine>();
|
||||||
@@ -85,19 +100,20 @@ 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);
|
||||||
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
|
}
|
||||||
|
private async UniTaskVoid BootstrapFinish(Container container)
|
||||||
|
{
|
||||||
var loadingScreen = GameObject.FindWithTag(Tags.LoadingScreen);
|
var loadingScreen = GameObject.FindWithTag(Tags.LoadingScreen);
|
||||||
DontDestroyOnLoad(loadingScreen);
|
DontDestroyOnLoad(loadingScreen);
|
||||||
|
|
||||||
IUIService uiService = container.Resolve<IUIService>();
|
await UniTask.WhenAll(
|
||||||
uiService.Initialize(loadingScreen.GetComponent<LoadingScreen>());
|
container.Resolve<IUIService>().Initialize(loadingScreen.GetComponent<LoadingScreen>()),
|
||||||
|
container.Resolve<IAudioService>().Initialize()
|
||||||
|
);
|
||||||
|
|
||||||
TryStartGame();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TryStartGame()
|
|
||||||
{
|
|
||||||
|
|
||||||
// TODO: поменяно для теста
|
|
||||||
_appStateMachine
|
_appStateMachine
|
||||||
.SwitchState(AppState.MainMenu)
|
.SwitchState(AppState.MainMenu)
|
||||||
.AllowStateTransition(AppState.Gameplay);
|
.AllowStateTransition(AppState.Gameplay);
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Code.Gameplay.Orders.Order;
|
||||||
|
using Code.Scenes;
|
||||||
|
using Code.Scenes.SceneEnvironments;
|
||||||
|
using Reflex.Core;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.App.SceneInstallers
|
||||||
|
{
|
||||||
|
public class GameplaySceneInstaller : MonoBehaviour, IInstaller
|
||||||
|
{
|
||||||
|
[SerializeField] private GameplaySceneEnvironment _gameplaySceneEnvironment;
|
||||||
|
|
||||||
|
public void InstallBindings(ContainerBuilder containerBuilder)
|
||||||
|
{
|
||||||
|
containerBuilder.AddScoped(typeof(GameplaySceneEnvironment), typeof(CurrentSceneEnvironment));
|
||||||
|
containerBuilder.AddScoped(typeof(ScoreService), typeof(IScoreService));
|
||||||
|
containerBuilder.AddScoped(typeof(OrderService), typeof(IOrderService));
|
||||||
|
|
||||||
|
containerBuilder.OnContainerBuilt += Initialize;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Initialize(Container container)
|
||||||
|
{
|
||||||
|
GameplaySceneEnvironment env = (GameplaySceneEnvironment)container.Resolve<CurrentSceneEnvironment>();
|
||||||
|
|
||||||
|
env.TransitVariables(_gameplaySceneEnvironment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 88584fd4361b46f6a7326440cd95ce69
|
||||||
|
timeCreated: 1763144580
|
||||||
@@ -2,6 +2,7 @@ using Code.Scenes;
|
|||||||
using Code.Scenes.SceneEnvironments;
|
using Code.Scenes.SceneEnvironments;
|
||||||
using Reflex.Core;
|
using Reflex.Core;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
namespace Code.App.SceneInstallers
|
namespace Code.App.SceneInstallers
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Code.Audio;
|
||||||
using Code.Gameplay.Camera;
|
using Code.Gameplay.Camera;
|
||||||
using Code.Gameplay.Player;
|
using Code.Gameplay.Player;
|
||||||
using Code.Input;
|
using Code.Input;
|
||||||
@@ -15,5 +16,7 @@ namespace Code.App.StateMachine
|
|||||||
[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 IPlayerFactory PlayerFactory { get; private set; }
|
||||||
|
[Inject] public IAudioFactory AudioFactory { get; private set; }
|
||||||
|
[Inject] public IAudioService AudioService { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 9ce1e20f4ee9be6709bf9022546bcb07
|
guid: a1937581573e47844bb593bd62310b89
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public enum SFXSounds
|
||||||
|
{
|
||||||
|
Crowbar,
|
||||||
|
Shot357
|
||||||
|
}
|
||||||
|
public enum UISounds
|
||||||
|
{
|
||||||
|
Crowbar
|
||||||
|
}
|
||||||
|
public enum EnemiesSounds
|
||||||
|
{
|
||||||
|
Bastard,
|
||||||
|
Bravo
|
||||||
|
}
|
||||||
|
public enum DispatcherSounds
|
||||||
|
{
|
||||||
|
Absolutely,
|
||||||
|
AbsolutelyNot,
|
||||||
|
AhFreeman,
|
||||||
|
Recieve1,
|
||||||
|
Recieve2,
|
||||||
|
TakeDamage1,
|
||||||
|
TakeDamage2,
|
||||||
|
TakeDamage3,
|
||||||
|
TakeDamage4,
|
||||||
|
Late1,
|
||||||
|
Late2,
|
||||||
|
Late3,
|
||||||
|
Late4,
|
||||||
|
Late5
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 907b506ceac843ebb509a8e5298af540
|
||||||
|
timeCreated: 1762888870
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Code.Configs;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public class AudioFactory : IAudioFactory
|
||||||
|
{
|
||||||
|
public AudioMixer AudioMixer { get; private set; }
|
||||||
|
private AssetReference _audioSourcePrefab;
|
||||||
|
|
||||||
|
private AssetReference[] _peacefulSoundtrack;
|
||||||
|
private AssetReference[] _actionSoundtrack;
|
||||||
|
private AssetReference[] _menuSoundtrack;
|
||||||
|
private AssetReference[] _SFX;
|
||||||
|
private AssetReference[] _enemies;
|
||||||
|
private AssetReference[] _dispatcher;
|
||||||
|
private AssetReference[] _character;
|
||||||
|
|
||||||
|
private AsyncOperationHandle<IList<AudioClip>> _menuMusicHandle;
|
||||||
|
private AsyncOperationHandle<IList<AudioClip>> _actionMusicHandle;
|
||||||
|
private AsyncOperationHandle<IList<AudioClip>> _peacefulMusicHandle;
|
||||||
|
private AsyncOperationHandle<IList<AudioClip>> _SFXHandle;
|
||||||
|
private AsyncOperationHandle<IList<AudioClip>> _enemiesHandle;
|
||||||
|
private AsyncOperationHandle<IList<AudioClip>> _dispatcherHandle;
|
||||||
|
|
||||||
|
public Dictionary<MusicType, List<AudioClip>> MusicDictionary { get; private set; } = new();
|
||||||
|
public List<AudioClip> SFXAudios { get; private set; } = new();
|
||||||
|
public List<AudioClip> EnemiesAudios { get; private set; } = new();
|
||||||
|
public List<AudioClip> DispatcherAudios { get; private set; } = new();
|
||||||
|
|
||||||
|
public AudioFactory(AudioMixerConfig audioMixerConfig,
|
||||||
|
SoundtrackListConfig soundtrackListConfig,
|
||||||
|
SFXListConfig sfxListConfig,
|
||||||
|
EnemiesSoundListConfig enemiesSoundListConfig,
|
||||||
|
DispatcherSoundListConfig dispatcherSoundListConfig
|
||||||
|
)
|
||||||
|
{
|
||||||
|
AudioMixer = audioMixerConfig.audioMixerAsset;
|
||||||
|
_audioSourcePrefab = audioMixerConfig.audioSourcePrefab;
|
||||||
|
|
||||||
|
_peacefulSoundtrack = soundtrackListConfig.peacefulSoundtrack;
|
||||||
|
_actionSoundtrack = soundtrackListConfig.actionSoundtrack;
|
||||||
|
_menuSoundtrack = soundtrackListConfig.menuSoundtrack;
|
||||||
|
_SFX = sfxListConfig.SFX;
|
||||||
|
_enemies = enemiesSoundListConfig.enemies;
|
||||||
|
_dispatcher = dispatcherSoundListConfig.dispatcher;
|
||||||
|
|
||||||
|
MusicDictionary.Add(MusicType.Menu, new ());
|
||||||
|
MusicDictionary.Add(MusicType.Peaceful, new ());
|
||||||
|
MusicDictionary.Add(MusicType.Action, new ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTask LoadAudioSourcePrefab(Action<GameObject> callback) =>
|
||||||
|
callback?.Invoke(await Addressables.LoadAssetAsync<GameObject>(_audioSourcePrefab));
|
||||||
|
|
||||||
|
public async UniTask WarmGameplayMusic( )
|
||||||
|
{
|
||||||
|
_actionMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_actionSoundtrack, OnActionTrackLoaded, Addressables.MergeMode.Union);
|
||||||
|
_peacefulMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_peacefulSoundtrack, OnPeacefulTrackLoaded, Addressables.MergeMode.Union);
|
||||||
|
|
||||||
|
await UniTask.WhenAll(_actionMusicHandle.ToUniTask(), _peacefulMusicHandle.ToUniTask());
|
||||||
|
}
|
||||||
|
public void ReleaseActionMusic()
|
||||||
|
{
|
||||||
|
MusicDictionary[MusicType.Action].Clear();
|
||||||
|
_actionMusicHandle.Release();
|
||||||
|
}
|
||||||
|
public void ReleasePeacefulMusic()
|
||||||
|
{
|
||||||
|
MusicDictionary[MusicType.Peaceful].Clear();
|
||||||
|
_peacefulMusicHandle.Release();
|
||||||
|
}
|
||||||
|
public async UniTask WarmMenuMusic( )
|
||||||
|
{
|
||||||
|
_menuMusicHandle = Addressables.LoadAssetsAsync<AudioClip>(_menuSoundtrack, OnMenuTrackLoaded, Addressables.MergeMode.Union);
|
||||||
|
// foreach (var assetReference in _menuSoundtrack) MenuMusic.Add(await assetReference.LoadAssetAsync<AudioClip>());
|
||||||
|
await _menuMusicHandle.ToUniTask();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ReleaseMenuMusic()
|
||||||
|
{
|
||||||
|
MusicDictionary[MusicType.Menu].Clear();
|
||||||
|
// foreach (var assetReference in _menuSoundtrack) assetReference.ReleaseAsset();
|
||||||
|
_menuMusicHandle.Release();
|
||||||
|
}
|
||||||
|
public async UniTask WarmSFX( )
|
||||||
|
{
|
||||||
|
_SFXHandle = Addressables.LoadAssetsAsync<AudioClip>(_SFX, OnSFXLoaded, Addressables.MergeMode.Union);
|
||||||
|
|
||||||
|
await _SFXHandle.ToUniTask();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void ReleaseSFX()
|
||||||
|
{
|
||||||
|
SFXAudios.Clear();
|
||||||
|
_SFXHandle.Release();
|
||||||
|
}
|
||||||
|
public async UniTask WarmEnemies( )
|
||||||
|
{
|
||||||
|
_enemiesHandle = Addressables.LoadAssetsAsync<AudioClip>(_enemies, OnEnemiesLoaded, Addressables.MergeMode.Union);
|
||||||
|
|
||||||
|
await _enemiesHandle.ToUniTask();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleaseEnemies()
|
||||||
|
{
|
||||||
|
EnemiesAudios.Clear();
|
||||||
|
_enemiesHandle.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTask WarmDispatcher( )
|
||||||
|
{
|
||||||
|
_dispatcherHandle = Addressables.LoadAssetsAsync<AudioClip>(_dispatcher, OnDispatcherLoaded, Addressables.MergeMode.Union);
|
||||||
|
|
||||||
|
await _dispatcherHandle.ToUniTask();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleaseDispatcher()
|
||||||
|
{
|
||||||
|
DispatcherAudios.Clear();
|
||||||
|
_dispatcherHandle.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMenuTrackLoaded(AudioClip audioClip)
|
||||||
|
{
|
||||||
|
MusicDictionary[MusicType.Menu].Add(audioClip);
|
||||||
|
}
|
||||||
|
private void OnActionTrackLoaded(AudioClip audioClip)
|
||||||
|
{
|
||||||
|
MusicDictionary[MusicType.Action].Add(audioClip);
|
||||||
|
}
|
||||||
|
private void OnPeacefulTrackLoaded(AudioClip audioClip)
|
||||||
|
{
|
||||||
|
MusicDictionary[MusicType.Peaceful].Add(audioClip);
|
||||||
|
}
|
||||||
|
private void OnSFXLoaded(AudioClip audioClip)
|
||||||
|
{
|
||||||
|
SFXAudios.Add(audioClip);
|
||||||
|
}
|
||||||
|
private void OnEnemiesLoaded(AudioClip audioClip)
|
||||||
|
{
|
||||||
|
EnemiesAudios.Add(audioClip);
|
||||||
|
}
|
||||||
|
private void OnDispatcherLoaded(AudioClip audioClip)
|
||||||
|
{
|
||||||
|
DispatcherAudios.Add(audioClip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5a4b48740d194d4dafa1732f96d71687
|
||||||
|
timeCreated: 1762626915
|
||||||
@@ -0,0 +1,172 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using Code.Configs;
|
||||||
|
using Code.Constants;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using Reflex.Attributes;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public class AudioService : IAudioService
|
||||||
|
{
|
||||||
|
private IAudioFactory _audioFactory;
|
||||||
|
|
||||||
|
private AudioMixer _mixer;
|
||||||
|
private AudioSource _actionMusicSource;
|
||||||
|
private AudioSource _peacefulMusicSource;
|
||||||
|
|
||||||
|
private AudioMixerGroup _masterGroup,
|
||||||
|
// _musicGroup,
|
||||||
|
// _actionMusicGroup,
|
||||||
|
// _peacefulMusicGroup,
|
||||||
|
_SFXGroup,
|
||||||
|
_creaturesGroup,
|
||||||
|
_dispatcherGroup,
|
||||||
|
_courierGroup,
|
||||||
|
_enemiesGroup;
|
||||||
|
|
||||||
|
private readonly AudioSourcePool _audioSourcePool = new();
|
||||||
|
|
||||||
|
private Dictionary<AudioSnapshotState, AudioMixerSnapshot> _snapshots = new();
|
||||||
|
|
||||||
|
public AudioService(IAudioFactory audioFactory)
|
||||||
|
{
|
||||||
|
_audioFactory = audioFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTask Initialize()
|
||||||
|
{
|
||||||
|
// _mixer = await _audioFactory.CreateMixer();
|
||||||
|
_mixer = _audioFactory.AudioMixer;
|
||||||
|
|
||||||
|
_masterGroup = _mixer.FindMatchingGroups(AudioGroups.MasterGroup)[0];
|
||||||
|
// _actionMusicGroup = _mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0];
|
||||||
|
// _peacefulMusicGroup = _mixer.FindMatchingGroups(AudioGroups.PeacefulMusoup)[0];
|
||||||
|
// _musicGroup = _mixer.FindMatchingGroups(AudioGroups.MusicGroup)[0];
|
||||||
|
_musicAudioGroups.Add(MusicType.Menu, _mixer.FindMatchingGroups(AudioGroups.MenuMusicGroup)[0]);
|
||||||
|
_musicAudioGroups.Add(MusicType.Action, _mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0]);
|
||||||
|
_musicAudioGroups.Add(MusicType.Peaceful, _mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0]);
|
||||||
|
|
||||||
|
_cancellationTokenSources.Add(MusicType.Menu, new());
|
||||||
|
_cancellationTokenSources.Add(MusicType.Action, new());
|
||||||
|
_cancellationTokenSources.Add(MusicType.Peaceful, new());
|
||||||
|
|
||||||
|
_musicAudioSources.Add(MusicType.Menu, null);
|
||||||
|
_musicAudioSources.Add(MusicType.Action, null);
|
||||||
|
_musicAudioSources.Add(MusicType.Peaceful, null);
|
||||||
|
|
||||||
|
_SFXGroup = _mixer.FindMatchingGroups(AudioGroups.SFXGroup)[0];
|
||||||
|
_creaturesGroup = _mixer.FindMatchingGroups(AudioGroups.CreaturesGroup)[0];
|
||||||
|
_dispatcherGroup = _mixer.FindMatchingGroups(AudioGroups.DispatcherMusicGroup)[0];
|
||||||
|
_courierGroup = _mixer.FindMatchingGroups(AudioGroups.CourierMusicGroup)[0];
|
||||||
|
_enemiesGroup = _mixer.FindMatchingGroups(AudioGroups.EnemiesMusicGroup)[0];
|
||||||
|
|
||||||
|
_snapshots[AudioSnapshotState.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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#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, AudioSource> _musicAudioSources = new();
|
||||||
|
private Dictionary<MusicType, AudioMixerGroup> _musicAudioGroups = new();
|
||||||
|
|
||||||
|
public async UniTaskVoid PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType musicType)
|
||||||
|
{
|
||||||
|
if(!_musicAudioSources[musicType])
|
||||||
|
{
|
||||||
|
_musicAudioSources[musicType] = _audioSourcePool.GetSource();
|
||||||
|
_musicAudioSources[musicType].spatialBlend = 0f;
|
||||||
|
_musicAudioSources[musicType].outputAudioMixerGroup = _musicAudioGroups[musicType];
|
||||||
|
}
|
||||||
|
|
||||||
|
_musicAudioSources[musicType].resource =
|
||||||
|
_audioFactory.MusicDictionary[musicType][
|
||||||
|
Random.Range(0, _audioFactory.MusicDictionary[musicType].Count)];
|
||||||
|
|
||||||
|
_musicAudioSources[musicType].Play();
|
||||||
|
|
||||||
|
// await UniTask.WaitUntilValueChanged(_musicAudioSources[musicType],
|
||||||
|
// _ => !_musicAudioSources[musicType].isPlaying,
|
||||||
|
// cancellationToken: _cancellationTokenSources[musicType].Token);
|
||||||
|
await UniTask.NextFrame();
|
||||||
|
// Debug.Log($"Playing {musicType}");
|
||||||
|
var (isCanceled, _) = await UniTask.WaitUntilValueChanged(_musicAudioSources[musicType],
|
||||||
|
_ => !_musicAudioSources[musicType].isPlaying,
|
||||||
|
cancellationToken: _cancellationTokenSources[musicType].Token).SuppressCancellationThrow();
|
||||||
|
// Debug.Log($"Finished {musicType}");
|
||||||
|
|
||||||
|
if (isCanceled)
|
||||||
|
{
|
||||||
|
// Debug.Log($"Cancelled {musicType}");
|
||||||
|
_cancellationTokenSources[musicType].Dispose();
|
||||||
|
_cancellationTokenSources[musicType] = new();
|
||||||
|
|
||||||
|
_audioSourcePool.ReleaseSource(_musicAudioSources[musicType]);
|
||||||
|
_musicAudioSources[musicType] = null;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(musicType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTaskVoid GladlyAskToStopMusic(MusicType musicType, AudioSnapshotState audioSnapshotState = AudioSnapshotState.None, float time = 1f, Action callback = null)
|
||||||
|
{
|
||||||
|
TransitToSnapshot(audioSnapshotState, time);
|
||||||
|
|
||||||
|
await UniTask.WaitForSeconds(time);
|
||||||
|
|
||||||
|
_cancellationTokenSources[musicType].Cancel();
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
_peacefulMusicSource.Stop();
|
||||||
|
_actionMusicSource.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GladlyAskToStopMusic(Action callback = null)
|
||||||
|
{
|
||||||
|
TransitToSnapshot(AudioSnapshotState.None);
|
||||||
|
_peacefulMusicSource.Stop();
|
||||||
|
_actionMusicSource.Stop();
|
||||||
|
|
||||||
|
callback?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TransitToSnapshot(AudioSnapshotState state, float time = 1f)
|
||||||
|
{
|
||||||
|
_snapshots[state].TransitionTo(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)
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayOneShot(_audioFactory.SFXAudios[(int)sfxId], position, _SFXGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position)
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayOneShot(_audioFactory.EnemiesAudios[(int)enemySoundId], position, _enemiesGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayDispatcher(DispatcherSounds dispatcherSoundId)
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayShizo(_audioFactory.DispatcherAudios[(int)dispatcherSoundId], _dispatcherGroup);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bf44cb051308463494bd930f2a3d31e4
|
||||||
|
timeCreated: 1762625073
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Code.Constants;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public class AudioServiceDebug : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private AudioMixer mixer;
|
||||||
|
|
||||||
|
private AudioSource _actionMusicSource;
|
||||||
|
private AudioSource _peacefulMusicSource;
|
||||||
|
[SerializeField] private AudioSource prefab;
|
||||||
|
|
||||||
|
[SerializeField] private AudioResource[] peacefulAudio;
|
||||||
|
[SerializeField] private AudioResource[] actionAudio;
|
||||||
|
|
||||||
|
private AudioMixerGroup _masterGroup,
|
||||||
|
_musicGroup,
|
||||||
|
_actionMusicGroup,
|
||||||
|
_peacefulMusicGroup,
|
||||||
|
_SFXGroup,
|
||||||
|
_creaturesGroup,
|
||||||
|
_dispatcherGroup,
|
||||||
|
_courierGroup,
|
||||||
|
_enemiesGroup;
|
||||||
|
|
||||||
|
private readonly AudioSourcePool _audioSourcePool = new();
|
||||||
|
|
||||||
|
private Dictionary<AudioSnapshotState, AudioMixerSnapshot> _snapshots = new();
|
||||||
|
|
||||||
|
[FormerlySerializedAs("sfxAudio")] [SerializeField] private AudioClip[] sfxAudios;
|
||||||
|
[SerializeField] private AudioClip[] enemiesAudios;
|
||||||
|
[SerializeField] private AudioClip[] dispatcherAudios;
|
||||||
|
|
||||||
|
private void MixerCreated()
|
||||||
|
{
|
||||||
|
_masterGroup = mixer.FindMatchingGroups(AudioGroups.MasterGroup)[0];
|
||||||
|
_actionMusicGroup = mixer.FindMatchingGroups(AudioGroups.ActionMusicGroup)[0];
|
||||||
|
_peacefulMusicGroup = mixer.FindMatchingGroups(AudioGroups.PeacefulMusicGroup)[0];
|
||||||
|
_SFXGroup = mixer.FindMatchingGroups(AudioGroups.SFXGroup)[0];
|
||||||
|
_musicGroup = mixer.FindMatchingGroups(AudioGroups.MusicGroup)[0];
|
||||||
|
_creaturesGroup = mixer.FindMatchingGroups(AudioGroups.CreaturesGroup)[0];
|
||||||
|
_dispatcherGroup = mixer.FindMatchingGroups(AudioGroups.DispatcherMusicGroup)[0];
|
||||||
|
_courierGroup = mixer.FindMatchingGroups(AudioGroups.CourierMusicGroup)[0];
|
||||||
|
_enemiesGroup = mixer.FindMatchingGroups(AudioGroups.EnemiesMusicGroup)[0];
|
||||||
|
|
||||||
|
_snapshots[AudioSnapshotState.Peaceful] = mixer.FindSnapshot(AudioGroups.PeacefulSnapshot);
|
||||||
|
_snapshots[AudioSnapshotState.Action] = mixer.FindSnapshot(AudioGroups.ActionSnapshot);
|
||||||
|
|
||||||
|
// _audioSourcePool.Initialize(10,prefab);
|
||||||
|
|
||||||
|
InitializeMusicSources();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeMusicSources()
|
||||||
|
{
|
||||||
|
_actionMusicSource = _audioSourcePool.GetSource();
|
||||||
|
_actionMusicSource.outputAudioMixerGroup = _actionMusicGroup;
|
||||||
|
_actionMusicSource.spatialBlend = 0f;
|
||||||
|
|
||||||
|
_peacefulMusicSource = _audioSourcePool.GetSource();
|
||||||
|
_peacefulMusicSource.outputAudioMixerGroup = _peacefulMusicGroup;
|
||||||
|
_peacefulMusicSource.spatialBlend = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
MixerCreated();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PlayRandomGameplayMusic()
|
||||||
|
{
|
||||||
|
_peacefulMusicSource.resource = peacefulAudio[Random.Range(0, peacefulAudio.Length)];
|
||||||
|
_actionMusicSource.resource = actionAudio[Random.Range(0, actionAudio.Length)];
|
||||||
|
|
||||||
|
_peacefulMusicSource.Play();
|
||||||
|
_actionMusicSource.Play();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TransitToSnapshot(AudioSnapshotState state)
|
||||||
|
{
|
||||||
|
_snapshots[state].TransitionTo(1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
|
public void PlaySFX(SFXSounds sfxId, Vector3 position)
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayOneShot(sfxAudios[(int)sfxId], position, _SFXGroup);
|
||||||
|
}
|
||||||
|
public void PlayDebugSFX()
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayOneShot(sfxAudios[(int)SFXSounds.Crowbar], transform.position, _SFXGroup);
|
||||||
|
}
|
||||||
|
public void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position)
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayOneShot(enemiesAudios[(int)enemySoundId], position, _enemiesGroup);
|
||||||
|
}
|
||||||
|
public void PlayDebugEnemySFX()
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayOneShot(enemiesAudios[(int)EnemiesSounds.Bastard], transform.position, _enemiesGroup);
|
||||||
|
}
|
||||||
|
public void PlayDispatcher(DispatcherSounds dispatcherSoundId)
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayShizo(dispatcherAudios[(int)dispatcherSoundId], _dispatcherGroup);
|
||||||
|
}
|
||||||
|
public void PlayDebugDispatcherSFX()
|
||||||
|
{
|
||||||
|
_audioSourcePool.PlayShizo(dispatcherAudios[(int)DispatcherSounds.AhFreeman], _dispatcherGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: a42cad8f28f54a53bef23d9313014abd
|
||||||
|
timeCreated: 1762805867
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public enum AudioSnapshotState
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Peaceful,
|
||||||
|
Action,
|
||||||
|
Menu
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 29adaf8e912649d9b91c09735e36840a
|
||||||
|
timeCreated: 1762808301
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
using UnityEngine.Pool;
|
||||||
|
|
||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public class AudioSourcePool
|
||||||
|
{
|
||||||
|
// The pool holds plain GameObjects (you can swap this for any component type).
|
||||||
|
private IObjectPool<AudioSource> _pool;
|
||||||
|
private GameObject _sourcePrefab;
|
||||||
|
|
||||||
|
public void Initialize(GameObject sourcePrefab)
|
||||||
|
{
|
||||||
|
_sourcePrefab = sourcePrefab;
|
||||||
|
|
||||||
|
// Create a pool with the four core callbacks.
|
||||||
|
_pool = new ObjectPool<AudioSource>(
|
||||||
|
createFunc: CreateItem,
|
||||||
|
// actionOnGet: OnGet,
|
||||||
|
actionOnRelease: OnRelease,
|
||||||
|
actionOnDestroy: OnDestroyItem,
|
||||||
|
collectionCheck: true, // helps catch double-release mistakes
|
||||||
|
defaultCapacity: 10,
|
||||||
|
maxSize: 20
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creates a new pooled GameObject the first time (and whenever the pool needs more).
|
||||||
|
private AudioSource CreateItem()
|
||||||
|
{
|
||||||
|
AudioSource audioSource = Object.Instantiate(_sourcePrefab).GetComponent<AudioSource>();
|
||||||
|
audioSource.name = "PooledAudioSource";
|
||||||
|
Object.DontDestroyOnLoad(audioSource);
|
||||||
|
return audioSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when an item is taken from the pool.
|
||||||
|
private void OnGet(AudioSource source)
|
||||||
|
{
|
||||||
|
//source.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when an item is returned to the pool.
|
||||||
|
private void OnRelease(AudioSource source)
|
||||||
|
{
|
||||||
|
source.Stop();
|
||||||
|
//source.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when the pool decides to destroy an item (e.g., above max size).
|
||||||
|
private void OnDestroyItem(AudioSource source)
|
||||||
|
{
|
||||||
|
Object.Destroy(source.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTaskVoid PlayOneShot(AudioClip clip, Vector3 position, AudioMixerGroup audioMixerGroup)
|
||||||
|
{
|
||||||
|
AudioSource source = _pool.Get();
|
||||||
|
source.PlayOneShot(clip);
|
||||||
|
source.spatialBlend = 1f;
|
||||||
|
source.transform.position = position;
|
||||||
|
source.outputAudioMixerGroup = audioMixerGroup;
|
||||||
|
|
||||||
|
await UniTask.WaitUntilValueChanged(source, x => x.isPlaying);
|
||||||
|
|
||||||
|
_pool.Release(source);
|
||||||
|
}
|
||||||
|
public async UniTaskVoid PlayShizo(AudioClip clip, AudioMixerGroup audioMixerGroup)
|
||||||
|
{
|
||||||
|
AudioSource source = _pool.Get();
|
||||||
|
source.PlayOneShot(clip);
|
||||||
|
source.spatialBlend = 0f;
|
||||||
|
source.outputAudioMixerGroup = audioMixerGroup;
|
||||||
|
|
||||||
|
await UniTask.WaitUntilValueChanged(source, x => x.isPlaying);
|
||||||
|
|
||||||
|
_pool.Release(source);
|
||||||
|
}
|
||||||
|
public AudioSource GetSource() => _pool.Get();
|
||||||
|
public void ReleaseSource(AudioSource source) => _pool.Release(source);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 370b6a43a74744ff9d90a99991b104f7
|
||||||
|
timeCreated: 1762852042
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
|
||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public interface IAudioFactory
|
||||||
|
{
|
||||||
|
List<AudioClip> SFXAudios { get; }
|
||||||
|
List<AudioClip> EnemiesAudios { get; }
|
||||||
|
List<AudioClip> DispatcherAudios { get; }
|
||||||
|
AudioMixer AudioMixer { get; }
|
||||||
|
Dictionary<MusicType, List<AudioClip>> MusicDictionary { get; }
|
||||||
|
UniTask LoadAudioSourcePrefab(Action<GameObject> callback);
|
||||||
|
UniTask WarmGameplayMusic();
|
||||||
|
void ReleaseActionMusic();
|
||||||
|
UniTask WarmMenuMusic();
|
||||||
|
void ReleaseMenuMusic();
|
||||||
|
UniTask WarmSFX();
|
||||||
|
void ReleaseSFX();
|
||||||
|
UniTask WarmEnemies();
|
||||||
|
void ReleaseEnemies();
|
||||||
|
UniTask WarmDispatcher();
|
||||||
|
void ReleaseDispatcher();
|
||||||
|
void ReleasePeacefulMusic();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ea837e1ca08a4846b7f4ce2df771bf65
|
||||||
|
timeCreated: 1762804793
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public interface IAudioService
|
||||||
|
{
|
||||||
|
UniTask Initialize();
|
||||||
|
UniTaskVoid PlayRandomMusicUntilHumanityWillBeDestroyedForTheySins(MusicType musicType);
|
||||||
|
UniTaskVoid GladlyAskToStopMusic(MusicType musicType, AudioSnapshotState audioSnapshotState = AudioSnapshotState.None, float time = 1f, Action callback = null);
|
||||||
|
void StopMusic();
|
||||||
|
void GladlyAskToStopMusic(Action callback = null);
|
||||||
|
void TransitToSnapshot(AudioSnapshotState state, float time = 1f);
|
||||||
|
void PlaySFX(SFXSounds sfxId, Vector3 position);
|
||||||
|
void PlayEnemy(EnemiesSounds enemySoundId, Vector3 position);
|
||||||
|
void PlayDispatcher(DispatcherSounds dispatcherSoundId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 30521fadcce84848ae88363e915bceb4
|
||||||
|
timeCreated: 1762804728
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Code.Audio
|
||||||
|
{
|
||||||
|
public enum MusicType
|
||||||
|
{
|
||||||
|
Menu,
|
||||||
|
Peaceful,
|
||||||
|
Action
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 74ff08d5f1b741f69e37fc06fb07ae8d
|
||||||
|
timeCreated: 1763151897
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
using UnityEngine.Audio;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Config/Audio/Mixer", fileName = "AudioMixerConfig")]
|
||||||
|
public class AudioMixerConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public AudioMixer audioMixerAsset;
|
||||||
|
public AssetReference audioSourcePrefab;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 353cee8946ca43efbbcda905d7b32ae1
|
||||||
|
timeCreated: 1762624627
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
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,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 83304a98bbdc4e7c9c7c643653ae1368
|
||||||
|
timeCreated: 1762625438
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Config/Audio/DispatcherSoundList", fileName = "DispatcherSoundListConfig")]
|
||||||
|
public class DispatcherSoundListConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public AssetReference[] dispatcher;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a6f6ffb8f5242899791719801791945
|
||||||
|
timeCreated: 1762625431
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Config/Audio/EnemiesSoundList", fileName = "EnemiesSoundListConfig")]
|
||||||
|
public class EnemiesSoundListConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public AssetReference[] enemies;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e73ac7f7e3cd4db8ada95f63d73c2d1d
|
||||||
|
timeCreated: 1762625425
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Config/Gameplay/OrderBox", fileName = "OrderBoxConfig")]
|
||||||
|
public class OrderBoxConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public float activationTime;
|
||||||
|
public AnimationCurve floatingCurve;
|
||||||
|
public float curveLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6af4f53d425a41c78ef889fd7e5c3197
|
||||||
|
timeCreated: 1763735968
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(fileName = "OrderServiceConfig", menuName = "Config/Gameplay/OrderServiceConfig")]
|
||||||
|
public class OrderServiceConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public Vector2 timeBounds;
|
||||||
|
public float koefRooms, koefOvertime;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ee2550c3e4874575ac3aecadfcc42475
|
||||||
|
timeCreated: 1763559999
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
|
||||||
namespace Code.Configs
|
namespace Code.Configs
|
||||||
{
|
{
|
||||||
@@ -6,5 +7,8 @@ namespace Code.Configs
|
|||||||
public class PlayerConfig : ScriptableObject
|
public class PlayerConfig : ScriptableObject
|
||||||
{
|
{
|
||||||
public int maxHealth;
|
public int maxHealth;
|
||||||
|
|
||||||
|
public AssetReference characterPrefab;
|
||||||
|
public AssetReference armsMeshPrefab;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Config/Audio/SFXList", fileName = "SFXListConfig")]
|
||||||
|
public class SFXListConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public AssetReference[] SFX;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be49de18297645009c1e2092f382a670
|
||||||
|
timeCreated: 1762625417
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
|
||||||
|
namespace Code.Configs
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(menuName = "Config/Audio/SoundtrackList", fileName = "SoundtrackListConfig")]
|
||||||
|
public class SoundtrackListConfig : ScriptableObject
|
||||||
|
{
|
||||||
|
public AssetReference[] peacefulSoundtrack;
|
||||||
|
public AssetReference[] actionSoundtrack;
|
||||||
|
public AssetReference[] menuSoundtrack;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6d4b28e4552d456d99550b6d91467345
|
||||||
|
timeCreated: 1762624980
|
||||||
@@ -10,4 +10,22 @@ namespace Code.Constants
|
|||||||
{
|
{
|
||||||
public const string LoadingScreen = "LoadingScreen";
|
public const string LoadingScreen = "LoadingScreen";
|
||||||
}
|
}
|
||||||
|
public static class AudioGroups
|
||||||
|
{
|
||||||
|
public const string MasterGroup = "Master";
|
||||||
|
public const string SFXGroup = "SFX";
|
||||||
|
public const string CreaturesGroup = "Creatures";
|
||||||
|
public const string MusicGroup = "Music";
|
||||||
|
public const string PeacefulMusicGroup = "Peaceful";
|
||||||
|
public const string ActionMusicGroup = "Action";
|
||||||
|
public const string DispatcherMusicGroup = "Dispatcher";
|
||||||
|
public const string CourierMusicGroup = "Courier";
|
||||||
|
public const string EnemiesMusicGroup = "Enemies";
|
||||||
|
|
||||||
|
public const string PeacefulSnapshot = "Peaceful";
|
||||||
|
public const string ActionSnapshot = "Action";
|
||||||
|
public const string NoneSnapshot = "None";
|
||||||
|
public const string MenuSnapshot = "Menu";
|
||||||
|
public const string MenuMusicGroup = "Menu";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ namespace Code.Gameplay.Camera
|
|||||||
{
|
{
|
||||||
Bogdan,
|
Bogdan,
|
||||||
Static,
|
Static,
|
||||||
|
UltraStatic,
|
||||||
FirstPerson,
|
FirstPerson,
|
||||||
ThirdPerson,
|
ThirdPerson,
|
||||||
Cinematic
|
Cinematic
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ namespace Code.Gameplay.Camera
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
States.Add(CameraMode.Static, new StaticState(StateMachineContext));
|
States.Add(CameraMode.Static, new StaticState(StateMachineContext));
|
||||||
|
States.Add(CameraMode.UltraStatic, new UltraStaticState(StateMachineContext));
|
||||||
States.Add(CameraMode.FirstPerson, new FirstPersonState(StateMachineContext));
|
States.Add(CameraMode.FirstPerson, new FirstPersonState(StateMachineContext));
|
||||||
States.Add(CameraMode.ThirdPerson, new ThirdPersonState(StateMachineContext));
|
States.Add(CameraMode.ThirdPerson, new ThirdPersonState(StateMachineContext));
|
||||||
|
|
||||||
CurrentBaseState = States[CameraMode.Static];
|
CurrentBaseState = States[CameraMode.UltraStatic];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnityEngine.Camera Camera => StateMachineContext.Camera;
|
||||||
|
|
||||||
protected override bool CheckTransitionAllowed(CameraMode nextState) => true;
|
protected override bool CheckTransitionAllowed(CameraMode nextState) => true;
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ namespace Code.Gameplay.Camera.CameraStates
|
|||||||
protected virtual void HandleRotationInput(float deltaTime, Vector3 rotationInput, out Quaternion targetRotation)
|
protected virtual void HandleRotationInput(float deltaTime, Vector3 rotationInput, out Quaternion targetRotation)
|
||||||
{
|
{
|
||||||
// Вращение вокруг вертикальной оси (горизонтальный поворот)
|
// Вращение вокруг вертикальной оси (горизонтальный поворот)
|
||||||
var rotationFromInput = Quaternion.Euler(FollowTransform.up * (rotationInput.x * RotationSpeed));
|
var rotationFromInput = Quaternion.Euler(Vector3.up * (rotationInput.x * RotationSpeed));
|
||||||
PlanarDirection = rotationFromInput * PlanarDirection;
|
PlanarDirection = rotationFromInput * PlanarDirection;
|
||||||
var planarRotation = Quaternion.LookRotation(PlanarDirection, FollowTransform.up);
|
var planarRotation = Quaternion.LookRotation(PlanarDirection, FollowTransform.up);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Camera.CameraStates
|
||||||
|
{
|
||||||
|
public class UltraStaticState : BaseCameraState, ICameraState
|
||||||
|
{
|
||||||
|
public UltraStaticState(CameraStateMachineContext context) : base(context) { }
|
||||||
|
|
||||||
|
public override void EnterState()
|
||||||
|
{
|
||||||
|
Debug.Log("Ultra static State Enter");
|
||||||
|
base.EnterState();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void HandlePosition(float deltaTime, float zoomInput, Quaternion targetRotation)
|
||||||
|
{
|
||||||
|
Camera.transform.position = FollowTransform.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CameraMode GetCameraMode() => CameraMode.UltraStatic;
|
||||||
|
|
||||||
|
protected override void HandleRotationInput(float deltaTime, Vector3 rotationInput,
|
||||||
|
out Quaternion targetRotation)
|
||||||
|
{
|
||||||
|
if(FollowTransform) Camera.transform.rotation = FollowTransform.rotation;
|
||||||
|
targetRotation = Camera.transform.rotation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8e4b2fa3af4b4ba78ab79ca154f05fb4
|
||||||
|
timeCreated: 1763547110
|
||||||
+39
-2
@@ -16,6 +16,12 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
// Пороговый косинус стены
|
// Пороговый косинус стены
|
||||||
public float WallNormalThreshold { get; }
|
public float WallNormalThreshold { get; }
|
||||||
|
|
||||||
|
private bool _hasClimbedThisWallSession;
|
||||||
|
private float _wallClimbCooldownTimer;
|
||||||
|
private readonly float _wallClimbCooldownDuration = 1.5f;
|
||||||
|
|
||||||
|
public bool IsClimbingActive { get; private set; }
|
||||||
|
|
||||||
// Конструктор механики залазания на стену
|
// Конструктор механики залазания на стену
|
||||||
public WallClimbMechanic(float wallClimbSpeedFactor, float minWallClimbSpeed, float wallDetectionAngleThreshold)
|
public WallClimbMechanic(float wallClimbSpeedFactor, float minWallClimbSpeed, float wallDetectionAngleThreshold)
|
||||||
{
|
{
|
||||||
@@ -26,11 +32,21 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Обработка столкновения при движении (вызывается при ударе о препятствие)
|
// Обработка столкновения при движении (вызывается при ударе о препятствие)
|
||||||
public void OnMovementHit(KinematicCharacterMotor motor, Vector3 hitNormal)
|
public bool TryClimbWall(KinematicCharacterMotor motor, Vector3 hitNormal)
|
||||||
{
|
{
|
||||||
// Проверяем, что это вертикальная или почти вертикальная поверхность (стена)
|
// Проверяем, что это вертикальная или почти вертикальная поверхность (стена)
|
||||||
var dotWithUp = Vector3.Dot(hitNormal, motor.CharacterUp);
|
var dotWithUp = Vector3.Dot(hitNormal, motor.CharacterUp);
|
||||||
if (Mathf.Abs(dotWithUp) > WallNormalThreshold) return; // Не стена — это пол или потолок
|
|
||||||
|
if (Mathf.Abs(dotWithUp) > WallNormalThreshold)
|
||||||
|
{
|
||||||
|
// Сбрасываем сессию, если коснулись пола/потолка → выход из "режима стены"
|
||||||
|
_hasClimbedThisWallSession = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запрещаем повторное залазание в рамках одной сессии
|
||||||
|
if (_hasClimbedThisWallSession || _wallClimbCooldownTimer > 0f)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Получаем текущую скорость персонажа
|
// Получаем текущую скорость персонажа
|
||||||
var currentVelocity = motor.Velocity;
|
var currentVelocity = motor.Velocity;
|
||||||
@@ -41,6 +57,7 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
// Если движемся в стену с достаточной скоростью
|
// Если движемся в стену с достаточной скоростью
|
||||||
if (velocityIntoWall > _minWallClimbSpeed)
|
if (velocityIntoWall > _minWallClimbSpeed)
|
||||||
{
|
{
|
||||||
|
_wallClimbCooldownTimer = _wallClimbCooldownDuration;
|
||||||
// Преобразуем часть горизонтальной скорости в вертикальную
|
// Преобразуем часть горизонтальной скорости в вертикальную
|
||||||
var verticalBoost = velocityIntoWall * _wallClimbSpeedFactor;
|
var verticalBoost = velocityIntoWall * _wallClimbSpeedFactor;
|
||||||
|
|
||||||
@@ -49,6 +66,26 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
|
|
||||||
// Предотвращаем заземление и повторное применение в этом кадре
|
// Предотвращаем заземление и повторное применение в этом кадре
|
||||||
motor.ForceUnground();
|
motor.ForceUnground();
|
||||||
|
_hasClimbedThisWallSession = true;
|
||||||
|
IsClimbingActive = true;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetWallClimbSession()
|
||||||
|
{
|
||||||
|
_hasClimbedThisWallSession = false;
|
||||||
|
IsClimbingActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TickCooldown(float deltaTime)
|
||||||
|
{
|
||||||
|
if (_wallClimbCooldownTimer > 0f)
|
||||||
|
{
|
||||||
|
_wallClimbCooldownTimer -= deltaTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+80
-12
@@ -17,6 +17,12 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
private Vector3 _lastWallNormal;
|
private Vector3 _lastWallNormal;
|
||||||
private float _lastWallContactHeight;
|
private float _lastWallContactHeight;
|
||||||
private float _leanFactor;
|
private float _leanFactor;
|
||||||
|
private float _leanSign;
|
||||||
|
private Vector3 _leanDirection;
|
||||||
|
|
||||||
|
private Vector3 _lastWallContactPoint;
|
||||||
|
private bool _isLeaningOnWall;
|
||||||
|
private const float WallProximityThreshold = 0.6f;
|
||||||
|
|
||||||
public WallLeanMechanic(float maxLeanAngle, float leanSharpness, float heightScale)
|
public WallLeanMechanic(float maxLeanAngle, float leanSharpness, float heightScale)
|
||||||
{
|
{
|
||||||
@@ -32,25 +38,89 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Вызывается из OnMovementHit
|
// Вызывается из OnMovementHit
|
||||||
public void OnWallContact(Vector3 wallNormal, float contactHeight)
|
public void OnWallContact(KinematicCharacterMotor motor, Vector3 wallNormal, float contactHeight)
|
||||||
{
|
{
|
||||||
|
// Только если это действительно стена (не пол/потолок)
|
||||||
|
var dotWithUp = Vector3.Dot(wallNormal, motor.CharacterUp);
|
||||||
|
if (Mathf.Abs(dotWithUp) > 0.7f) // ~45°, можно настроить
|
||||||
|
return;
|
||||||
|
|
||||||
_lastWallNormal = wallNormal;
|
_lastWallNormal = wallNormal;
|
||||||
_lastWallContactHeight = contactHeight; }
|
_lastWallContactHeight = contactHeight;
|
||||||
|
_lastWallContactPoint = motor.TransientPosition;
|
||||||
|
|
||||||
|
// Пересчитываем направление наклона
|
||||||
|
_leanDirection = -_lastWallNormal;
|
||||||
|
_leanDirection = Vector3.ProjectOnPlane(_leanDirection, motor.CharacterUp).normalized;
|
||||||
|
|
||||||
|
_leanSign = 1;
|
||||||
|
|
||||||
|
// what the fuck
|
||||||
|
if (_leanDirection.x != 0)
|
||||||
|
{
|
||||||
|
switch (_leanDirection.x)
|
||||||
|
{
|
||||||
|
case -1 or 1 when motor.CharacterRight.x > 0.1f:
|
||||||
|
_leanSign = -1;
|
||||||
|
break;
|
||||||
|
case -1 or 1 when Mathf.Abs(motor.CharacterRight.x) < 0.1f:
|
||||||
|
_leanDirection = new Vector3(0, 0, -1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (_leanDirection.z)
|
||||||
|
{
|
||||||
|
case 1 when Mathf.Abs(motor.CharacterRight.z) < 0.1f:
|
||||||
|
_leanSign = -1;
|
||||||
|
break;
|
||||||
|
case -1 when motor.CharacterRight.z < -0.1f:
|
||||||
|
case 1 when motor.CharacterRight.z > 0.1f:
|
||||||
|
_leanDirection = new Vector3(-1, 0, 0);
|
||||||
|
break;
|
||||||
|
case -1 when motor.CharacterRight.z > 0.1f:
|
||||||
|
case 1 when motor.CharacterRight.z < -0.1f:
|
||||||
|
_leanDirection = new Vector3(1, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_isLeaningOnWall = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Обновление каждый кадр
|
// Обновление каждый кадр
|
||||||
public void UpdateLean(KinematicCharacterMotor motor, float deltaTime)
|
public void UpdateLean(KinematicCharacterMotor motor, float deltaTime)
|
||||||
{
|
{
|
||||||
if (!_characterTransform) return;
|
if (!_characterTransform) return;
|
||||||
|
|
||||||
var isGrounded = motor.GroundingStatus.IsStableOnGround;
|
var currentPosition = motor.TransientPosition;
|
||||||
|
|
||||||
if (!isGrounded)
|
var isStillNearWall = false;
|
||||||
|
if (_isLeaningOnWall && _lastWallNormal != Vector3.zero)
|
||||||
{
|
{
|
||||||
var heightDelta = motor.TransientPosition.y - _lastWallContactHeight;
|
var toWall = currentPosition - _lastWallContactPoint;
|
||||||
|
var distanceToWallPlane = Mathf.Abs(Vector3.Dot(toWall, _lastWallNormal));
|
||||||
|
isStillNearWall = distanceToWallPlane <= WallProximityThreshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isLeaningOnWall)
|
||||||
|
{
|
||||||
|
var isBelowContactHeight = currentPosition.y < _lastWallContactHeight;
|
||||||
|
|
||||||
|
if (!isStillNearWall || isBelowContactHeight)
|
||||||
|
{
|
||||||
|
_isLeaningOnWall = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var heightDelta = currentPosition.y - _lastWallContactHeight;
|
||||||
var targetLeanFactor = Mathf.Clamp01(heightDelta * _heightScale);
|
var targetLeanFactor = Mathf.Clamp01(heightDelta * _heightScale);
|
||||||
_leanFactor = Mathf.Lerp(_leanFactor, targetLeanFactor, 1f - Mathf.Exp(-_leanSharpness * deltaTime));
|
_leanFactor = Mathf.Lerp(_leanFactor, targetLeanFactor, 1f - Mathf.Exp(-_leanSharpness * deltaTime));
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
|
||||||
|
if (!_isLeaningOnWall)
|
||||||
{
|
{
|
||||||
_leanFactor = Mathf.Lerp(_leanFactor, 0f, 1f - Mathf.Exp(-_leanSharpness * deltaTime));
|
_leanFactor = Mathf.Lerp(_leanFactor, 0f, 1f - Mathf.Exp(-_leanSharpness * deltaTime));
|
||||||
}
|
}
|
||||||
@@ -66,13 +136,11 @@ namespace Code.Gameplay.Character.Controller.Abilities
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var leanDirection = -_lastWallNormal;
|
if (_leanDirection.sqrMagnitude < 0.01f) return;
|
||||||
leanDirection = Vector3.ProjectOnPlane(leanDirection, motor.CharacterUp).normalized;
|
|
||||||
|
|
||||||
if (leanDirection.sqrMagnitude < 0.01f) return;
|
var leanAngle = _leanSign * _leanFactor * _maxLeanAngle;
|
||||||
|
var leanAxis = Vector3.Cross(motor.CharacterUp, _leanDirection);
|
||||||
var leanAngle = _leanFactor * _maxLeanAngle;
|
var leanRotation = Quaternion.AngleAxis(leanAngle, leanAxis);
|
||||||
var leanRotation = Quaternion.AngleAxis(leanAngle, Vector3.Cross(motor.CharacterUp, leanDirection));
|
|
||||||
_characterTransform.localRotation = leanRotation;
|
_characterTransform.localRotation = leanRotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+55
-16
@@ -33,9 +33,43 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
private GroundMovementSystem _groundMovement;
|
private GroundMovementSystem _groundMovement;
|
||||||
private AirMovementSystem _airMovement;
|
private AirMovementSystem _airMovement;
|
||||||
|
|
||||||
|
public void SetPosition(Vector3 position) => motor.SetPosition(position);
|
||||||
|
public void SetRotation(Quaternion rotation) => motor.SetRotation(rotation);
|
||||||
|
|
||||||
// Инициализация контроллера
|
// Инициализация контроллера
|
||||||
private void Awake()
|
// private void Awake()
|
||||||
|
// {
|
||||||
|
// // Инициализация подсистем с параметрами из конфига
|
||||||
|
// _inputHandler = new CharacterInputHandler(
|
||||||
|
// _characterConfig.sprintAngleThreshold
|
||||||
|
// );
|
||||||
|
// _slideMechanic = new SlideMechanic(
|
||||||
|
// _characterConfig.slideSpeed,
|
||||||
|
// _characterConfig.slideDuration,
|
||||||
|
// _characterConfig.slideCooldown
|
||||||
|
// );
|
||||||
|
// _wallClimbMechanic = new WallClimbMechanic(
|
||||||
|
// _characterConfig.wallClimbSpeedFactor,
|
||||||
|
// _characterConfig.minWallClimbSpeed,
|
||||||
|
// _characterConfig.wallDetectionAngleThreshold
|
||||||
|
// );
|
||||||
|
// _wallLeanMechanic = new WallLeanMechanic(
|
||||||
|
// _characterConfig.maxWallLeanAngle,
|
||||||
|
// _characterConfig.wallLeanSharpness,
|
||||||
|
// _characterConfig.wallLeanHeightScale
|
||||||
|
// );
|
||||||
|
// _groundMovement = new GroundMovementSystem(
|
||||||
|
// _characterConfig.maxStableMoveSpeed,
|
||||||
|
// _characterConfig.sprintMoveSpeed,
|
||||||
|
// _characterConfig.stableMovementSharpness,
|
||||||
|
// _characterConfig.jumpSpeed
|
||||||
|
// );
|
||||||
|
// _airMovement = new AirMovementSystem(_characterConfig.gravity);
|
||||||
|
// }
|
||||||
|
[Inject]
|
||||||
|
private void Construct(CharacterConfig characterConfig)
|
||||||
{
|
{
|
||||||
|
_characterConfig = characterConfig;
|
||||||
// Инициализация подсистем с параметрами из конфига
|
// Инициализация подсистем с параметрами из конфига
|
||||||
_inputHandler = new CharacterInputHandler(
|
_inputHandler = new CharacterInputHandler(
|
||||||
_characterConfig.sprintAngleThreshold
|
_characterConfig.sprintAngleThreshold
|
||||||
@@ -62,25 +96,31 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
_characterConfig.jumpSpeed
|
_characterConfig.jumpSpeed
|
||||||
);
|
);
|
||||||
_airMovement = new AirMovementSystem(_characterConfig.gravity);
|
_airMovement = new AirMovementSystem(_characterConfig.gravity);
|
||||||
}
|
|
||||||
|
|
||||||
// Текущий режим камеры для адаптации поведения
|
|
||||||
private CameraMode _currentCameraMode = CameraMode.FirstPerson;
|
|
||||||
|
|
||||||
// Инициализация контроллера
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
motor.CharacterController = this; // Регистрация этого контроллера в движке
|
motor.CharacterController = this; // Регистрация этого контроллера в движке
|
||||||
_inputHandler.FirstPersonCameraRotation =
|
_inputHandler.FirstPersonCameraRotation =
|
||||||
motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
||||||
_wallLeanMechanic.SetCharacterTransform(characterTransform);
|
_wallLeanMechanic.SetCharacterTransform(characterTransform);
|
||||||
}
|
}
|
||||||
|
// Текущий режим камеры для адаптации поведения
|
||||||
|
private CameraMode _currentCameraMode = CameraMode.FirstPerson;
|
||||||
|
|
||||||
|
// Инициализация контроллера
|
||||||
|
// private void Start()
|
||||||
|
// {
|
||||||
|
// motor.CharacterController = this; // Регистрация этого контроллера в движке
|
||||||
|
// _inputHandler.FirstPersonCameraRotation =
|
||||||
|
// motor.Transform.rotation; // Начальное вращение совпадает с персонажемс
|
||||||
|
// _wallLeanMechanic.SetCharacterTransform(characterTransform);
|
||||||
|
// }
|
||||||
|
|
||||||
// Обработка и преобразование входных данных от персонажа
|
// Обработка и преобразование входных данных от персонажа
|
||||||
public void SetInputs(ref CharacterInputs inputs)
|
public void SetInputs(ref CharacterInputs inputs)
|
||||||
{
|
{
|
||||||
// Обновляем таймер перезарядки слайда
|
// Обновляем таймер перезарядки слайда
|
||||||
_slideMechanic.TickCooldown(Time.deltaTime);
|
_slideMechanic.TickCooldown(Time.deltaTime);
|
||||||
|
_wallClimbMechanic.TickCooldown(Time.deltaTime);
|
||||||
|
|
||||||
// Если активен слайд - игнорируем весь остальной ввод
|
// Если активен слайд - игнорируем весь остальной ввод
|
||||||
if (_slideMechanic.IsSliding)
|
if (_slideMechanic.IsSliding)
|
||||||
@@ -109,8 +149,7 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
// Обновление вращения персонажа на основе входных данных
|
// Обновление вращения персонажа на основе входных данных
|
||||||
public void UpdateRotation(ref Quaternion currentRotation, float deltaTime)
|
public void UpdateRotation(ref Quaternion currentRotation, float deltaTime)
|
||||||
{
|
{
|
||||||
// ВО ВРЕМЯ СЛАЙДА НЕ ОБНОВЛЯЕМ ВРАЩЕНИЕ - ПЕРСОНАЖ СМОТРИТ ПРЯМО
|
if (_slideMechanic.IsSliding || _wallClimbMechanic.IsClimbingActive) return;
|
||||||
if (_slideMechanic.IsSliding) return;
|
|
||||||
|
|
||||||
switch (_currentCameraMode)
|
switch (_currentCameraMode)
|
||||||
{
|
{
|
||||||
@@ -196,6 +235,11 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
{
|
{
|
||||||
_slideMechanic.EndSlide();
|
_slideMechanic.EndSlide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (motor.GroundingStatus.IsStableOnGround)
|
||||||
|
{
|
||||||
|
_wallClimbMechanic.ResetWallClimbSession();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Метод вызывается после обновления персонажа
|
// Метод вызывается после обновления персонажа
|
||||||
@@ -220,13 +264,8 @@ namespace Code.Gameplay.Character.Controller
|
|||||||
public void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint,
|
public void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint,
|
||||||
ref HitStabilityReport hitStabilityReport)
|
ref HitStabilityReport hitStabilityReport)
|
||||||
{
|
{
|
||||||
_wallClimbMechanic.OnMovementHit(motor, hitNormal);
|
if (_wallClimbMechanic.TryClimbWall(motor, hitNormal))
|
||||||
|
_wallLeanMechanic.OnWallContact(motor, hitNormal, motor.TransientPosition.y);
|
||||||
var dotWithUp = Vector3.Dot(hitNormal, motor.CharacterUp);
|
|
||||||
if (Mathf.Abs(dotWithUp) <= _wallClimbMechanic.WallNormalThreshold)
|
|
||||||
{
|
|
||||||
_wallLeanMechanic.OnWallContact(hitNormal, motor.TransientPosition.y);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обработка отчета о стабильности столкновения
|
// Обработка отчета о стабильности столкновения
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ namespace Code.Gameplay.Character.Controller.Input
|
|||||||
var cameraForward = cameraRotation * Vector3.forward;
|
var cameraForward = cameraRotation * Vector3.forward;
|
||||||
|
|
||||||
// Проецируем на горизонтальную плоскость
|
// Проецируем на горизонтальную плоскость
|
||||||
var horizontalForward = Vector3.ProjectOnPlane(cameraForward, motor.CharacterUp).normalized;
|
var horizontalForward = Vector3.ProjectOnPlane(cameraForward, Vector3.up).normalized;
|
||||||
|
|
||||||
// Если проекция вырождена, используем текущее направление персонажа
|
// Если проекция вырождена, используем текущее направление персонажа
|
||||||
if (horizontalForward.sqrMagnitude < 0.01f)
|
if (horizontalForward.sqrMagnitude < 0.01f)
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
using Code.Gameplay.Camera;
|
||||||
|
using Code.Gameplay.Camera.CameraStates;
|
||||||
|
using Code.Gameplay.Character.Controller;
|
||||||
|
using Code.Gameplay.Player;
|
||||||
|
using Code.Input;
|
||||||
|
using Reflex.Attributes;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Character.Core
|
||||||
|
{
|
||||||
|
public class CharacterProvider : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Inject] private CameraStateMachine _cameraStateMachine; // Стейт-машина камеры (нужна для транзакций и т.п.)
|
||||||
|
[SerializeField] private CustomCharacterController customCharacterController; // Компонент управления персонажем
|
||||||
|
public CustomCharacterController CustomCharacterController => customCharacterController;
|
||||||
|
|
||||||
|
[SerializeField] private Transform cameraFollowPoint; // Точка следования камеры (уровень глаз для FirstPerson)
|
||||||
|
public Transform GetFollowTransform() => cameraFollowPoint;
|
||||||
|
|
||||||
|
[Inject] private IInputService _inputService; // Сервис ввода через DI
|
||||||
|
|
||||||
|
[SerializeField] private PlayerAnimator _animator;
|
||||||
|
public PlayerAnimator PlayerAnimator => _animator;
|
||||||
|
|
||||||
|
public void Teleport(Vector3 position, Quaternion rotation)
|
||||||
|
{
|
||||||
|
customCharacterController.SetPosition(position);
|
||||||
|
customCharacterController.SetRotation(rotation);
|
||||||
|
}
|
||||||
|
// Обработка ввода для движения персонажа
|
||||||
|
private void HandleCharacterInput()
|
||||||
|
{
|
||||||
|
// Создаем структуру ввода с полной информацией о камере
|
||||||
|
var inputs = new CharacterInputs();
|
||||||
|
|
||||||
|
// Получаем данные движения из Input System
|
||||||
|
var moveInput = _inputService.MoveInput;
|
||||||
|
inputs.MoveAxisForward = moveInput.y; // Vertical ось (W/S или Up/Down)
|
||||||
|
inputs.MoveAxisRight = moveInput.x; // Horizontal ось (A/D или Left/Right)
|
||||||
|
inputs.JumpPressed = _inputService.JumpPressed; // Прыжки (Space)
|
||||||
|
inputs.SprintPressed = true;//_inputService.SprintPressed; // Спринт (Shift)
|
||||||
|
inputs.SlidePressed = _inputService.SlidePressed; // Слайд (Ctrl)
|
||||||
|
inputs.CameraMode = ((ICameraState)_cameraStateMachine.CurrentBaseState).GetCameraMode();
|
||||||
|
|
||||||
|
// Передаем информацию о камере для адаптивного поведения
|
||||||
|
inputs.CameraRotation = ((BaseCameraState)_cameraStateMachine.CurrentBaseState).GetCameraRotation();
|
||||||
|
inputs.CameraPlanarDirection = ((BaseCameraState)_cameraStateMachine.CurrentBaseState).GetPlanarDirection();
|
||||||
|
|
||||||
|
// Передаем ввод в контроллер персонажа
|
||||||
|
customCharacterController.SetInputs(ref inputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Обновление логики каждый кадр
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
// Обработка ввода для движения в Update (физика)
|
||||||
|
HandleCharacterInput();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b2d4b8256c1f4b3facf6b8d0a7d5256b
|
||||||
|
timeCreated: 1763217123
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b7ba7b62b1aa47c48dc82ac8d8e8530e
|
||||||
|
timeCreated: 1763548306
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using DG.Tweening;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Door
|
||||||
|
{
|
||||||
|
public class CinematicDoorOpening
|
||||||
|
{
|
||||||
|
public DamnDoor DamnDoor;
|
||||||
|
public Light DoorLight;
|
||||||
|
|
||||||
|
public void PreOpen(bool start)
|
||||||
|
{
|
||||||
|
DoorLight.DOColor(start ? Color.yellow : Color.red, 0.2f);
|
||||||
|
|
||||||
|
DamnDoor.Petlya.DORotate(new Vector3(0, -40, 0), 1f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
DamnDoor.Petlya.DORotate(new Vector3(0, 0, 0), 1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: deda0339570d44609dd62eafd9c6215f
|
||||||
|
timeCreated: 1763548908
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Door
|
||||||
|
{
|
||||||
|
public class DamnDoor : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] Rigidbody rigidbody;
|
||||||
|
[SerializeField] private Transform petlya;
|
||||||
|
public Transform Petlya => petlya;
|
||||||
|
|
||||||
|
public void SetPhysics(bool active)
|
||||||
|
{
|
||||||
|
rigidbody.isKinematic = active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 50a6b5e332704611b19f5a209d4dbffe
|
||||||
|
timeCreated: 1763548314
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e41c28f7828a44b7bc26d87886064d99
|
||||||
|
timeCreated: 1763556651
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4911436131e345ada949f2418595bbd8
|
||||||
|
timeCreated: 1763559099
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public interface IOrderService
|
||||||
|
{
|
||||||
|
delegate void OrderProgressDelegate(float time);
|
||||||
|
|
||||||
|
event OrderProgressDelegate OnOrderGiven;
|
||||||
|
event OrderProgressDelegate OnOrderRecieved;
|
||||||
|
|
||||||
|
delegate void OrderDeliveredDelegate(int score, float time);
|
||||||
|
|
||||||
|
event OrderDeliveredDelegate OnOrderDelivered;
|
||||||
|
OrderState OrderState { get; }
|
||||||
|
void RoomPassed();
|
||||||
|
float DecreaseTimer(float delta);
|
||||||
|
void OrderGive();
|
||||||
|
void OrderRecieved();
|
||||||
|
void OrderDelivered();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8b4467951c884c8dafeb633020696c24
|
||||||
|
timeCreated: 1763561686
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public interface IScoreService
|
||||||
|
{
|
||||||
|
int Score { get; }
|
||||||
|
void IncreaseScore(int amount);
|
||||||
|
void DecreaseScore(int amount);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 64668c9ef4c441af84c635365cfbb2de
|
||||||
|
timeCreated: 1763559523
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using Code.Configs;
|
||||||
|
using Code.Gameplay.Orders.Order;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using Reflex.Attributes;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public class OrderBox : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Inject] private IOrderService _orderService;
|
||||||
|
public Rigidbody rigidbody;
|
||||||
|
[SerializeField] private bool _pickupMode;
|
||||||
|
// [SerializeField] private AnimationCurve debugCurve;
|
||||||
|
|
||||||
|
//DEBUG
|
||||||
|
// private void Start()
|
||||||
|
// {
|
||||||
|
// _capturedPosition = transform.position;
|
||||||
|
// _floatingCurve = debugCurve;
|
||||||
|
// _curveLength = 1f;
|
||||||
|
// }
|
||||||
|
// DEBUG
|
||||||
|
|
||||||
|
private float _activationTime;
|
||||||
|
[Inject]
|
||||||
|
private void Construct(OrderBoxConfig config)
|
||||||
|
{
|
||||||
|
_floatingCurve = config.floatingCurve;
|
||||||
|
_activationTime = config.activationTime;
|
||||||
|
_curveLength = config.curveLength;
|
||||||
|
}
|
||||||
|
public void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (!_pickupMode) return;
|
||||||
|
|
||||||
|
_orderService.OrderRecieved();
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTaskVoid SwitchMode()
|
||||||
|
{
|
||||||
|
Debug.LogWarning("Activating");
|
||||||
|
await UniTask.WaitForSeconds(_activationTime);
|
||||||
|
Debug.LogWarning("Available");
|
||||||
|
_pickupMode = true;
|
||||||
|
rigidbody.isKinematic = true;
|
||||||
|
_capturedPosition = transform.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3 _capturedPosition;
|
||||||
|
private float _timeForMoving;
|
||||||
|
private AnimationCurve _floatingCurve;
|
||||||
|
private float _curveLength;
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
if (!_pickupMode) return;
|
||||||
|
_timeForMoving += Time.fixedDeltaTime;
|
||||||
|
|
||||||
|
if (_timeForMoving > _curveLength) _timeForMoving = 0;
|
||||||
|
|
||||||
|
transform.position = _capturedPosition + new Vector3(0, _floatingCurve.Evaluate(_timeForMoving), 0);
|
||||||
|
Debug.Log(transform.position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 067bc72af86a4fb8ac44d0c1fcfd25d5
|
||||||
|
timeCreated: 1763573681
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using Reflex.Attributes;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public class OrderDeliveryTrigger : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Inject] private IOrderService _orderService;
|
||||||
|
private bool _playerEntered;
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (_playerEntered) return;
|
||||||
|
|
||||||
|
_playerEntered = true;
|
||||||
|
_orderService.OrderDelivered();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 47fbefab729047e5a11d8761e26f75a6
|
||||||
|
timeCreated: 1763737623
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using DG.Tweening;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public class OrderDispenser : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private Transform hatch;
|
||||||
|
[SerializeField] private OrderBox order;
|
||||||
|
|
||||||
|
private bool _activated;
|
||||||
|
public void ThrowOrder()
|
||||||
|
{
|
||||||
|
hatch.DORotate(new Vector3(-130f, 0, 0), 0.2f);
|
||||||
|
|
||||||
|
order.rigidbody.isKinematic = false;
|
||||||
|
order.rigidbody.AddForce(-transform.forward * 10f, ForceMode.Impulse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG TODO ДИМКА УДАЛИ И ПРОПИШИ В СВОЕЙ ЛОГИКЕ
|
||||||
|
public void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if(_activated) return;
|
||||||
|
_activated = true;
|
||||||
|
|
||||||
|
ThrowOrder();
|
||||||
|
order.SwitchMode();
|
||||||
|
}
|
||||||
|
// DEBUG
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e50e3c42f5ee45e0b1087e0dbf7dd0f4
|
||||||
|
timeCreated: 1763556675
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Reflex.Attributes;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public class OrderGiveTrigger : MonoBehaviour
|
||||||
|
{
|
||||||
|
[Inject] private IOrderService _orderService;
|
||||||
|
private bool _playerEntered;
|
||||||
|
private void OnTriggerEnter(Collider other)
|
||||||
|
{
|
||||||
|
if (_playerEntered) return;
|
||||||
|
|
||||||
|
_playerEntered = true;
|
||||||
|
_orderService.OrderGive();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d3966e4798d243abba9d85b9ad8aef33
|
||||||
|
timeCreated: 1763742374
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
using Code.Audio;
|
||||||
|
using Code.Configs;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public class OrderService : IOrderService
|
||||||
|
{
|
||||||
|
public event IOrderService.OrderProgressDelegate OnOrderGiven;
|
||||||
|
public event IOrderService.OrderProgressDelegate OnOrderRecieved;
|
||||||
|
public event IOrderService.OrderDeliveredDelegate OnOrderDelivered;
|
||||||
|
|
||||||
|
private OrderState _orderState;
|
||||||
|
public OrderState OrderState => _orderState;
|
||||||
|
|
||||||
|
private float _deliveryTimer = 0.0f;
|
||||||
|
|
||||||
|
private Vector2 _timeBounds;
|
||||||
|
private float _koefRooms, _koefOvertime;
|
||||||
|
|
||||||
|
private int _roomsPassed;
|
||||||
|
|
||||||
|
public OrderService(OrderServiceConfig config)
|
||||||
|
{
|
||||||
|
_orderState = OrderState.Delivered;
|
||||||
|
|
||||||
|
_timeBounds = config.timeBounds;
|
||||||
|
_koefRooms = config.koefRooms;
|
||||||
|
_koefOvertime = config.koefOvertime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RoomPassed() => _roomsPassed++;
|
||||||
|
public float DecreaseTimer(float delta)
|
||||||
|
{
|
||||||
|
return _deliveryTimer -= delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OrderGive()
|
||||||
|
{
|
||||||
|
_orderState = OrderState.Given;
|
||||||
|
_roomsPassed = 0;
|
||||||
|
|
||||||
|
_deliveryTimer = Random.Range(_timeBounds.x, _timeBounds.y);
|
||||||
|
OnOrderGiven?.Invoke(_deliveryTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OrderRecieved()
|
||||||
|
{
|
||||||
|
_orderState = OrderState.Recieved;
|
||||||
|
OnOrderRecieved?.Invoke(_deliveryTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OrderDelivered()
|
||||||
|
{
|
||||||
|
_orderState = OrderState.Delivered;
|
||||||
|
|
||||||
|
int score = (int)(_koefRooms * _roomsPassed + _deliveryTimer * _koefOvertime);
|
||||||
|
OnOrderDelivered?.Invoke(score, _deliveryTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b324c2a1be1546868cddf779445b286a
|
||||||
|
timeCreated: 1763559110
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public enum OrderState
|
||||||
|
{
|
||||||
|
Delivered,
|
||||||
|
Given,
|
||||||
|
Recieved,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 0a8980a0cc034110ab3ccd948d40956b
|
||||||
|
timeCreated: 1763559535
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Code.Gameplay.Orders.Order
|
||||||
|
{
|
||||||
|
public class ScoreService : IScoreService
|
||||||
|
{
|
||||||
|
private int _score;
|
||||||
|
public int Score => _score;
|
||||||
|
|
||||||
|
public void IncreaseScore(int amount) => _score += amount;
|
||||||
|
public void DecreaseScore(int amount) => _score -= amount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 619f2425460843aaa1f0f21e302158ce
|
||||||
|
timeCreated: 1763559528
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Player
|
||||||
|
{
|
||||||
|
public class ArmsMeshProvider : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] public Animator ArmsAnimator;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: cfe65f613bc54b4098acdba0d3fdd2a2
|
||||||
|
timeCreated: 1763730814
|
||||||
@@ -1,8 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using Code.Gameplay.Character.Core;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Code.Gameplay.Player
|
namespace Code.Gameplay.Player
|
||||||
{
|
{
|
||||||
public interface IPlayerFactory
|
public interface IPlayerFactory
|
||||||
{
|
{
|
||||||
PlayerHealth CreatePlayerHealth(int count = -1);
|
PlayerHealth CreatePlayerHealth(int count = -1);
|
||||||
PlayerMoney CreatePlayerMoney(int count = 0);
|
PlayerMoney CreatePlayerMoney(int count = 0);
|
||||||
|
UniTask<CharacterProvider> CreatePlayer();
|
||||||
|
void ReleasePlayer(CharacterProvider characterProvider);
|
||||||
|
UniTask<ArmsMeshProvider> CreateArms(Transform papochka);
|
||||||
|
void ReleaseArms(ArmsMeshProvider arms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using KinematicCharacterController;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Code.Gameplay.Player
|
||||||
|
{
|
||||||
|
public class PlayerAnimator : MonoBehaviour
|
||||||
|
{
|
||||||
|
private static readonly int Velocity = Animator.StringToHash("Velocity");
|
||||||
|
|
||||||
|
private Animator _playerAnimator;
|
||||||
|
public void SetAnimator(Animator animator) => _playerAnimator = animator;
|
||||||
|
[SerializeField] private KinematicCharacterMotor kinematicCharacterMotor;
|
||||||
|
|
||||||
|
private void SetVelocity(float velocity)
|
||||||
|
{
|
||||||
|
_playerAnimator.SetFloat(Velocity, velocity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
SetVelocity(kinematicCharacterMotor.Velocity.magnitude);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2f94efbea729423596ee5c6ee2366c98
|
||||||
|
timeCreated: 1763220863
|
||||||
@@ -1,6 +1,13 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Code.Configs;
|
using Code.Configs;
|
||||||
|
using Code.Gameplay.Character.Core;
|
||||||
|
using Cysharp.Threading.Tasks;
|
||||||
using Reflex.Attributes;
|
using Reflex.Attributes;
|
||||||
|
using Reflex.Core;
|
||||||
|
using Reflex.Extensions;
|
||||||
|
using Reflex.Injectors;
|
||||||
|
using UnityEngine.AddressableAssets;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace Code.Gameplay.Player
|
namespace Code.Gameplay.Player
|
||||||
{
|
{
|
||||||
@@ -15,5 +22,21 @@ namespace Code.Gameplay.Player
|
|||||||
return new(count);
|
return new(count);
|
||||||
}
|
}
|
||||||
public PlayerMoney CreatePlayerMoney(int count = 0) => new(count);
|
public PlayerMoney CreatePlayerMoney(int count = 0) => new(count);
|
||||||
|
|
||||||
|
public async UniTask<CharacterProvider> CreatePlayer()
|
||||||
|
{
|
||||||
|
CharacterProvider characterProvider = (await Addressables.InstantiateAsync(_playerConfig.characterPrefab).ToUniTask()).GetComponent<CharacterProvider>();
|
||||||
|
AttributeInjector.Inject(characterProvider, Container.ProjectContainer);
|
||||||
|
AttributeInjector.Inject(characterProvider.CustomCharacterController, Container.ProjectContainer);
|
||||||
|
return characterProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ReleasePlayer(CharacterProvider characterProvider)
|
||||||
|
{
|
||||||
|
Addressables.ReleaseInstance(characterProvider.gameObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async UniTask<ArmsMeshProvider> CreateArms(Transform papochka) => (await Addressables.InstantiateAsync(_playerConfig.armsMeshPrefab, papochka).ToUniTask()).GetComponent<ArmsMeshProvider>();
|
||||||
|
public void ReleaseArms(ArmsMeshProvider arms) => Addressables.ReleaseInstance(arms.gameObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,9 +8,11 @@ namespace Code.Input
|
|||||||
}
|
}
|
||||||
public enum DebugActions
|
public enum DebugActions
|
||||||
{
|
{
|
||||||
GiveHealth,
|
Debug1,
|
||||||
LooseHealth,
|
Debug2,
|
||||||
GiveMoney,
|
Debug3,
|
||||||
LooseMoney
|
Debug4,
|
||||||
|
Debug5,
|
||||||
|
Debug6
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,5 +7,6 @@ namespace Code.Scenes
|
|||||||
{
|
{
|
||||||
UniTaskVoid LoadSceneAsync(string sceneName, float waitFor = 0f, Action callBack = null);
|
UniTaskVoid LoadSceneAsync(string sceneName, float waitFor = 0f, Action callBack = null);
|
||||||
UniTaskVoid LoadSceneAsync(int sceneId, float waitFor = 0f, Action callBack = null);
|
UniTaskVoid LoadSceneAsync(int sceneId, float waitFor = 0f, Action callBack = null);
|
||||||
|
UniTask LoadSceneAsyncAwaitable(int sceneId, float waitFor = 0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using Code.Gameplay.Orders.Order;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
|
namespace Code.Scenes.SceneEnvironments
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class GameplaySceneEnvironment : CurrentSceneEnvironment
|
||||||
|
{
|
||||||
|
[FormerlySerializedAs("sfxTarget")] public Transform debugSfxTarget;
|
||||||
|
public Transform playerSpawnPoint;
|
||||||
|
public OrderDispenser debugTube;
|
||||||
|
|
||||||
|
public void TransitVariables(GameplaySceneEnvironment env)
|
||||||
|
{
|
||||||
|
debugSfxTarget = env.debugSfxTarget;
|
||||||
|
playerSpawnPoint = env.playerSpawnPoint;
|
||||||
|
debugTube = env.debugTube;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 286a31cf64d54f509b13784d928d8842
|
||||||
|
timeCreated: 1763144375
|
||||||
@@ -1,18 +1,21 @@
|
|||||||
|
using Code.Gameplay.Door;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Experimental.GlobalIllumination;
|
||||||
|
|
||||||
namespace Code.Scenes.SceneEnvironments
|
namespace Code.Scenes.SceneEnvironments
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class MainMenuEnvironment : CurrentSceneEnvironment
|
public class MainMenuEnvironment : CurrentSceneEnvironment
|
||||||
{
|
{
|
||||||
public Transform cameraTarget;
|
|
||||||
public Transform cameraPosition;
|
public Transform cameraPosition;
|
||||||
|
public DamnDoor damnDoor;
|
||||||
|
public Light doorLight;
|
||||||
|
|
||||||
public void TransitVariables(MainMenuEnvironment env)
|
public void TransitVariables(MainMenuEnvironment env)
|
||||||
{
|
{
|
||||||
cameraTarget = env.cameraTarget;
|
|
||||||
cameraPosition = env.cameraPosition;
|
cameraPosition = env.cameraPosition;
|
||||||
|
damnDoor = env.damnDoor;
|
||||||
|
doorLight = env.doorLight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,5 +29,12 @@ namespace Code.Scenes
|
|||||||
SceneManager.LoadSceneAsync(sceneId, LoadSceneMode.Single).ToUniTask());
|
SceneManager.LoadSceneAsync(sceneId, LoadSceneMode.Single).ToUniTask());
|
||||||
callBack?.Invoke();
|
callBack?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async UniTask LoadSceneAsyncAwaitable(int sceneId, float waitFor = 0f)
|
||||||
|
{
|
||||||
|
await UniTask.WhenAll(
|
||||||
|
UniTask.Delay(TimeSpan.FromSeconds(waitFor)),
|
||||||
|
SceneManager.LoadSceneAsync(sceneId, LoadSceneMode.Single).ToUniTask());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,13 +10,20 @@ namespace Code.StaticData
|
|||||||
{
|
{
|
||||||
public interface IStaticDataService
|
public interface IStaticDataService
|
||||||
{
|
{
|
||||||
void Load();
|
|
||||||
InputConfig InputConfig { get; }
|
|
||||||
AppConfig AppConfig { get; }
|
AppConfig AppConfig { get; }
|
||||||
|
InputConfig InputConfig { get; }
|
||||||
CameraConfig CameraConfig { get; }
|
CameraConfig CameraConfig { get; }
|
||||||
CharacterConfig CharacterConfig { get; }
|
CharacterConfig CharacterConfig { get; }
|
||||||
UIConfig UIConfig { get; }
|
UIConfig UIConfig { get; }
|
||||||
PlayerConfig PlayerConfig { get; }
|
PlayerConfig PlayerConfig { get; }
|
||||||
|
AudioMixerConfig AudioMixerConfig { get; }
|
||||||
|
SoundtrackListConfig SoundtrackListConfig { get; }
|
||||||
|
SFXListConfig SFXListConfig { get; }
|
||||||
|
DispatcherSoundListConfig DispatcherSoundListConfig { get; }
|
||||||
|
EnemiesSoundListConfig EnemiesSoundListConfig { get; }
|
||||||
|
OrderServiceConfig OrderServiceConfig { get; }
|
||||||
|
OrderBoxConfig OrderBoxConfig { get; }
|
||||||
|
void Load();
|
||||||
Task<T> InstantiateAsset<T>(AssetReference assetReference) where T : Behaviour;
|
Task<T> InstantiateAsset<T>(AssetReference assetReference) where T : Behaviour;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loaded 100 of 457 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user