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("move [north,south,west,east]"); TextBuffer.Add("look"); TextBuffer.Add("drop"); TextBuffer.Add("pickup"); TextBuffer.Add("inventory"); 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.Item.Add(item); TextBuffer.Add("The " + ItemName + " Has been droped"); } else { TextBuffer.Add("You Don't Have an Item Named: " + ItemName); } }
public static void ProcessCommand(string line) { string command = TextUtilils.ExtractCommand(line.Trim()).Trim().ToLower(); string arguments = TextUtilils.ExtractArgueMent(line.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 "whereami": Player.GetCurrentRoom().ShowTitle(); break; default: TextBuffer.Add("Not a Valid Command"); 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 Can't Carry More!"); return; } room.Item.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); }
//Public Methods public void Describe() { TextBuffer.Add(this.description); TextBuffer.Add(this.getItemList()); TextBuffer.Add(this.getExitList()); }