Загрузчик не юзлес + больше интерфейса
This commit is contained in:
1 parent
f3a83eb909
commit
cd384239ff
28 files changed
+379
-1758
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using System.Globalization;
|
||||
using System.Reflection.Emit;
|
||||
using System.Threading.Tasks;
|
||||
using Code.App.Loading;
|
||||
using Code.App.StateMachine;
|
||||
using Code.Audio;
|
||||
@@ -29,9 +30,8 @@ namespace Code.App.AppStates
|
||||
{
|
||||
|
||||
private PlayerHealth _playerHealth;
|
||||
private PlayerMoney _playerMoney;
|
||||
private IPlayerScore _playerScore;
|
||||
|
||||
private IScoreService _scoreService;
|
||||
private IOrderService _orderService;
|
||||
|
||||
private CharacterProvider _playerCharacter;
|
||||
@@ -44,12 +44,10 @@ namespace Code.App.AppStates
|
||||
{
|
||||
Context.LoadingManager
|
||||
.RegisterLoading(LoadingWork.LoadScene)
|
||||
.RegisterLoading(LoadingWork.WaitForSceneInstaller)
|
||||
.RegisterLoading(LoadingWork.LoadUI)
|
||||
.RegisterLoading(LoadingWork.LoadModelResource)
|
||||
// .RegisterLoading(LoadingWork.LoadModelResource)
|
||||
.RegisterLoading(LoadingWork.LoadAudio);
|
||||
|
||||
_playerMoney = Context.PlayerFactory.CreatePlayerMoney();
|
||||
|
||||
_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
|
||||
|
||||
_playerHealth.OnDamage += PlayerDamageTaken;
|
||||
@@ -59,35 +57,59 @@ namespace Code.App.AppStates
|
||||
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, GiveOrderDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug2, RecieveOrderDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug3, DeliverOrderDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug1, InstaKillDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug4, RoomPassedDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug6, TakeDamageDEBUG);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.Debug5, Tube);
|
||||
|
||||
Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.Gameplay);
|
||||
Context.LoadingManager.OnLoadingEnded += AfterSceneLoaded;
|
||||
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
WaitForSceneToLoad();
|
||||
WaitForLoad();
|
||||
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
}
|
||||
private async UniTask WaitForPlayerCharacterLoad() => _playerCharacter = await Context.PlayerFactory.CreatePlayer();
|
||||
|
||||
private async UniTaskVoid WaitForSceneToLoad()
|
||||
private async UniTaskVoid WaitForLoad()
|
||||
{
|
||||
await Context.SceneLoaderService.LoadSceneAsyncAwaitable((int)SceneIds.Gameplay);
|
||||
|
||||
await UniTask.WhenAll(
|
||||
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
|
||||
// TODO
|
||||
Context.UIService.AsyncSwitchPanelTo(UIPanel.Gameplay),
|
||||
Context.AudioFactory.WarmGameplayMusic(),
|
||||
Context.AudioFactory.WarmSFX(),
|
||||
Context.AudioFactory.WarmDispatcher(),
|
||||
// TODO
|
||||
WaitForPlayerArmsToInitialize(),
|
||||
WaitForPlayerCharacterLoad()
|
||||
Context.AudioFactory.WarmDispatcher()
|
||||
);
|
||||
|
||||
Container sceneContainer = SceneManager.GetActiveScene().GetSceneContainer();
|
||||
Context.LoadingManager
|
||||
.UnregisterLoading(LoadingWork.LoadUI)
|
||||
.UnregisterLoading(LoadingWork.LoadAudio);
|
||||
|
||||
InputServiceInitialize();
|
||||
|
||||
MusicInitialize();
|
||||
}
|
||||
|
||||
private async void AfterSceneLoaded()
|
||||
{
|
||||
Context.LoadingManager
|
||||
.RegisterLoading(LoadingWork.LoadModelResource);
|
||||
|
||||
Context.LoadingManager.OnLoadingEnded -= AfterSceneLoaded;
|
||||
Context.LoadingManager.OnLoadingEnded += AfterPlayerLoaded;
|
||||
|
||||
await UniTask.WhenAll(
|
||||
WaitForPlayerArmsToInitialize(),
|
||||
WaitForPlayerCharacterLoad()
|
||||
);
|
||||
|
||||
Context.LoadingManager
|
||||
.UnregisterLoading(LoadingWork.LoadModelResource);
|
||||
}
|
||||
|
||||
private void AfterPlayerLoaded()
|
||||
{
|
||||
Container sceneContainer = SceneManager.GetActiveScene().GetSceneContainer();
|
||||
|
||||
_playerScore = sceneContainer.Resolve<IPlayerScore>();
|
||||
|
||||
GameplaySceneEnvironment sceneEnvironment = SceneEnvironmentVariables(sceneContainer);
|
||||
|
||||
@@ -95,22 +117,13 @@ namespace Code.App.AppStates
|
||||
|
||||
CameraInitialize();
|
||||
|
||||
InputServiceInitialize();
|
||||
|
||||
GameplayServicesInitialize(sceneContainer);
|
||||
|
||||
MusicInitialize();
|
||||
|
||||
UIInitialize();
|
||||
|
||||
_tickEnabled = true;
|
||||
Context.LoadingManager.OnLoadingEnded -= AfterPlayerLoaded;
|
||||
|
||||
Context.LoadingManager
|
||||
.UnregisterLoading(LoadingWork.LoadScene)
|
||||
.UnregisterLoading(LoadingWork.LoadUI)
|
||||
.UnregisterLoading(LoadingWork.LoadModelResource)
|
||||
.UnregisterLoading(LoadingWork.LoadAudio);
|
||||
// Context.UIService.LoadingScreen.Hide();
|
||||
_tickEnabled = true;
|
||||
}
|
||||
|
||||
private async UniTask WaitForPlayerArmsToInitialize() => _armsMesh = await Context.PlayerFactory.CreateArms(Context.CameraStateMachine.Camera.transform);
|
||||
@@ -133,7 +146,7 @@ namespace Code.App.AppStates
|
||||
_gameplayPanel.HideTimer();
|
||||
|
||||
if(time < 0f) Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.Late1,(int)DispatcherSounds.Late2));
|
||||
_playerMoney.GiveMoney(score);
|
||||
_playerScore.UpdateScore(score);
|
||||
|
||||
Context.AudioService.TransitToSnapshot(AudioSnapshotState.Peaceful);
|
||||
}
|
||||
@@ -143,21 +156,9 @@ namespace Code.App.AppStates
|
||||
Context.AudioService.PlayDispatcher((DispatcherSounds)Random.Range((int)DispatcherSounds.TakeDamage1,(int)DispatcherSounds.TakeDamage4));
|
||||
}
|
||||
// DEBUG
|
||||
private void GiveOrderDEBUG(InputAction.CallbackContext context)
|
||||
private void InstaKillDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
_orderService.OrderGive();
|
||||
}
|
||||
private void TakeDamageDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
_playerHealth.GetDamage(1);
|
||||
}
|
||||
private void RecieveOrderDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
_orderService.OrderRecieved();
|
||||
}
|
||||
private void DeliverOrderDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
_orderService.OrderDelivered();
|
||||
_playerHealth.InstaKill();
|
||||
}
|
||||
private void RoomPassedDEBUG(InputAction.CallbackContext context)
|
||||
{
|
||||
@@ -187,7 +188,7 @@ namespace Code.App.AppStates
|
||||
public override void ExitState()
|
||||
{
|
||||
_playerHealth = null;
|
||||
_playerMoney = null;
|
||||
_playerScore = null;
|
||||
|
||||
_tickEnabled = false;
|
||||
|
||||
@@ -205,12 +206,9 @@ namespace Code.App.AppStates
|
||||
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.Debug1, InstaKillDEBUG);
|
||||
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, TakeDamageDEBUG);
|
||||
|
||||
base.ExitState();
|
||||
}
|
||||
@@ -231,7 +229,7 @@ namespace Code.App.AppStates
|
||||
private void UIInitialize()
|
||||
{
|
||||
_gameplayPanel = (GameplayPanel)Context.UIService.CurrentPanel;
|
||||
_gameplayPanel.Initialize(_playerMoney, _playerHealth, _orderService);
|
||||
_gameplayPanel.Initialize(_playerScore, _playerHealth, _orderService);
|
||||
Context.AudioService.OnDispatcherStarted += _gameplayPanel.SummonDispatcher;
|
||||
Context.AudioService.OnDispatcherEnded += _gameplayPanel.CloseDispatcher;
|
||||
}
|
||||
@@ -247,8 +245,7 @@ namespace Code.App.AppStates
|
||||
_playerCharacter.PlayerAnimator.SetAnimator(_armsMesh.ArmsAnimator);
|
||||
}
|
||||
private void GameplayServicesInitialize(Container sceneContainer)
|
||||
{
|
||||
_scoreService = sceneContainer.Resolve<IScoreService>();
|
||||
{
|
||||
_orderService = sceneContainer.Resolve<IOrderService>();
|
||||
|
||||
_orderService.OnOrderGiven += OrderGiven;
|
||||
|
||||
Reference in new issue
Block a user