Example #1
0
        public Boolean PrintMaze(NonMoveableGameObject first)
        {
            Console.Clear();
            NonMoveableGameObject current = first;

            finished = true;
            while (current.Down != null)      // Loop down the list
            {
                while (current.Right != null) // Loop to the last item
                {
                    finished = PrintSymbol(current);
                    current  = current.Right;
                }
                finished = PrintSymbol(current);
                while (current.Left != null) // Loop back to begin
                {
                    current = current.Left;
                }
                System.Console.WriteLine("");
                current = current.Down;
            }
            while (current.Right != null) // Loop to the last item
            {
                finished = PrintSymbol(current);
                current  = current.Right;
            }
            finished = PrintSymbol(current);
            return(finished);
        }
Example #2
0
 public Boolean PrintSymbol(NonMoveableGameObject current)
 {
     if (current.GetType().Name == "Destination" && !current.IsActive)
     {
         finished = false;
     }
     if (current.Player != null)
     {
         System.Console.Write(GetSymbol("Player"));
     }
     else if (current.GetType().Name == "Destination" && current.IsActive)
     {
         System.Console.Write("0");
     }
     else if (current.Crate != null)
     {
         System.Console.Write(GetSymbol("Crate"));
     }
     else
     {
         System.Console.Write(GetSymbol(current.GetType().Name));
     }
     return(finished);
 }
Example #3
0
        public Maze ReadFile()
        {
            _maze = new Maze();

            String LevelPath = @"Doolhof\doolhof" + _level + ".txt";

            String[] readString = System.IO.File.ReadAllLines(LevelPath);

            int width  = 0;
            int height = readString.Length;

            for (int i = 0; i < height; i++) // Pak de langste lengte die een lijn in het tekstbestand heeft
            {
                if (readString[i].Length > width)
                {
                    width = readString[i].Length;
                }
            }

            NonMoveableGameObject[,] levelArray = new NonMoveableGameObject[width, height];
            for (int y = 0; y < height; y++) // Full Multidimensional Array
            {
                for (int x = 0; x < width; x++)
                {
                    try
                    {
                        NonMoveableGameObject tempObject = null;
                        switch (readString[y].ElementAt(x))
                        {
                        case '.':
                            tempObject = new Floor();
                            break;

                        case '#':
                            tempObject = new Wall();
                            break;

                        case 'o':
                            tempObject       = new Floor(); // Plaats crate hierin
                            tempObject.Crate = new Crate();
                            break;

                        case 'x':
                            tempObject = new Destination();
                            break;

                        case '@':
                            tempObject        = new Floor();
                            tempObject.Player = new Player();
                            break;

                        default:
                            tempObject = new Empty();
                            break;
                        }
                        levelArray[x, y] = tempObject;
                    }
                    catch
                    {
                        NonMoveableGameObject tempObject = new Empty();
                        levelArray[x, y] = tempObject;
                    }
                }
            }
            _maze.InitMaze(levelArray, width, height);
            return(_maze);
        }