Пример #1
0
        void GameScreen(Game game)
        {
            currentScreen = new GameScreen(game, fieldSize);

            ScreenCaller.Call(currentScreen, drawer, () => game.DelayBetweenFrames).OnExit((o) =>
            {
                StartScreen();
            });
        }
Пример #2
0
        void ConfigurationScreen()
        {
            currentScreen = new ConfigurationScreen(fieldSize, p);

            ScreenCaller.Call(currentScreen, drawer, 60).OnExit((newConfig) =>
            {
                ConfigStorage.Current = (ConfigStorage)newConfig;
                StartScreen();
            });
        }
Пример #3
0
        /// <summary>
        /// Нарисовать окно с выбором игры и ждать пока пользователь выберет
        /// </summary>
        public void StartScreen()
        {
            currentScreen = new SelectGameScreen(new string[] {
                "Snake game",     // 0
                "Snake together", // 1
                "Tetris",         // 2
                "Flappy bird",    // 3
                "Settings",       // 4
                "Exit"            // 5
            }, fieldSize, p);

            ScreenCaller.Call(currentScreen, drawer, 60).OnExit((i) =>
            {
                int selectedIndex = (int)i;

                if (selectedIndex == 0)
                {
                    GameScreen(new SnakeGame(fieldSize, p));
                }
                else if (selectedIndex == 1)
                {
                    GameScreen(new SnakeTogetherGame(fieldSize, p));
                }
                else if (selectedIndex == 2)
                {
                    GameScreen(new TetrisGame(fieldSize, p));
                }
                else if (selectedIndex == 3)
                {
                    GameScreen(new FlappyBirdGame(fieldSize, p));
                }
                else if (selectedIndex == 4)
                {
                    ConfigurationScreen();
                }
                else if (selectedIndex == 5)
                {
                    Exit();
                }
            });
        }
Пример #4
0
        public static ScreenCaller Call(Screen screen, Drawer d, Func <int> delay)
        {
            var output = new ScreenCaller();

            screen.OnExit += (o) => { output.prevScreenResult = o; };

            do
            {
                d.Create(screen);
                d.DrawToConsole();

                Thread.Sleep(delay());
            } while (!screen.Exited);

            d.Remove(screen);
            d.DrawToConsole();

            screen.OnExit -= (o) => { output.prevScreenResult = o; };

            return(output);
        }