-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndlessGameLoopState.cs
More file actions
102 lines (86 loc) · 4.83 KB
/
Copy pathEndlessGameLoopState.cs
File metadata and controls
102 lines (86 loc) · 4.83 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using Constants;
using Services;
using Services.Board;
using Services.GameRound;
using Services.Mono;
using Services.Mono.Sound;
using Services.UI;
using UI.Background;
namespace Infrastructure.StateMachine
{
public class EndlessGameLoopState : IState
{
private readonly ISceneLoader _sceneLoader;
private readonly ILoadingCurtainMonoService _loadingCurtainMonoService;
private readonly IAssetProviderService _assetProviderService;
private readonly IRandomService _randomService;
private readonly IStaticDataService _staticDataService;
private readonly ISoundMonoService _soundMonoService;
private readonly IUpdateMonoService _updateMonoService;
private readonly IPersistentDataService _persistentDataService;
private readonly IUiFactory _uiFactory;
private readonly IWindowService _windowService;
private readonly ICoinService _coinService;
private readonly IAdsService _adsService;
private readonly ICustomizationService _customizationService;
private IBoardService _boardService;
public bool IsGameLoopState => true;
public EndlessGameLoopState(ISceneLoader sceneLoader, ILoadingCurtainMonoService loadingCurtainMonoService,
IAssetProviderService assetProviderService, IRandomService randomService,
IStaticDataService staticDataService, ISoundMonoService soundMonoService,
IUpdateMonoService updateMonoService, IPersistentDataService persistentDataService,
IUiFactory uiFactory, IWindowService windowService, ICoinService coinService, IAdsService adsService,
ICustomizationService customizationService)
{
_sceneLoader = sceneLoader;
_loadingCurtainMonoService = loadingCurtainMonoService;
_assetProviderService = assetProviderService;
_randomService = randomService;
_staticDataService = staticDataService;
_soundMonoService = soundMonoService;
_updateMonoService = updateMonoService;
_persistentDataService = persistentDataService;
_uiFactory = uiFactory;
_windowService = windowService;
_coinService = coinService;
_adsService = adsService;
_customizationService = customizationService;
}
public void Enter()
{
_loadingCurtainMonoService.FadeOnInstantly();
_sceneLoader.LoadScene(Settings.GameLevelScene, OnSceneLoaded, true);
}
public void Exit()
{
Cleanup();
}
private void OnSceneLoaded()
{
_uiFactory.CreateUiRootCanvas();
IProgressUpdateService progressUpdateService = new ProgressUpdateService(Settings.EndlessLevelName, _persistentDataService);
IParticleService particleService = new ParticleService(_staticDataService);
IGameFactory gameFactory = new GameFactory(Settings.EndlessLevelName, _randomService, _staticDataService, particleService);
IPlayerLevelService playerLevelService = new PlayerLevelService(_persistentDataService, _staticDataService, progressUpdateService);
IScoreService scoreService = new ScoreService(Settings.EndlessLevelName, _soundMonoService, _persistentDataService, progressUpdateService, playerLevelService.ScoreToNextLevel);
IGameRoundService gameRoundService = new EndlessGameRoundService(_soundMonoService, _windowService, _coinService, scoreService, playerLevelService);
ITileService tileService = new TileService(Settings.EndlessLevelName, _staticDataService, progressUpdateService, gameFactory, gameRoundService);
IGamePieceService gamePieceService = new GamePieceService(Settings.EndlessLevelName, _staticDataService, _soundMonoService,
_randomService, progressUpdateService, tileService, gameFactory, particleService);
IBoardService boardService = new BoardService(Settings.EndlessLevelName, _soundMonoService, _updateMonoService,
_persistentDataService, _staticDataService, progressUpdateService, scoreService, gameRoundService,
tileService, gamePieceService, particleService);
ICameraService cameraService = new CameraService(boardService.BoardSize);
EndlessBackgroundScreen endlessBackgroundScreen = _assetProviderService.Instantiate<EndlessBackgroundScreen>(AssetPaths.EndlessBackgroundScreenPath);
endlessBackgroundScreen.Init(playerLevelService, scoreService, cameraService, _windowService, _customizationService);
gameRoundService.StartGame();
_loadingCurtainMonoService.FadeOffWithDelay();
_boardService = boardService;
}
private void Cleanup()
{
_uiFactory.Cleanup();
_boardService.Cleanup();
}
}
}