コード例 #1
0
        static void Main(string[] args)
        {
            var boardSizeBounds = Defaults.BoardSizeBounds;
            var boardViewState  = new BoardViewState(boardSizeBounds);

            var gameFlow = Generate.GameFlow()
                           .WithBoardSize(boardSizeBounds)
                           .WithBoardViewUpdater(boardViewState)
                           .Build();

            var canvas = GenerateView(boardSizeBounds, boardViewState);

            var(textBox, userActionMessage) = GenerateInteractiveElements(canvas);

            SetupConsole(canvas);

            var isRunning = true;

            var inputReactionCallbacks = new InputReactionCallbacks(
                () => isRunning = false,
                result => HandleGameActionResult(userActionMessage, result),
                () => HandleReset(userActionMessage));
            var input = GenerateInputListeners(textBox, gameFlow, inputReactionCallbacks);

            while (isRunning)
            {
                Thread.Sleep(10);

                ConsoleManager.ReadInput(input);
            }
        }
コード例 #2
0
 private static IInputListener[] GenerateInputListeners(
     TextBox textBox, GameFlowFacade gameFlow, InputReactionCallbacks inputReactionCallbacks)
 {
     return(new IInputListener[]
     {
         new InputController(textBox, gameFlow, inputReactionCallbacks),
         textBox
     });
 }
コード例 #3
0
 public InputController(TextBox textBox, GameFlowFacade gameFlow, InputReactionCallbacks inputReactionCallbacks)
 {
     _textBox  = textBox;
     _gameFlow = gameFlow;
     _inputReactionCallbacks = inputReactionCallbacks;
 }