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); }
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()); }
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."); }
public Game(DoublyLinkedMatrix board) { view = new GameViewModel(this); Board = board; player = board.player; }