Beispiel #1
0
    private bool ParseJSONDemo()
    {
        PathReader pr;

        try
        {
            pr = new PathReader(Path.Combine(Application.dataPath, JSONFileName));
        }
        catch (Exception e) {
            Debug.Log(e.Message);
            return(false);
        }
        pr.setPathId(2);
        pr.printBookWithLocation(pr.getBookWithLocation(2));
        return(true);
    }
    // Update is called once per frame
    void Update()
    {
        //if (Input.GetKeyDown(KeyCode.UpArrow) && bookNum < pr.getNumberOfBooksInPath() - 1)
        if ((Input.GetKeyDown(KeyCode.Joystick1Button0) || Input.GetKeyDown(KeyCode.Joystick2Button0)) && bookNum < pr.getNumberOfBooksInPath() - 1)
        {
            BookWithLocation bookInfo     = pr.getBookWithLocation(bookNum);
            TextMesh         bookInfoText = bookText.GetComponent <TextMesh>();
            bookInfoText.text = "Title: ";
            wrapText(bookInfo.book.title);
            bookInfoText.text = bookInfoText.text + "\nAuthor: ";
            wrapText(bookInfo.book.author);

            if (!isShelfViewActive)
            {
                shelf.SetActive(true);
                shelf.GetComponent <ChangeShelfBlock>().highlightBlock(bookInfo.book.tag);
                shelf.SetActive(false);
            }
            else
            {
                shelf.GetComponent <ChangeShelfBlock>().highlightBlock(bookInfo.book.tag);
            }
            if (!isBookInfoActive)
            {
                book.SetActive(true);
                changeShelfHighlight(bookInfo.book.tag);
                book.SetActive(false);
            }
            else
            {
                changeShelfHighlight(bookInfo.book.tag);
            }
            bookNum += 1;
        }
        //if (Input.GetKeyDown(KeyCode.DownArrow))
        if ((Input.GetKeyDown(KeyCode.Joystick1Button1) || Input.GetKeyDown(KeyCode.Joystick2Button1)))
        {
            isBookInfoActive  = !isBookInfoActive;
            isShelfViewActive = !isShelfViewActive;
            book.SetActive(isBookInfoActive);
            shelf.SetActive(isShelfViewActive);
        }
    }
    private void pathIdSelectionControl()
    {
        if (Input.GetKeyDown(KeyCode.C) || Input.GetKeyDown(KeyCode.Joystick2Button1))
        {
            pathIdSelectionView.GetComponent <PathIdSelectionView>().selectNext();
        }
        else if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.Joystick2Button2))
        {
            pathIdSelectionView.GetComponent <PathIdSelectionView>().selectLast();
        }
        else if (Input.GetKeyDown(KeyCode.B) || Input.GetKeyDown(KeyCode.Joystick2Button3))
        {
            selectedPathId = pathIdSelectionView.GetComponent <PathIdSelectionView>().getSelectedPathId();

            currentActiveView.SetActive(false);
            bookInfoView.SetActive(true);
            currentActiveView = bookInfoView;
            // setup the next view

            /*if (selectedPathId != pr.getPathId())
             * {*/
            bookPicked = new bool[pr.getNumberOfBooksInPath()];
            for (int i = 0; i < bookPicked.Length; i++)
            {
                bookPicked[i] = false;
            }
            pr.setPathId(selectedPathId);
            numOfPickedBook = 0;
            selectedBookNum = 0;

            //}
            bookInfoView.GetComponent <BookInfoView>().highlightBookInfo(pr.getBookWithLocation(selectedBookNum));
        }
        else if (Input.GetKeyDown(KeyCode.F) || Input.GetKeyDown(KeyCode.Joystick2Button0))
        {
            currentActiveView.SetActive(false);
            phaseSelectionView.SetActive(true);
            currentActiveView = phaseSelectionView;
        }
    }