예제 #1
0
    /// <summary>
    /// Prints all objects in the inventory. Listed objects replace (ITEMS) in the default string.
    /// </summary>
    public void openInventory()
    {
        if (inventory.Count == 0)
        {
            textPrompt.printText(defaultValues.emptyInventoryText);
            openEquipment();
            return;
        }

        StringBuilder itemList = new StringBuilder();

        foreach (RoomObject obj in inventory)
        {
            itemList.Append(obj.name + ", ");
        }
        itemList.Remove(itemList.Length - 2, 2);

        string inv = defaultValues.occupiedInventoryText.Replace("(ITEMS)", itemList.ToString());

        textPrompt.printText(inv);

        openEquipment();
    }
예제 #2
0
    public void printCurrentLookText()
    {
        string lookText = currentRoom.runtimeLookText;

        if (System.String.IsNullOrEmpty(lookText))
        {
            textPrompt.printText("(You forgot to add Room Look Text for this room)");
        }
        else
        {
            textPrompt.printText(lookText);
        }
    }
예제 #3
0
    /// <summary>
    /// Scrapes user input to find commands and the object referenced and directs it to ActionHandler.
    /// </summary>
    /// <param name="input">The user's input</param>
    public void parseInput(string input)
    {
        string[] words = trimText(input);

        // Player commands are separate from regular commands because actions are in the Player script rather than ActionHandler
        // and regular commands need a minimum of 2 words to work whereas player commands (like "inv") can be one word.
        // Check player commands. If one activates, return.

        string failText = defaultValues.unknownCommand;

        if (words.Length == 0)
        {
            textPrompt.printText(failText);
            return;
        }

        string     command      = words[0];
        RoomObject targetObject = findObjectFromInput(input);

        // parsePlayerCommands needs input to scrape room name from input when player moves.
        bool playerCommandSuccess = parsePlayerCommands(command, input);

        if (playerCommandSuccess)
        {
            return;
        }

        if (words.Length == 1)
        {
            //textPrompt.printText(failText);
            roomTracker.changeRoomViaRoomConnection(input);
            return;
        }

        // Regular Commands: Eat, Talk, Kill, Sit, Use, Pickup, Wear
        parseRegularCommands(command, targetObject);
    }
예제 #4
0
    public void eatObject(RoomObject obj)
    {
        if (defaultValues.eatActive)
        {
            if (obj == null)
            {
                textPrompt.printText(defaultValues.edibleNotFoundText);
                return;
            }

            string defaultSuccessText = defaultValues.edibleSuccessText.Replace("(NAME)", obj.name);
            string defaultFailText    = defaultValues.edibleFailText.Replace("(NAME)", obj.name);
            doGenericAction(obj, defaultSuccessText, defaultFailText, ref obj.runtimeEdibleFlavorText, obj.runtimeIsEdible, obj.edibleVars);
        }
        else
        {
            textPrompt.printText(defaultValues.unknownCommand);
        }
    }