Repository navigation
Expand file tree
/
Copy pathLoadLevelTestState.cs
More file actions
64 lines (54 loc) · 1.73 KB
/
Copy pathLoadLevelTestState.cs
File metadata and controls
64 lines (54 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using Code.Services.Factories.UIFactory;
using Code.Services.Providers.Widgets;
namespace Code.Infrastructure.StateMachine.Game.States
{
public class LoadLevelTestState : IPayloadedState<string>, IGameState
{
private readonly ISceneLoader _sceneLoader;
private readonly ILoadingCurtain _loadingCurtain;
private readonly IUIFactory _uiFactory;
private readonly IStateMachine<IGameState> _gameStateMachine;
private readonly IWidgetProvider _widgetProvider;
public LoadLevelTestState(
IStateMachine<IGameState> gameStateMachine,
ISceneLoader sceneLoader,
ILoadingCurtain loadingCurtain,
IUIFactory uiFactory,
IWidgetProvider widgetProvider)
{
_gameStateMachine = gameStateMachine;
_sceneLoader = sceneLoader;
_loadingCurtain = loadingCurtain;
_uiFactory = uiFactory;
_widgetProvider = widgetProvider;
}
public void Enter(string payload)
{
_loadingCurtain.Show();
_sceneLoader.Load(payload, OnLevelLoad);
}
public void Exit()
{
_loadingCurtain.Hide();
}
protected virtual void OnLevelLoad()
{
InitGameWorld();
}
private void InitGameWorld()
{
_uiFactory.CreateUiRoot();
InitHud();
InitProviders();
}
private void InitProviders()
{
_widgetProvider.CreatePoolWidgets();
}
private void InitHud()
{
var gameHud = _uiFactory.CreateGameHud();
gameHud.Initialize();
}
}
}