Esempio n. 1
0
        public DoublyLinkedMatrix CreateMaze(String level)
        {
            String[] LevelLines = level.Split(
                new[] { "\r\n", "\r", "\n" },
                StringSplitOptions.None
                );

            // Set up the matrix.
            var Matrix = new DoublyLinkedMatrix(MatrixItemsFromString(LevelLines[0]));

            // Add more Rows.
            for (int i = 1; i < LevelLines.Length; i++)
            {
                Matrix.AddRow(MatrixItemsFromString(LevelLines[i]));
            }
            return(Matrix);
        }
Esempio n. 2
0
        private MatrixItem[] getDestinations(DoublyLinkedMatrix matrix)
        {
            List <MatrixItem> destinations   = new List <MatrixItem>();
            MatrixItem        currentElement = matrix.Origin;

            while (currentElement.South != null)
            {
                var innerCurrentElement = currentElement;
                do
                {
                    if (innerCurrentElement.IsDestination)
                    {
                        destinations.Add(innerCurrentElement);
                    }
                    innerCurrentElement = innerCurrentElement.East;
                }while (innerCurrentElement.East != null);
                // Move one line lower
                currentElement = currentElement.South;
            }
            return(destinations.ToArray());
        }
Esempio n. 3
0
        public void Render()
        {
            System.Console.Clear();
            _board = _game.Board;
            MatrixItem leftHelper     = _board.Origin;
            MatrixItem currentElement = leftHelper;
            string     line;

            while (currentElement != null)
            {
                line = "";
                do
                {
                    if (currentElement.occupant == null)
                    {
                        if (currentElement.IsDestination)
                        {
                            line += 'x';
                        }
                        else
                        {
                            line += ".";
                        }
                    }
                    else
                    {
                        line += currentElement.occupant.view;
                    }
                    currentElement = currentElement.East;
                }while (currentElement != null);
                leftHelper     = leftHelper.South;
                currentElement = leftHelper;
                Console.WriteLine(line);
            }
            Console.WriteLine("");
            Console.WriteLine("Laat met de pijltjestoetsen de speler bewegen.");
        }
Esempio n. 4
0
 public Game(DoublyLinkedMatrix board)
 {
     view   = new GameViewModel(this);
     Board  = board;
     player = board.player;
 }