Advertisement
MaoChessy

Untitled

Nov 26th, 2021
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using DefaultNamespace;
  5. using DefaultNamespace.Infrastructure.Data;
  6. using Gameplay;
  7. using Gameplay.Map.ConfigData;
  8. using Gameplay.Map.Generator;
  9. using Infrastructure.ConfigData;
  10. using Infrastructure.SceneStates;
  11. using Interface;
  12. using PerlinNode;
  13. using Plugins.DIContainer;
  14. using Plugins.GameStateMachines;
  15. using Plugins.Interfaces;
  16. using Plugins.Sound;
  17. using Services;
  18. using Services.Inputs;
  19. using UnityEngine;
  20. using UnityEngine.Audio;
  21.  
  22. public class BootStrapGame : MonoBehaviour, ICoroutineRunner
  23. {
  24. [SerializeField] private ConfigGame _configGame;
  25. [SerializeField] private CurtainProgress _curtainProgress;
  26. [SerializeField] private Curtain _curtain;
  27. [SerializeField] private AudioSource _audioSourceTemplate;
  28. [SerializeField] private AudioMixer _audioMixer;
  29. [SerializeField] private Localizator _localizator;
  30.  
  31. private DiBox _diBox = DiBox.MainBox;
  32.  
  33. private void Awake()
  34. {
  35. var appStateMachine = new AppStateMachine();
  36. var onlineProvider = new BinaryProvider();
  37. var localProvider = new BinaryProvider();
  38. var audioMixerScripts= new AudioMixerScript();
  39.  
  40. _localizator.Init(false);
  41.  
  42. _configGame.InitConfig(onlineProvider);
  43.  
  44. _diBox.RegisterSingle(audioMixerScripts);
  45. _diBox.RegisterSingle(_audioMixer);
  46. _diBox.RegisterSingle<ICurtain>(_curtain);
  47. _diBox.RegisterSingle<SaveDataProvider>(onlineProvider, SaveDataProvider.OnlineID);
  48. _diBox.RegisterSingle<SaveDataProvider>(localProvider, SaveDataProvider.LocalID);
  49. _diBox.RegisterSingle(_configGame);
  50. _diBox.RegisterSingle<ICoroutineRunner>(this);
  51. _diBox.RegisterSingle(appStateMachine);
  52. _diBox.RegisterSingle(_localizator);
  53. _diBox.RegisterSingle<ICurtainProgress>(_curtainProgress);
  54. var soundSystem = new SoundSystem(_audioSourceTemplate, 25);
  55. _diBox.RegisterSingle(soundSystem);
  56. _diBox.InjectSingle(soundSystem);
  57. CreateInput();
  58.  
  59. _diBox.InjectSingle(audioMixerScripts);
  60.  
  61. _curtain.Unfade(0);
  62. _curtainProgress.Unfade(0);
  63.  
  64. DontDestroyOnLoad(gameObject);
  65. DontDestroyOnLoad(_curtainProgress);
  66. DontDestroyOnLoad(_curtain);
  67. appStateMachine.Enter<InitScene>();
  68. }
  69.  
  70. private void CreateInput()
  71. {
  72. if(Application.isEditor)
  73. _diBox.InjectAndRegisterAsSingle<IInput>(new PCInput());
  74. else
  75. _diBox.InjectAndRegisterAsSingle<IInput>(new MobileInput());
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement