public FromFileSceneCreator(IParamsProvider paramsProvider, IScreenProvider screen,
                             IObjectFromFileProvider objectProvider)
 {
     ParamsProvider = paramsProvider;
     _screen        = screen;
     ObjectProvider = objectProvider;
 }
Пример #2
0
    public static void RunApplication(
        IScreenNavigation screenNavigation,
        IScreenProvider screenProvider,
        CancellationToken cancellationToken)
    {
        screenNavigation.ScreenObservable.Subscribe(screen =>
        {
            // TODO: Refactor to IObservable<IChangeDetector>.
            var cd = screenProvider.GetCurrentScreen()?.ChangeDetector;
            cd?.NotifyChanged();
        });

        while (true)
        {
            if (cancellationToken.IsCancellationRequested)
            {
                return;
            }

            if (screenNavigation.Screen == GameScreen.Exit)
            {
                return;
            }

            var screen = screenProvider.GetCurrentScreen();
            if (screen == null)
            {
                continue;
            }

            var inputHandler = screen.InputHandler;
            var cd           = screen.ChangeDetector;

            var key = Console.ReadKey(true);
            switch (key.Key)
            {
            case ConsoleKey.Escape:
                inputHandler.Escape();
                break;

            case ConsoleKey.Backspace:
                inputHandler.Backspace();
                break;

            case ConsoleKey.Tab:
                inputHandler.Tab();
                break;

            default:
                inputHandler.Type(key.KeyChar);
                break;
            }

            // A hack to redraw the screen every time a key is pressed (to highlight Typers).
            cd.NotifyChanged();
        }
    }
Пример #3
0
 public Renderer(ICameraPositionProvider positionProvider, ICameraDirectionProvider directionProvider,
                 IScreenProvider screenProvider, IColorProvider colorProvider, ILightsProvider lightsProvider)
 {
     _positionProvider  = positionProvider;
     _directionProvider = directionProvider;
     _screenProvider    = screenProvider;
     _colorProvider     = colorProvider;
     _lightsProvider    = lightsProvider;
 }
Пример #4
0
 public SceneCreator(IParamsProvider paramsProvider, IScreenProvider screen, IObjectFromFileProvider objectProvider)
 => (_screen, ParamsProvider, ObjectProvider) = (screen, paramsProvider, objectProvider);
Пример #5
0
 public ProtocolHandler(int maximumFramesPerSecond, IProtocolProvider protocolProvider, IScreenProvider screenProvider)
 {
     _maximumFramesPerSecond = maximumFramesPerSecond;
     _protocolProvider = protocolProvider;
     _screenProvider = screenProvider;
 }
 public static void Activate(this IScreenProvider screenProvider, string screenName)
 {
     screenProvider.FindScreen(screenName).Activate();
 }