예제 #1
0
파일: Controller.cs 프로젝트: A3vk/Sokoban
        public Controller()
        {
            Parser    = new Parser();
            InputView = new InputView();

            OutputView = new OutputView();
            OutputView.DisplayMenu();

            while (true)
            {
                ConsoleKeyInfo input = InputView.WaitForInput();
                if (input.Key != ConsoleKey.S)
                {
                    int.TryParse(input.KeyChar.ToString(), out int number);
                    if (number >= 1 && number <= 6)
                    {
                        CurrentMaze = number;
                        break;
                    }
                }
                else
                {
                    return;
                }
            }

            Maze = Parser.ParseMaze(CurrentMaze);
            Start();
        }
예제 #2
0
 public Game()
 {
     DesFieldCounter = 0;
     WinCounter      = 0;
     Player          = new Player();
     Employee        = new Employee();
     parser          = new Parser();
     _outputView     = new OutputView();
     _inputView      = new InputView(this);
     _outputView.StartMessage();
     Level = _inputView.ChooseMaze();
     parser.CreateMaze(Level, Player, this, Employee);
     FirstField = parser.firstField2;
     Play();
 }
예제 #3
0
파일: Controller.cs 프로젝트: A3vk/Sokoban
        private void Start()
        {
            while (true)
            {
                DisplayMaze();

                ConsoleKeyInfo input = InputView.WaitForInput();

                switch (input.Key)
                {
                case ConsoleKey.S:
                    return;

                case ConsoleKey.R:
                    Maze = Parser.ParseMaze(CurrentMaze);
                    break;

                case ConsoleKey.UpArrow:
                    Maze.Forklift.Move(Dir.UP);
                    Maze.Employee.DoSomething();
                    break;

                case ConsoleKey.RightArrow:
                    Maze.Forklift.Move(Dir.RIGHT);
                    Maze.Employee.DoSomething();
                    break;

                case ConsoleKey.DownArrow:
                    Maze.Forklift.Move(Dir.DOWN);
                    Maze.Employee.DoSomething();
                    break;

                case ConsoleKey.LeftArrow:
                    Maze.Forklift.Move(Dir.LEFT);
                    Maze.Employee.DoSomething();
                    break;
                }

                if (CheckWin())
                {
                    break;
                }
            }

            OutputView.DisplayVictory();
            Console.ReadKey();
        }
예제 #4
0
파일: Controller.cs 프로젝트: A3vk/Sokoban
        private void DisplayMaze()
        {
            String output = "";

            Tile head = Maze.Head;

            Tile currentTile = head;

            while (head != null)
            {
                while (currentTile != null)
                {
                    output     += currentTile.Description;
                    currentTile = currentTile.East;
                }

                output     += "\n";
                head        = head.South;
                currentTile = head;
            }

            OutputView.DisplayMaze(output);
        }
예제 #5
0
 //constructor
 public Game()
 {
     inputView  = new InputView();
     outputView = new OutputView();
     Parser parser;
 }
예제 #6
0
 public Controller()
 {
     inputView  = new InputView();
     outputView = new OutputView();
     parser     = new Parser();
 }
예제 #7
0
파일: Parser.cs 프로젝트: Sklomp1/Sokoban
 public Parser()
 {
     outputView = new OutputView();
 }
예제 #8
0
        public void print()
        {
            OutputView p = new OutputView();

            p.StandardScreen(firstField2, levelWidth, levelHeight);
        }