コード例 #1
0
    void SetCurrentNode(int locationNum) //get the current node based on locationNum
    {
        print(locationNum);

        locationIndex = locationNum - 1;                                     //remove one from the location to match position in the jsonArray (ie, location 1 is 0 in the array)

        currentNode = new ZorkNode();                                        //make a new ZorkNode

        currentNode.locationNum = locationIndex;                             //set the location num
        currentNode.eLocation   = jsonArray[locationIndex][JSON_EAST].AsInt; //set up all 4 directions
        currentNode.wLocation   = jsonArray[locationIndex][JSON_WEST].AsInt;
        currentNode.sLocation   = jsonArray[locationIndex][JSON_SOUTH].AsInt;
        currentNode.nLocation   = jsonArray[locationIndex][JSON_NORTH].AsInt;
        currentNode.storyText   = jsonArray[locationIndex][JSON_TEXT]; //set the text for this location
    }
コード例 #2
0
    void UpdateUI(ZorkNode currentNode)    //update the UI based on currentNode
    {
        text.text = currentNode.storyText; //set the text to the storyText in currentNode

        //if currentNode for a location is 0, that means there is no json location for that direction, so turn off the button
        if (currentNode.eLocation == 0)
        {
            eButton.SetActive(false);
        }
        else //if there is a number, turn it back on
        {
            eButton.SetActive(true);
        }


        if (currentNode.wLocation == 0)
        {
            wButton.SetActive(false);
        }
        else
        {
            wButton.SetActive(true);
        }


        if (currentNode.nLocation == 0)
        {
            nButton.SetActive(false);
        }
        else
        {
            nButton.SetActive(true);
        }


        if (currentNode.sLocation == 0)
        {
            sButton.SetActive(false);
        }
        else
        {
            sButton.SetActive(true);
        }
    }