示例#1
0
    private void Awake()
    {
        YouLose.gameObject.SetActive(false);
        InstanceCache.Flush();

        gameRepository   = InstanceCache.GetOrInstanciate <InMemoryGameRepository>(() => new InMemoryGameRepository());
        resultRepository = InstanceCache.GetOrInstanciate <InMemoryResultRepository>(() => new InMemoryResultRepository());
        scoreService     = InstanceCache.GetOrInstanciate <LocalScoreService>(() => new LocalScoreService());
        resultRepository.Clear();
        gameRepository.Clear();
        scoreService.Reset();

        gamePresenter = InstanceCache.GetOrInstanciate <GamePresenter>(
            () => {
            resultGenerator = new ResultGenerator(4, new AdditionOperator(), new RandomNumberGenerator(5, 15));
            return(new GamePresenter(
                       this,
                       new CreateGame(gameRepository,
                                      new FixedInitialNumber(),
                                      resultGenerator,
                                      resultRepository),
                       new Guess(gameRepository, resultRepository, resultGenerator, scoreService),
                       scoreService));
        });
    }