Addressables in process
This commit is contained in:
1 parent
1ad87e7432
commit
6b1f24b72e
13 files changed
+122
-77
No files matched your search
@@ -5,7 +5,6 @@ using Code.Input;
|
||||
using Code.Scenes;
|
||||
using Code.StateMachine;
|
||||
using Code.UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Code.App.AppStates
|
||||
@@ -15,6 +14,8 @@ namespace Code.App.AppStates
|
||||
private PlayerHealth _playerHealth;
|
||||
private PlayerMoney _playerMoney;
|
||||
|
||||
private bool _uiLoaded, _sceneLoaded;
|
||||
|
||||
public GameplayState(AppStateMachineContext context) : base(context)
|
||||
{
|
||||
}
|
||||
@@ -23,12 +24,9 @@ namespace Code.App.AppStates
|
||||
{
|
||||
Context.UIService.LoadingScreen.Show();
|
||||
|
||||
Context.SceneLoaderService.LoadScene((int)SceneIds.MovementDev, SceneLoaded); // TODO Фабрика говна Nada
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
|
||||
Context.UIService.SwitchPanelTo(UIPanel.Gameplay);
|
||||
|
||||
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
|
||||
Context.SceneLoaderService.LoadSceneAsync((int)SceneIds.MovementDev, callBack: OnSceneLoaded); // TODO Фабрика говна Nada
|
||||
|
||||
Context.UIService.SwitchPanelTo(UIPanel.Gameplay, callback: PostUILoaded);
|
||||
|
||||
_playerMoney = Context.PlayerFactory.CreatePlayerMoney();
|
||||
_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
|
||||
@@ -40,16 +38,32 @@ namespace Code.App.AppStates
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseHealth, LooseHealth);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseMoney, LooseMoney);
|
||||
}
|
||||
|
||||
private void OnSceneLoaded()
|
||||
{
|
||||
_sceneLoaded = true;
|
||||
CheckIfLoaded();
|
||||
}
|
||||
|
||||
private void SceneLoaded()
|
||||
private void PostUILoaded()
|
||||
{
|
||||
((GameplayPanel)(Context.UIService.CurrentPanel)).Initialize(_playerMoney, _playerHealth);
|
||||
Context.UIService.LoadingScreen.Hide();
|
||||
|
||||
base.EnterState();
|
||||
_uiLoaded = true;
|
||||
CheckIfLoaded();
|
||||
}
|
||||
|
||||
|
||||
private void CheckIfLoaded()
|
||||
{
|
||||
if(!_uiLoaded || !_sceneLoaded) return;
|
||||
|
||||
Context.UIService.LoadingScreen.Hide();
|
||||
|
||||
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
}
|
||||
|
||||
|
||||
// Debug
|
||||
private void GiveHealth(InputAction.CallbackContext context)
|
||||
{
|
||||
|
||||
@@ -14,28 +14,37 @@ namespace Code.App.AppStates
|
||||
{
|
||||
public class MainMenuState : BaseState<AppStateMachineContext>
|
||||
{
|
||||
private bool _uiLoaded, _sceneLoaded;
|
||||
public MainMenuState(AppStateMachineContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
_uiLoaded = false;
|
||||
_sceneLoaded = false;
|
||||
|
||||
Context.UIService.LoadingScreen.Show();
|
||||
|
||||
Context.SceneLoaderService.LoadScene((int)SceneIds.MainMenu, SceneLoaded);
|
||||
Context.InputService.EnableMap(ActionMappings.MainMenu);
|
||||
|
||||
Context.UIService.SwitchPanelTo(UIPanel.MainMenu);
|
||||
((MainMenuPanel)Context.UIService.CurrentPanel).startButton.onClick.AddListener(StartGame);
|
||||
((MainMenuPanel)Context.UIService.CurrentPanel).exitButton.onClick.AddListener(ExitGame);
|
||||
Context.SceneLoaderService.LoadSceneAsync((int)SceneIds.MainMenu, callBack: SceneLoaded);
|
||||
|
||||
Context.UIService.SwitchPanelTo(UIPanel.MainMenu, PostUILoaded);
|
||||
|
||||
Context.CameraStateMachine.SwitchState(CameraMode.Static);
|
||||
}
|
||||
|
||||
private void PostUILoaded()
|
||||
{
|
||||
((MainMenuPanel)Context.UIService.CurrentPanel).startButton.onClick.AddListener(StartGame);
|
||||
((MainMenuPanel)Context.UIService.CurrentPanel).exitButton.onClick.AddListener(ExitGame);
|
||||
|
||||
_uiLoaded = true;
|
||||
|
||||
CheckIfLoaded();
|
||||
}
|
||||
|
||||
private void SceneLoaded()
|
||||
{
|
||||
Context.UIService.LoadingScreen.Hide();
|
||||
|
||||
var hui = ((MainMenuEnvironment)SceneManager.GetActiveScene()
|
||||
.GetSceneContainer().Resolve<CurrentSceneEnvironment>());
|
||||
|
||||
@@ -45,8 +54,21 @@ namespace Code.App.AppStates
|
||||
((BaseCameraState)Context.CameraStateMachine.CurrentBaseState).SetFollowTransform(hui.cameraPosition);
|
||||
|
||||
base.EnterState();
|
||||
|
||||
_sceneLoaded = true;
|
||||
|
||||
CheckIfLoaded();
|
||||
}
|
||||
|
||||
private void CheckIfLoaded()
|
||||
{
|
||||
if(!_uiLoaded || !_sceneLoaded) return;
|
||||
|
||||
Context.UIService.LoadingScreen.Hide();
|
||||
|
||||
Context.InputService.EnableMap(ActionMappings.MainMenu);
|
||||
}
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Code.App.AppStates
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
Context.SceneLoaderService.LoadScene((int)SceneIds.MovementDev, SceneLoaded);
|
||||
// Context.SceneLoaderService.LoadScene((int)SceneIds.MovementDev, SceneLoaded);
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
|
||||
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
|
||||
|
||||
Reference in new issue
Block a user