public void MoveTo(Forklifttruck forklifttruck) { Console.WriteLine("Wall"); }
public void loadPlayfield(int level) { // convert level to objects of right classes string[] lines; String startupPath = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.FullName.ToString(); try { lines = System.IO.File.ReadAllLines((@"" + startupPath + "/Sokoban/Doolhoffen/doolhof" + level + ".txt")); } catch (DirectoryNotFoundException dirNotFound) { Console.WriteLine("File not found, cannot execute Sokoban. Sorry!"); Console.WriteLine("Press any key to stop Sokoban."); Console.ReadLine(); System.Environment.Exit(1); return; } bool isFirstCharAndLine = true; bool isFirstLine = true; bool isFirstChar = true; foreach (string line in lines) { isFirstChar = true; foreach (char c in line) { Tile newTile; switch (c) { case '~': //val newTile = new Trap(); break; case '#': // muur newTile = new Wall(); break; case '.': // vloer newTile = new Floor(); break; case 'o': // krat newTile = new Floor(); newTile.MoveableObject = new Box(newTile); break; case 'x': // bestemming newTile = new Destination(); break; case '@': // truck newTile = new Floor(); Forklifttruck = new Forklifttruck(newTile); newTile.MoveableObject = Forklifttruck; break; default: // Empty aanmaken newTile = new Empty(); break; } if (isFirstLine) { if (isFirstCharAndLine) { map.First = newTile; map.Current = map.First; isFirstCharAndLine = false; } else { map.Current.RightTile = newTile; newTile.LeftTile = map.Current; map.Current = map.Current.RightTile; } } else { if (isFirstChar) { Tile currentTile = map.First; while (currentTile.LowerTile != null) { currentTile = currentTile.LowerTile; } currentTile.LowerTile = newTile; newTile.UpperTile = currentTile; map.Current = currentTile.LowerTile; isFirstChar = false; } else { map.Current.RightTile = newTile; newTile.LeftTile = map.Current; newTile.UpperTile = map.Current.UpperTile.RightTile; newTile.UpperTile.LowerTile = newTile; map.Current = map.Current.RightTile; } } } isFirstLine = false; } Console.WriteLine("\n"); Console.WriteLine(); }