Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (camWaypointIndex == 0 && rotateAround)
        {
            mainCam.transform.RotateAround(Vector3.zero, Vector3.up, 10 * Time.deltaTime);
        }

        if (camWaypointIndex == 2 || camWaypointIndex == 4)
        {
            if (overlayPowerBook != null && overlayPowerBook.GetBookState() == PBook.BookState.CLOSED)
            {
                if (camWaypointIndex == 2)
                {
                    stepTexts [camWaypointIndex].SetActive(true);
                    overlayPowerBook.transform.position = overlayBookOriginalPos;
                    overlayPowerBook.transform.rotation = overlayBookOriginalRot;
                    overlayCam.gameObject.SetActive(false);
                }
                if (camWaypointIndex == 4)
                {
                    stepTexts [camWaypointIndex].SetActive(true);
                }
                exampleUIController.gameObject.SetActive(false);
                exampleUIController.pBook = null;
                overlayPowerBook          = null;
            }

            if (Input.GetMouseButtonDown(0) && overlayPowerBook == null)
            {
                RaycastHit hit;
                Ray        ray = mainCam.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit))
                {
                    if (hit.transform.parent.GetComponent <PBook> () != null)
                    {
                        overlayPowerBook = hit.transform.parent.GetComponent <PBook> ();
                        if (camWaypointIndex == 2)
                        {
                            BoxCollider bookCollider = (BoxCollider)hit.collider;
                            overlayBookOriginalPos = hit.transform.position;
                            overlayBookOriginalRot = hit.transform.rotation;
                            overlayPowerBook.transform.position = new Vector3((bookCollider.size.y / 2) - 0.005f, 0, 9.875f);
                            overlayPowerBook.transform.rotation = Quaternion.identity;
                            overlayCam.gameObject.SetActive(true);
                        }
                        overlayPowerBook.OpenBook();
                        exampleUIController.gameObject.SetActive(true);
                        exampleUIController.pBook = overlayPowerBook;
                        stepTexts [camWaypointIndex].SetActive(false);
                    }
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            NextWaypoint();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (!bookIsOpen)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hit, raycastDistance))
                {
                    if (hit.transform.parent != null && hit.transform.parent.GetComponent <PBook> () != null)
                    {
                        activePowerBook = hit.transform.parent.GetComponent <PBook> ();
                        activePowerBookOriginalLayer = activePowerBook.gameObject.layer;
                        SetLayer(activePowerBook.gameObject, LayerMask.NameToLayer(overlayLayer));
                        BoxCollider bookCollider = (BoxCollider)hit.collider;
                        activePowerBookOriginalPos         = hit.transform.position;
                        activePowerBookOriginalRot         = hit.transform.rotation;
                        activePowerBook.transform.position = new Vector3((bookCollider.size.y / 2) - 0.005f, 0, -bookCollider.size.z / 2);
                        activePowerBook.transform.rotation = Quaternion.Euler(perspectiveAngle, 0, 0);
                        overlayCam.transform.position      = new Vector3(0, ((bookCollider.size.z * 1.4f) - (bookCollider.size.y / 2)) - perspectiveAngle * 0.003f, -perspectiveAngle * 0.001f);
                        overlayCam.gameObject.SetActive(true);
                        if (autoOpenBook)
                        {
                            activePowerBook.OpenBook();
                        }
                        bookIsOpen = true;

                        foreach (GameObject go in disabledGameObjectsWhileReading)
                        {
                            go.SetActive(false);
                        }
                    }
                }
            }
        }
        else
        {
            if (Input.GetKey(openCloseKey))
            {
                if (activePowerBook.GetBookState() == PBook.BookState.CLOSED)
                {
                    activePowerBook.OpenBook();
                }
                else if (activePowerBook.GetBookState() == PBook.BookState.OPEN)
                {
                    CloseOverlay();
                }
            }
            if (Input.GetKey(nextPageKey))
            {
                activePowerBook.NextPage();
            }
            if (Input.GetKey(prevPageKey))
            {
                activePowerBook.PrevPage();
            }
        }
    }
    void Update()
    {
        if (openCloseKey != KeyCode.None && Input.GetKeyDown(openCloseKey))
        {
            if (pBook.GetBookState() == PBook.BookState.CLOSED)
            {
                pBook.OpenBook();
            }
            if (pBook.GetBookState() == PBook.BookState.OPEN)
            {
                pBook.CloseBook();
            }
        }

        if (nextPageKey != KeyCode.None && Input.GetKeyDown(nextPageKey))
        {
            pBook.NextPage();
        }

        if (prevPageKey != KeyCode.None && Input.GetKeyDown(prevPageKey))
        {
            pBook.PrevPage();
        }

        if (gotoLastPageKey != KeyCode.None && Input.GetKeyDown(gotoLastPageKey))
        {
            pBook.GoToLastPage(gotoSpeed);
        }

        if (gotoFirstPageKey != KeyCode.None && Input.GetKeyDown(gotoFirstPageKey))
        {
            pBook.GoToFirstPage(gotoSpeed);
        }

        if (jumpToLastPageKey != KeyCode.None && Input.GetKeyDown(jumpToLastPageKey))
        {
            pBook.JumpToLastPage(playSoundOnJump);
        }

        if (gotoFirstPageKey != KeyCode.None && Input.GetKeyDown(jumpToFirstPageKey))
        {
            pBook.JumpToFirstPage(playSoundOnJump);
        }
    }
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;

        pointer.color = Color.white;
        if (Physics.Raycast(camTr.position + (camTr.forward * raycastStartDistance), camTr.forward, out hit, raycastDistance, bookLayer.value))
        {
            if ((hit.transform.parent != null && hit.transform.parent.GetComponent <PBook> () != null) || (hit.transform.parent.parent != null && hit.transform.parent.parent.GetComponent <PBook> () != null))
            {
                pointer.color = Color.red;
            }
        }

        if (Input.GetKeyDown(openCloseBookKey) && activePowerBook == null)
        {
            if (Physics.Raycast(camTr.position + (camTr.forward * raycastStartDistance), camTr.forward, out hit, raycastDistance, bookLayer.value))
            {
                if (hit.transform.parent != null && hit.transform.parent.GetComponent <PBook> () != null)
                {
                    activePowerBook = hit.transform.parent.GetComponent <PBook> ();
                    if (activePowerBook.GetBookState() == PBook.BookState.CLOSED)
                    {
                        activePowerBook.OpenBook();
                    }
                    activePowerBook = null;
                }
            }

            if (Physics.Raycast(camTr.position + (camTr.forward * raycastStartDistance), camTr.forward, out hit, raycastDistance, bookLayer.value))
            {
                if (hit.transform.parent.parent != null && hit.transform.parent.parent.GetComponent <PBook> () != null)
                {
                    activePowerBook = hit.transform.parent.parent.GetComponent <PBook> ();
                    if (activePowerBook.GetBookState() == PBook.BookState.OPEN)
                    {
                        activePowerBook.CloseBook();
                    }
                    activePowerBook = null;
                }
            }
        }

        if (Input.GetKeyDown(prevPageKey) && activePowerBook == null)
        {
            if (Physics.Raycast(camTr.position + (camTr.forward * raycastStartDistance), camTr.forward, out hit, raycastDistance, bookLayer.value))
            {
                if (hit.transform.parent.parent != null && hit.transform.parent.parent.GetComponent <PBook> () != null)
                {
                    activePowerBook = hit.transform.parent.parent.GetComponent <PBook> ();
                    if (activePowerBook.GetBookState() == PBook.BookState.OPEN)
                    {
                        activePowerBook.PrevPage();
                    }
                    activePowerBook = null;
                }
            }
        }

        if (Input.GetKeyDown(nextPageKey) && activePowerBook == null)
        {
            if (Physics.Raycast(camTr.position + camTr.forward * raycastStartDistance, camTr.forward, out hit, raycastDistance, bookLayer.value))
            {
                if (hit.transform.parent.parent != null && hit.transform.parent.parent.GetComponent <PBook> () != null)
                {
                    activePowerBook = hit.transform.parent.parent.GetComponent <PBook> ();
                    if (activePowerBook.GetBookState() == PBook.BookState.OPEN)
                    {
                        activePowerBook.NextPage();
                    }
                    activePowerBook = null;
                }
            }
        }
    }
 public void OpenBook()
 {
     pBook.OpenBook();
 }