예제 #1
0
        // Public Methods
        #region Public Methods

        public void Describe()
        {
            TextBuffer.Add(this.GetCoordinates());
            TextBuffer.Add(this.description);
            TextBuffer.Add(this.GetItemList());
            TextBuffer.Add(this.GetExitList());
        }
예제 #2
0
파일: Player.cs 프로젝트: smtzr/Hyperion
        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();
        }
예제 #3
0
 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");
 }
예제 #4
0
파일: Player.cs 프로젝트: smtzr/Hyperion
        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");
            }
        }
예제 #5
0
        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();
        }
예제 #6
0
파일: Player.cs 프로젝트: smtzr/Hyperion
        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.");
            }
        }
예제 #7
0
파일: Player.cs 프로젝트: smtzr/Hyperion
        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);
        }
예제 #8
0
 public void ShowTitle()
 {
     TextBuffer.Add(this.title);
 }