예제 #1
0
        public static void DisplayInventory()
        {
            string message   = "Your inventory contains:";
            string items     = "";
            string underline = "";

            underline = underline.PadLeft(message.Length, '-');

            int health = Player.Health;

            TextBuffer.Add("Health: " + health + "/32\n\n");

            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);
        }
예제 #2
0
        //Commands Below

        //Command to view an items description that they have in their inventory that is in the room
        public static void Examine(string itemName)
        {
            Room   room      = Player.GetCurrentRoom();
            Item   item      = Player.GetInventoryItem(itemName);
            Item   rmitem    = room.GetItem(itemName);
            string underline = "";

            underline = underline.PadLeft(itemName.Length, '-');

            if (itemName != null)
            {
                if (item != null)
                {
                    TextBuffer.Add(itemName + ":" + "\n" + underline + "\n\n" + item.Description);
                }
                else if (room.GetItem(itemName) != null)
                {
                    TextBuffer.Add(itemName + ":" + "\n" + underline + "\n\n" + rmitem.Description);
                }
                else
                {
                    TextBuffer.Add("Please type a valid item that is in your inventory or room to examine.");
                }
            }
            else
            {
                TextBuffer.Add("Please type a valid item that is in your inventory or room to examine.");
            }
        }
예제 #3
0
        //Function which is for movement
        public static void Go(string direction)
        {
            Room room = Player.GetCurrentRoom();

            if (!room.CanExit(direction))
            {
                TextBuffer.Add("Invalid Direction");
                return;
            }

            Player.moves++;

            switch (direction)
            {
            case Direction.Up:
                posY--;
                break;

            case Direction.Down:
                posY++;
                break;

            case Direction.Right:
                posX++;
                break;

            case Direction.Left:
                posX--;
                break;
            }

            Player.GetCurrentRoom().Describe();
        }
예제 #4
0
        //Public Methods

        public void Describe()
        {
            //Debug Util - Display coords at top
            TextBuffer.Add(this.GetCoord());
            //--------
            TextBuffer.Add(this.description);
            TextBuffer.Add(this.GetItemList());
            TextBuffer.Add(this.GetExitList());
        }
예제 #5
0
        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("You dropped " + itemName + " into this room.");
            }
            else
            {
                TextBuffer.Add("There is no " + itemName + " in your inventory");
            }
        }
예제 #6
0
        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("Your inventory has exceeded the weight limit, please drop an item first.");
                    return;
                }
                TextBuffer.Add(item.PickUpText);
                room.Items.Remove(item);
                Player.inventoryItems.Add(item);
            }
            else
            {
                TextBuffer.Add("There is no " + itemName + " in this room.");
            }
        }
예제 #7
0
        public static void ProcessCommand(string input)
        {
            string command   = TextUtils.ExtractCmd(input.Trim()).Trim().ToLower();
            string arguement = TextUtils.ExtractArgs(input.Trim().Trim().ToLower());

            if (Direction.isValidDirection(command))
            {
                Player.Go(command);
            }
            else
            {
                switch (command)
                {
                case "exit":
                    Program.exit = true;
                    return;

                case "help":
                    ShowHelp();
                    break;

                case "examine":
                    Player.Examine(arguement);
                    break;

                case "move":
                    Player.Go(arguement);
                    break;

                case "look":
                    Player.GetCurrentRoom().Describe();
                    break;

                case "pickup":
                    Player.PickupItem(arguement);
                    break;

                case "pickupall":     //Not built in to engine.
                    Player.PickupAll();
                    break;

                case "drop":
                    Player.DropItem(arguement);
                    break;

                case "inventory":
                    Player.DisplayInventory();
                    break;

                case "whereami":
                    Player.GetCurrentRoom().ShowTitle();
                    break;

                case "use":
                    Player.Use(arguement);     //Not built into engine
                    break;

                default:
                    TextBuffer.Add("Input not understood.");
                    break;
                }
                GameManager.ApplyRules();
                TextBuffer.Display();
            }
        }
예제 #8
0
 public void ShowTitle()
 {
     TextBuffer.Add(this.title);
 }