Beispiel #1
0
        public int Run()
        {
            ConsoleKeyInfo keyInfo;
            UpdateStatus   updateStatus = UpdateStatus.None;

            do
            {
                updateStatus = UpdateStatus.None;

                CurrentGameViewControler.Draw(CurrentGameData, CurrentPlayerData);

                while (!Console.KeyAvailable)
                {
                    Thread.Yield();
                }

                keyInfo = Console.ReadKey(true);

                updateStatus = CurrentGameViewControler.ProcessGameKeyPress(keyInfo.Key);

                switch (updateStatus)
                {
                case UpdateStatus.Error:
                    CurrentGameViewControler.ShowError();
                    break;

                case UpdateStatus.Hit:
                    CurrentGameViewControler.ShowHit();
                    break;

                case UpdateStatus.ShowHelp:
                    CurrentDisplayedView     = GameViews.HelpView;
                    CurrentGameViewControler = new HelpViewControler();
                    break;

                case UpdateStatus.ShowSettings:
                    CurrentDisplayedView     = GameViews.SettingsView;
                    CurrentGameViewControler = new SettingsViewControler();
                    break;

                case UpdateStatus.Reset:
                    Reset();
                    CurrentDisplayedView     = GameViews.GameView;
                    CurrentGameViewControler = GameViewControler;
                    CurrentGameViewControler.ShowHit();
                    break;

                case UpdateStatus.Close:
                    CurrentDisplayedView     = GameViews.GameView;
                    CurrentGameViewControler = GameViewControler;
                    break;
                }
            } while (updateStatus != UpdateStatus.Terminate);
            return(0);
        }
Beispiel #2
0
 public SettingsView(SettingsViewControler view)
 {
     ViewControler = view;
 }