Пример #1
0
        public void MoveSwitch(ConsoleKey input)
        {
            if (!IsPlaying)
            {
                return;
            }

            ConsoleKey[] keys = { ConsoleKey.D1, ConsoleKey.D2, ConsoleKey.D3, ConsoleKey.D4, ConsoleKey.D5 };

            if (keys.Contains(input))
            {
                PlayingGround.MoveSwitch(Array.IndexOf(keys, input) + 1);
                OutputView.PrintPlayground(PlayingGround);
                InputView.PrintGameInstruction();
            }
        }
Пример #2
0
        public Game()
        {
            IsPlaying = true;

            PlayingGround = Reviver.GeneratePlayingGround();
            Score         = 0;
            Timer         = new Timer(1000)
            {
                AutoReset = true
            };
            Timer.Elapsed += TimerTick;

            Timer.Start();

            OutputView.PrintPlayground(PlayingGround);
            InputView.PrintGameInstruction();
        }
Пример #3
0
        public void TimerTick(object sender, ElapsedEventArgs eventArgs)
        {
            PlayingGround.MoveVehicles();
            PlayingGround.SpawnNewCarts();

            OutputView.PrintPlayground(PlayingGround);

            if (!IsPlaying)
            {
                Timer.Stop();
                Timer.Dispose();

                OutputView.PrintEndGame(Score);
                return;
            }

            InputView.PrintGameInstruction();
        }