public void addUsables(Usables usableToAdd) { usables.Add(usableToAdd); }
//Most of the instances of classes in the game are declared in this instance of the game class. public Game() { //Clear the inventories. Prevents leftovers from previous games. inventory = new List <Item>(); usables = new List <Usables>(); //Quick scene setter. Dark red is used to represent story elements. Console.ForegroundColor = ConsoleColor.DarkRed; Console.WriteLine("The lift has stopped. You are trapped."); Console.ResetColor(); // build the "map" lDoors = new Location("Facing Forward.", "You are facing the doors to the lift."); lPanel = new Location("Facing Left.", "You are facing the lift panel."); //Adds instances of Usables for players to interact with later. Usables alarm = new Usables("alarm"); Usables floor1 = new Usables("floor1"); Usables floor2 = new Usables("floor2"); Usables floor3 = new Usables("floor3"); Usables openDoors = new Usables("opendoors"); Usables closeDoors = new Usables("closedoors"); lPanel.addUsables(alarm); lPanel.addUsables(floor1); lPanel.addUsables(floor2); lPanel.addUsables(floor3); lPanel.addUsables(openDoors); lPanel.addUsables(closeDoors); lFloor = new Location("Facing Down.", "You are facing the floor. The unconscious body of a fellow traveller lies there, starved of oxygen."); lBack = new Location("Facing the rear.", "You are facing the back of the lift. There is a hole in the panel."); Usables maintenance = new Usables("maintenance"); lRight = new Location("Facing right.", "You are facing the right of the lift."); lCeiling = new Location("Facing the ceiling", "You are facing upwards. You can see a small panel in the top of the lift."); lDoors.addExit(new Exit(Exit.Directions.Right, lRight)); lDoors.addExit(new Exit(Exit.Directions.Left, lPanel)); lDoors.addExit(new Exit(Exit.Directions.Down, lFloor)); lDoors.addExit(new Exit(Exit.Directions.Up, lCeiling)); lRight.addExit(new Exit(Exit.Directions.Right, lBack)); lRight.addExit(new Exit(Exit.Directions.Left, lDoors)); lRight.addExit(new Exit(Exit.Directions.Down, lFloor)); lRight.addExit(new Exit(Exit.Directions.Up, lCeiling)); lBack.addExit(new Exit(Exit.Directions.Right, lPanel)); lBack.addExit(new Exit(Exit.Directions.Left, lRight)); lBack.addExit(new Exit(Exit.Directions.Down, lFloor)); lBack.addExit(new Exit(Exit.Directions.Up, lCeiling)); lPanel.addExit(new Exit(Exit.Directions.Right, lDoors)); lPanel.addExit(new Exit(Exit.Directions.Left, lBack)); lPanel.addExit(new Exit(Exit.Directions.Down, lFloor)); lPanel.addExit(new Exit(Exit.Directions.Up, lCeiling)); lFloor.addExit(new Exit(Exit.Directions.Up, lDoors)); lCeiling.addExit(new Exit(Exit.Directions.Down, lDoors)); //Assign default values to the location variables. currentLocation = lDoors; locationCurrent = "lDoors"; currentFloor = "floor 1"; showLocation(); }