/// <summary>
    ///  Attempting to change rooms
    /// </summary>
    /// <param name="directionNoun"></param>
    public void AttemptToChangeRooms(string directionNoun)
    {
        // If the exit exists
        if (exitDictionary.ContainsKey(directionNoun))
        {
            // Get the current room to the new room
            currentRoom = exitDictionary[directionNoun];

            // If the next room to change to is the exit to vn room, switch to vn
            if (currentRoom == VNSwitch.exitToVNRoom)
            {
                // This is the exit room. Exit to the VN
                VNSwitch.enterVN();
            }

            _controller.LogStringWithReturn("You head off to the " + directionNoun);

            // Displays the new room text
            _controller.DisplayRoomText();
        }
        else
        {
            int randInt = Random.Range(0, invalidStrings.Length + 1);

            // Prints random invalid message with invalid input
            if (randInt == 0)
            {
                _controller.LogStringWithReturn("You cant go " + directionNoun + ".");
            }
            else
            {
                _controller.LogStringWithReturn(invalidStrings[randInt]);
            }
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Checks if noun is in room so we can take it
    /// </summary>
    /// <param name="separatedInputWords"></param>
    /// <returns></returns>
    public Dictionary <string, string> takeItem(string[] separatedInputWords)
    {
        // stores the noun
        string noun = separatedInputWords[1];

        // If the room contains a noun, store it into the inventory
        if (nounsInRoom.Contains(noun))
        {
            nounsInInventory.Add(noun);
            AddActionResponsesToUseDictionary();
            nounsInRoom.Remove(noun);
            return(takeDictionary);
        }
        else
        {
            // It doesn't exist in this room
            int randInt = Random.Range(0, invalidStrings.Length + 1);

            if (randInt == 0)
            {
                _controller.LogStringWithReturn("There is no " + noun + " here to take.");
            }
            else
            {
                _controller.LogStringWithReturn(invalidStrings[randInt]);
            }

            return(null);
        }
    }
    public Room[] StoryRooms;           // Stores rooms for the story


    // Private variables
    //private bool _isInVN;
    //private bool _isInTA;



    #region public func


    /// <summary>
    /// Enters text adventure
    /// </summary>
    public void enterTA()
    {
        //_isInTA = true;
        //_isInVN = false;

        // Disable the VN stuff, enable TA stuff
        VN.SetActive(false);
        TA.SetActive(true);

        // Enter next room for dream world, ensure that it prints next room and everything
        _roomNav.currentRoom = StoryRooms[sleepTree.GetIntegerVariable("DayCount")];

        // Prints out tons of blank space
        _controller.LogStringWithReturn("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +
                                        "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

        // Prints new room text
        _controller.DisplayRoomText();
        _controller.DisplayLoggedText();

        // Reactivates the input field when enter/return is pressed
        _inputField.ActivateInputField();

        // Empties inputfield for the player
        _inputField.text = null;
    }
    /// <summary>
    ///
    /// NOTE: tuens all values in the string into lowercase to ensure that it doesn't get messed up by casinput by case.
    /// </summary>
    /// <param name="userInput"></param>
    private void AcceptStringInput(string userInput)
    {
        // Converts all values in userinput to lwercase
        userInput = userInput.ToLower();

        // Mirrors input back to player
        _controller.LogStringWithReturn(userInput);

        // checks the user input for basic 1 letter input
        switch (userInput)
        {
        case "n":
            userInput = "go north";
            break;

        case "s":
            userInput = "go south";
            break;

        case "e":
            userInput = "go east";
            break;

        case "w":
            userInput = "go west";
            break;

        case "u":
            userInput = "go up";
            break;

        case "d":
            userInput = "go down";
            break;
        }

        //Process input - Used to look for separating words will be spaces
        char[]   delimiterCharacters = { ' ' };
        string[] separatedInputWords = userInput.Split(delimiterCharacters);

        // finding input
        for (int i = 0; i < _controller.inputActions.Length; i++)
        {
            // Little bit of code so i the programmer dont need to do _controller.inputActions[i] every time
            InputAction inputAction = _controller.inputActions[i];

            // Using the verb noun style (go north), first word is verb
            // If keyword match
            if (inputAction.Keyword == separatedInputWords[0])
            {
                inputAction.RespondToInput(_controller, separatedInputWords);
            }
        }

        // Completes input
        InputComplete();
    }
    public override void RespondToInput(TxtAdvController controller, string[] separatedInputWords)
    {
        Dictionary <string, string> takeDict = controller.interactableItems.takeItem(separatedInputWords);

        // If the dict is not null
        if (takeDict != null)
        {
            controller.LogStringWithReturn(controller.testVerbDictionaryWithNoun(takeDict, separatedInputWords[0], separatedInputWords[1]));
        }
    }
 public override void RespondToInput(TxtAdvController controller, string[] separatedInputWords)
 {
     controller.LogStringWithReturn(controller.testVerbDictionaryWithNoun(controller.interactableItems.examineDictionary, separatedInputWords[0], separatedInputWords[1]));
 }