예제 #1
0
 public Room GetJoiningRoom(Exit exit)
 {
     if (exit.Room1.Equals(this))
     {
         return exit.Room2;
     }
     else
     {
         return exit.Room1;
     }
 }
예제 #2
0
 // change to current location to another one
 private void moveToLocation(Exit targetExit)
 {
     // if that exit isn't locked
     if (targetExit.Key == null)
     {
         currentLocation = targetExit.getLeadsTo();
         showLocation();
         #if ANNOYING
         Console.Beep();
         #endif
     }
     else
     {
         Console.WriteLine("That exit is Locked");
     }
 }
예제 #3
0
        private void readMapFile()
        {
            string line;

            try
            {
                StreamReader sr = new StreamReader("C:\\Users\\Steve\\Source\\Repos\\OurTextBasedAdventure\\Resources\\consoleMap.txt");
                if (isDebug)
                {
                    Console.Write(".");
                }

                // read first line,  should start with R
                line = sr.ReadLine();

                // read until end of file;
                while (line != null)
                {
                    // this is room
                    if (isDebug)
                    {
                        Console.WriteLine(line);
                    }
                    Location tempLocation = new Location(line);
                    line = sr.ReadLine();
                    if (isDebug)
                    {
                        Console.Write(".");
                    }

                    // read next lines until not I
                    line = sr.ReadLine();
                    while (line.StartsWith("I"))
                    {
                        if (isDebug)
                        {
                            Console.WriteLine(line);
                        }
                        Item tempItem = new Item(line);
                        tempLocation.addItem(tempItem);

                        line = sr.ReadLine();
                        if (isDebug)
                        {
                            Console.Write(".");
                        }
                    }
                    // read next line until not E
                    while (line != null && line.StartsWith("E"))
                    {
                        if (isDebug)
                        {
                            Console.WriteLine(line);
                        }
                        Exit tempexit = new Exit(line);
                        tempLocation.addExit(tempexit);
                        line = sr.ReadLine();
                        if (isDebug)
                        {
                            Console.Write(".");
                        }
                    }

                    Map.Add(tempLocation);
                    if (isDebug)
                    {
                        Console.Write(".");
                    }

                    // move to next room or end of file.
                }
            }
            catch (FileNotFoundException fnfe)
            {
                Console.WriteLine("file was not found");
                Console.WriteLine(fnfe.Message);
            }
            catch (DirectoryNotFoundException dnfe)
            {
                Console.WriteLine("directory was not found");
                Console.WriteLine(dnfe.Message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("something unexpected happened");
                Console.WriteLine(ex.Message);
            }
        }
 public void addExit(Exit exit)
 {
     exits.Add(exit);
 }
예제 #5
0
 public Exit(int x, int y, bool enterable, bool locked, Room outroom, Room inroom, Exit oout = null) : base(x, y, locked ? "Locked Door" : "Door", inroom, true, locked ? 'Ø' : 'O') //Creates an Exit at (x,y) named "Exit" in the present room is navigable and is seen as "D"
 {
     //Sets the room you come in from and where you go out to
     Enterable = enterable;
     OutRoom = outroom;
     InRoom = inroom;
     Out = oout;
     Locked = locked;
 }