Exemplo n.º 1
0
 void AddToInventory(Item item)
 {
     CurrentPlayer.Inventory.Add(item);
     CurrentRoom.Items.Remove(item);
 }
Exemplo n.º 2
0
        public void Setup()
        {
            BuildRooms();
            void BuildRooms()
            {
                Rooms = new List <Room>();

                Room Room0 = new Room("Storage Room 0", description: "--A single skylight, cracked and yellowing from age, provides barely enough light to see that you are in some sort of dilapidated storage room.\nTwo rows of metal shelves stand near the wall to your right (east). A heap of black garbage bags lay against the opposing wall.")
                {
                    DescriptionE = @"--After allowing your eyes to adjust to the low light, you think you can make out what looks like a metal pipe, roughly forearm-length and capped at one end.",
                    DescriptionW = @"--Using your hands to feel around the trash bags, you hear something small and metal fall onto the concrete floor.",
                    DescriptionN = "--A door leading out of the storage room",
                    DescriptionS = "--A simple white brick wall. Squinting your eyes, you can see an externally mounted electrical outlet near the bottom of the wall.",
                    Items        = new List <Item>(),

                    Exits = new Dictionary <string, Room>()
                };
                Room Room1 = new Room(name: "Corridor 1", description: "--You find yourself in a dark corridor, leading East and nowhere else.")
                {
                    DescriptionN = "This is the north wall of Corridor 1",
                    Items        = new List <Item>(),
                    Exits        = new Dictionary <string, Room>()
                };
                Room Room2 = new Room(name: "Altar Room", description: "--A musty and dark semicircular room. Across from you stands a large stone slab flanked by two lit braziers. To your right, there is a large wooden door.")
                {
                    Items = new List <Item>(),
                    Exits = new Dictionary <string, Room>()
                };
                Room Room3 = new Room(name: "Antechamber", description: "--As soon as you set foot on the hard dirt floor, you look in front of you at a seemingly endless tunnel lit by hundreds of rusted iron wall sconces. Suddenly, you think you see the darkness far at the end of tunnel begin to swell and move toward you. Your blood freezes cold in your veins. Petrified by an overwhelming sense of inescapable dread, your gaze remains transfixed on the abyss growing before you. The tunnel is now only lit about fifty yards in front of you, and the ground begins to shake. Thirty yards now. In a matter of seconds the roaring stygial blackness splits your eardrums and deafens you to your own terrified screams as the last of the tunnel's light extinguishes.")
                {
                    Items = new List <Item>(),
                    Exits = new Dictionary <string, Room>()
                };

                AddRooms();
                BuildItems();
                AddExits();
                void AddRooms()
                {
                    Rooms.Add(Room0);
                    Rooms.Add(Room1);
                    Rooms.Add(Room2);
                    Rooms.Add(Room3);
                }

                void AddExits()
                {
                    // Room0.Exits.Add("north", Room1);
                    Room1.Exits.Add("south", Room0);
                    Room1.Exits.Add("east", Room2);
                    Room2.Exits.Add("west", Room1);
                    Room2.Exits.Add("south", Room3);
                    Room3.Exits.Add("north", Room2);
                }

                void BuildItems()
                {
                    Item pipe    = new Item("pipe", "--A metal pipe, about forearm-length and capped on one end.");
                    Item bentKey = new Item("bent key", "--A small brass key that is bent just slightly.");

                    Room0.Items.Add(pipe);
                    Room0.Items.Add(bentKey);
                }

                CurrentRoom   = Room0;
                CurrentPlayer = new Player();
            }
        }
