示例#1
0
        public TestContext()
        {
            ContextProvider.Subscribe(this);

            OnPause          = new UnityEvent <bool>();
            PointsCalculator = new PointsCalculator();
            AssetLoader      = new AssetLoader();
            SequenceChecker  = new DefaultSequenceChecker(3);
        }
        public Context()
        {
            ContextProvider.Subscribe(this);

            OnPause         = new UnityEvent <bool>();
            LocalStorage    = new LocalStorage();
            AssetLoader     = new AssetLoader();
            GameSettings    = AssetLoader.Load <GameSettings>($"Settings/{nameof(GameSettings)}");
            SoundController = AssetLoader.LoadAndInstantiate <SoundController>($"Controllers/{nameof(SoundController)}");

            InputController = AssetLoader.LoadAndInstantiate <InputController>($"Controllers/{nameof(InputController)}");
            //since this creation is in context, we can easily change to another script with another formula
            PointsCalculator = new PointsCalculator();
            SequenceChecker  = new DefaultSequenceChecker(GameSettings.MinItemsCount);

            GameController = AssetLoader.LoadAndInstantiate <GameController>($"Controllers/{nameof(GameController)}");
            GameController.Initialize(GameSettings, InputController, LocalStorage,
                                      SoundController, SequenceChecker, PointsCalculator);
        }