コード例 #1
0
    // TODO: Rewrite this whole logic so that all these dependencies are created PER PAGE when it opens, and are disposed when the page closes.
    public WorldScreenStateManager(
        ITyperPool typerPool,
        IConnectionManager connectionManager,
        WorldScreenState state,
        ILocationsClient locationsClient)
    {
        _characterId     = connectionManager.CharacterId;
        _typerPool       = typerPool;
        _locationsClient = locationsClient;

        connectionManager.WorldStateObservable.Subscribe(state =>
        {
            if (state == null)
            {
                return; // TODO: Show loading screen?
            }
            lock (_updateStateLock)
            {
                UpdateState(state);
            }
        });

        _currentState = state;
        _stateSubject = new BehaviorSubject <WorldScreenState>(_currentState);
    }
コード例 #2
0
    public ScreenFactory(
        ITextGenerator textGenerator,
        IConnectionManager connectionManager,
        ICharactersClient charactersClient,
        ILocationsClient locationsClient,
        IOutput output,
        IPrinter <MainMenuState> mainMenuPrinter,
        IPrinter <CharacterCreationState> characterCreationPrinter,
        IPrinter <WorldScreenState> worldPrinter)
    {
        _textGenerator            = textGenerator;
        _connectionManager        = connectionManager;
        _charactersClient         = charactersClient;
        _locationsClient          = locationsClient;
        _output                   = output;
        _mainMenuPrinter          = mainMenuPrinter;
        _characterCreationPrinter = characterCreationPrinter;
        _worldPrinter             = worldPrinter;

        // Create this only after initializing everything inside ScreenFactory.
        ScreenNavigation = new ScreenNavigation(this);

        Task.Run(() => ScreenNavigation.Screen = GameScreen.MainMenu);
    }