// Public Methods #region Public Methods public void Describe() { TextBuffer.Add(this.GetCoordinates()); TextBuffer.Add(this.description); TextBuffer.Add(this.GetItemList()); TextBuffer.Add(this.GetExitList()); }
public static void Move(string direction) { Room room = Player.GetCurrentRoom(); if (!room.CanExit(direction)) { TextBuffer.Add("Invalid Direction"); return; } Player.moves++; switch (direction) { case Direction.North: posY--; break; case Direction.South: posY++; break; case Direction.East: posX++; break; case Direction.West: posX--; break; } Player.GetCurrentRoom().Describe(); }
public static void ShowHelp() { TextBuffer.Add("Available Commands:"); TextBuffer.Add("--------------------"); TextBuffer.Add("help"); TextBuffer.Add("exit"); TextBuffer.Add("move(north south,east,west)"); TextBuffer.Add("pickup"); TextBuffer.Add("look"); TextBuffer.Add("inventory"); TextBuffer.Add("drop"); TextBuffer.Add("whereami"); }
public static void DropItem(string itemName) { Room room = Player.GetCurrentRoom(); Item item = GetInventoryItem(itemName); if (item != null) { Player.inventoryItems.Remove(item); room.Items.Add(item); TextBuffer.Add("The" + itemName + " has been dropped into this room"); } else { TextBuffer.Add("There is no " + itemName + " in your inventory"); } }
public static void ProcessCommand(string line) { string command = TextUtils.ExtractCommand(line.Trim()).Trim().ToLower(); string arguments = TextUtils.ExtractArguments(line.Trim()).Trim().ToLower(); switch (command) { case "exit": Program.quit = true; return; case "help": ShowHelp(); break; case "move": Player.Move(arguments); break; case "look": Player.GetCurrentRoom().Describe(); break; case "pickup": Player.PickupItem(arguments); break; case "drop": Player.DropItem(arguments); break; case "inventory": Player.DisplayInventory(); break; case "wherami": Player.GetCurrentRoom().ShowTitle(); break; default: TextBuffer.Add("Input not understood"); break; } GameManager.ApplyRules(); TextBuffer.Display(); }
public static void PickupItem(string itemName) { Room room = Player.GetCurrentRoom(); Item item = room.GetItem(itemName); if (item != null) { if (Player.InventoryWeight + item.Weight > Player.weightCapacity) { TextBuffer.Add("You must first drop some weight before you can pick up this item"); return; } room.Items.Remove(item); Player.inventoryItems.Add(item); TextBuffer.Add(item.PickupText); } else { TextBuffer.Add("There is no " + itemName + " in this room."); } }
public static void DisplayInventory() { string message = "Your Inventory contains:"; string items = ""; string underline = ""; underline = underline.PadLeft(message.Length, '-'); if (inventoryItems.Count > 0) { foreach (Item item in inventoryItems) { items += "\n[" + item.Title + "] Wt: " + item.Weight.ToString(); } } else { items = "\n<no items>"; } items += "\n\nTotal Wt: " + Player.InventoryWeight + " / " + Player.WeightCapacity; TextBuffer.Add(message + "\n" + underline + items); }
public void ShowTitle() { TextBuffer.Add(this.title); }