Exemplo n.º 3
0
        public void Play()
        {
            while (Playing)
            {
                Console.Clear();
                System.Console.WriteLine($"Greetings {CurrentPlayer.Name}. You are on level {CurrentRoom.Name}. Your point: {CurrentPlayer.Score}");
                if (CurrentPlayer.Inventory.Count > 0)
                {
                    System.Console.WriteLine("Your man-puse has:");
                    foreach (Item item in CurrentPlayer.Inventory)
                    {
                        System.Console.WriteLine(item.Name);
                    }
                }
                else
                {
                    System.Console.WriteLine("Your man-purse is empty.");
                }
                if (CurrentRoom.CanMove)
                {
                    System.Console.WriteLine(CurrentRoom.AlternateDescription);
                }
                else
                {
                    System.Console.WriteLine(CurrentRoom.Description);
                }

                string   Choice = Console.ReadLine();
                string[] Action = Choice.Split(' ');

                if (Action[0].ToLower() == "take" || Action[0].ToLower() == "t")
                {
                    Item TakeItem = FindItem(Action[1]);
                    if (TakeItem != null)
                    {
                        System.Console.WriteLine($"You have add a {TakeItem.Name} to your man-purse.");
                        string Pause1 = Console.ReadLine();
                        CurrentPlayer.Score++;
                    }
                    else
                    {
                        System.Console.WriteLine("No such item on this level");
                        string Pause = Console.ReadLine();
                    }
                }
                else if (Action[0].ToLower() == "go" || Action[0].ToLower() == "g")
                {
                    int RoomNum;
                    Int32.TryParse(CurrentRoom.Name, out RoomNum);
                    if (Action[1].ToLower() == "up" && CurrentRoom.CanMove)
                    {
                        if (Rooms[(RoomNum + 1).ToString()] != null)
                        {
                            CurrentRoom = Rooms[(RoomNum + 1).ToString()];
                            CurrentPlayer.Score++;
                        }
                    }
                    else if (Action[1].ToLower() == "up" && !CurrentRoom.CanMove)
                    {
                        System.Console.WriteLine("Can't move up yet.");
                    }
                    else if (Action[1].ToLower() == "down")
                    {
                        if (Rooms[(RoomNum - 1).ToString()] != null)
                        {
                            CurrentRoom = Rooms[(RoomNum - 1).ToString()];
                            CurrentPlayer.Score++;
                        }
                    }
                }
                else if (Action[0].ToLower() == "use" || Action[0].ToLower() == "u")
                {
                    System.Console.WriteLine($"{CurrentPlayer.Inventory.Contains(SearchInventory("sheers")).ToString()}");
                    if (Action[1] == CurrentRoom.MustDo)
                    {
                        CurrentRoom.CanMove = true;
                    }
                    else
                    {
                        foreach (Item item in CurrentPlayer.Inventory)
                        {
                            if (Action[1].ToLower() == item.Name)
                            {
                                CurrentRoom.HaveDone = item.Name;
                                if (CurrentRoom.HaveDone == CurrentRoom.MustDo)
                                {
                                    CurrentRoom.CanMove = true;
                                }
                                System.Console.WriteLine(item.Description);
                                string Pause = Console.ReadLine();
                            }
                        }
                    }
                    if (CurrentRoom.Name == "2")
                    {
                        if (Action[1] == "shovel" && CurrentPlayer.Inventory.Contains(SearchInventory("shovel")))
                        {
                            System.Console.WriteLine("You hit the sheep on the head with your shovel but that only makes the sheep angier and it headbutts you out the window.");
                            System.Console.WriteLine("Luckily you grab onto a rope as you're falling and you swing back into the 1st Level");
                            Console.ReadLine();
                            CurrentRoom = Rooms["1"];
                        }
                        else if (Action[1] == "sheers" && CurrentPlayer.Inventory.Contains(SearchInventory("sheers")))
                        {
                            CurrentRoom.CanMove = true;
                            System.Console.WriteLine("Being the smart adventurer that you are, you realize that the sheep is angry because its wool is way too fluffy.");
                            System.Console.WriteLine("You decide to use your sheers an shave the sheep. It is now happy and allows you to move to the next level.");
                            System.Console.WriteLine("As you are leaving you hear the sheep mutter something. The only words you caught were 'I find romance when I start to dance' and 'black'.");
                            Console.ReadLine();
                        }
                    }
                    if (CurrentRoom.Name == "3")
                    {
                        if (Action[1] == "1")
                        {
                            System.Console.WriteLine("You say 'Pickles are green and orangles are black, my left rear hoof is the shape of a seagul.' Instantly the all the candles and torches are lit.");
                            System.Console.WriteLine("You can now find the stairs to the next level.");
                        }
                    }
                    if (CurrentRoom.Name == "4" && Action[1].ToLower() != "boogie-wonderland")
                    {
                        System.Console.WriteLine("Thats not his favorite song and the Gnome King boops you on the head and you lose consciousness and are thrown out of the tower.");
                        Console.ReadLine();
                        Playing = false;
                    }
                }
                else if (Action[0].ToLower() == "help" || Action[0].ToLower() == "h")
                {
                    System.Console.WriteLine("To move levels: type 'go' + 'up/down'");
                    System.Console.WriteLine("To take item: type 'take' + 'item name'");
                    System.Console.WriteLine("To use item: type 'use' + 'item name'");
                    System.Console.WriteLine("To quit game: type 'quit'");
                    string Pause = Console.ReadLine();
                }
                else if (Action[0].ToLower() == "quit" || Action[0].ToLower() == "q")
                {
                    Playing = false;
                    System.Environment.Exit(0);
                }
            }
        }