Exemplo n.º 1
0
    // Pick up a book, also used when a book is first created.
    public void pickupBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        // Open the book.
        //   setOpen ();

        // Enable the menu.
        showMenu();

        // Disable physics.
        GetComponent <Rigidbody> ().useGravity  = false;
        GetComponent <Rigidbody> ().isKinematic = true;
        transform.SetParent(null);
        dropped = false;

        // Add the book to the collection of active books.
        GameObject activeBooks = GameObject.Find("ActiveBooks");

        if (activeBooks != null)
        {
            transform.SetParent(activeBooks.transform);
        }

        // Bring it near the user and let them position it somewhere.
        this.transform.position = controllerObject.controllerObject.transform.position + 1.0f * controllerObject.controllerObject.transform.forward;
        moveBook(controller, controllerObject, null, avatar);
    }
Exemplo n.º 2
0
 public void trolleyManoeuvre(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         GetComponent <Rigidbody> ().AddForce(-forceStrength * Vector3.Normalize(trolley.transform.position - avatar.transform.position));
     }
 }
Exemplo n.º 3
0
 private void removeBook(TreeNode n, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         Debug.Log("Remove" + n.filepath);
     }
 }
Exemplo n.º 4
0
 public void resume(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         gameObject.SetActive(false);
     }
 }
Exemplo n.º 5
0
 public void returnToLibrary(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         RoomChangeMenuInteraction.changeToRoom("Library", this);
     }
 }
Exemplo n.º 6
0
 // Switch between open and closed.
 public void toggleCloseBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (initialize)
     {
         // enforce current state.
         if (open)
         {
             setOpen();
         }
         else
         {
             setClosed();
         }
     }
     else
     {
         // switch state.
         if (open)
         {
             setClosed();
         }
         else
         {
             setOpen();
         }
     }
 }
Exemplo n.º 7
0
// Drop the book.
    public void dropBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        if (!initialize)
        {
            // Close it first.
//       setClosed ();

            // Switch off menu - a dropped book is no longer in use.
            hideMenu();

            // Switch off settings.
//       settingsOpen = false;
//       updateSettings ();

            // Let physics have it.
            GetComponent <Rigidbody> ().useGravity      = true;
            GetComponent <Rigidbody> ().isKinematic     = false;
            GetComponent <Rigidbody> ().angularVelocity = new Vector3(-1.1f, -1.2f, -1.3f);

            // Remove it from the managed set.
            transform.SetParent(null);
            dropped = true;
            // Ensure it doesn't get transferred between scenes.
//       SceneManager.MoveGameObjectToScene (gameObject, SceneManager.GetActiveScene ());

            // Sound effect.
            bookDropSound.Play();
        }
    }
Exemplo n.º 8
0
    void checkScroll(ControlInput controller, ControlInput.ControllerDescription controllerObject, bool trigger, bool debounceTrigger, Vector3 direction, Vector3 position, GameObject avatarout, bool touchpad, Vector2 touchposition)
    {
        if (touchpad)
        {
            if (!haveOffset)
            {
                scrollStart = touchposition;
                haveOffset  = true;
            }

            Vector2 scrollOffset = 0.5f * (touchposition - scrollStart);
            Debug.Log("Touchpad " + touchpad + " " + touchposition + " " + haveOffset + " " + scrollOffset);
            scroll(scrollOffset.y);
            reflow();
            scrollStart = touchposition;
        }
        else
        {
//       if (haveOffset)
//       {
//         Vector2 scrollOffset = 100.0f * (touchposition - scrollStart);
//     Debug.Log ("Touchpad " + touchpad + " " + touchposition + " " + haveOffset + " " + scrollOffset);
//         scroll (scrollOffset.y);
//         reflow ();
            haveOffset = false;
//       }
        }
    }
Exemplo n.º 9
0
    private void colourResponse(MenuItem menuOption, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject avatar)
    {
        // Remember where the button was.
        Color buttonOrigin = new Color(0, 0, 0);

        foreach (MeshRenderer r in menuOption.button.GetComponentsInChildren <MeshRenderer> ())
        {
            buttonOrigin = r.material.color;
        }
        // Set/reset the time when focus is lost.
        menuOption.lastTouch = Time.time + buttonColourRecoveryTime;
        if (!menuOption.outOfPosition)
        {
            // If not focus, then move.
            foreach (MeshRenderer r in menuOption.button.GetComponentsInChildren <MeshRenderer> ())
            {
                r.material.color = new Color(0, 1, 0);
            }
            menuOption.outOfPosition = true;
            // Play sound.
            if (touchSound != null)
            {
                touchSound.Play();
            }
            // Start timer to recover if moves out of focus.
            StartCoroutine(returnToNormalColour(menuOption, buttonOrigin));
        }
    }
Exemplo n.º 10
0
    // Respond to the door being selected.
    public void summonTrolley(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        if (!initialize)
        {
            Debug.Log("Summoning");
            TrolleyManager [] tm = Object.FindObjectsOfType <TrolleyManager> ();

            TrolleyManager thisTrolley = null;
            foreach (TrolleyManager t in tm)
            {
                Debug.Log("Got tr " + t.trolleyName);
                if (t.trolleyName == trolleyIdentifier)
                {
                    thisTrolley = t;
                    break;
                }
            }

            if (thisTrolley == null)
            {
                Debug.Log("Creating trolley ");
                thisTrolley = Instantiate(trolleyTemplate, transform.position + 0.0f * transform.forward, Quaternion.identity).GetComponent <TrolleyManager> ();
            }

            Debug.Log("Calling");
            thisTrolley.track(avatar);
        }
    }
Exemplo n.º 11
0
 // Respond to the door being selected.
 public void teleportActivate(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         StartCoroutine(teleport(avatar));
     }
 }
Exemplo n.º 12
0
 // deprecated - to be removed.
 public void positionBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         triggerCleared = false;
         controller.addHandler(bookManipulate, controllerObject);
     }
 }
Exemplo n.º 13
0
 // Get the door to respond to pointer goes over it.
 public void doorRespond(MenuItem menuOption, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject avatar)
 {
     if ((touchSound != null) && (!touchingDoor))
     {
         touchSound.Play();
     }
     touchingDoor = true;
 }
Exemplo n.º 14
0
 // Increase the local state represent font.
 public void increaseFont(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         fontSize += 5;
     }
     updateView();
 }
Exemplo n.º 15
0
 public void scaleBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         triggerCleared = false;
         controller.addHandler(bookScale, controllerObject, true);
     }
 }
Exemplo n.º 16
0
 private void addBook(TreeNode n, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         Debug.Log("Add " + n.filepath);
         StartCoroutine(bookFiles.registerBook(n.filepath));
     }
 }
Exemplo n.º 17
0
    // Toggle the settings menu. Create it, if it does not already exist and needs to open.
    public void toggleSettings(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        if (!initialize)
        {
            settingsOpen = !settingsOpen;

            updateSettings();
        }
    }
Exemplo n.º 18
0
 // Rotate the book to get the best reading angle.
 public void rotateBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         triggerCleared = false;
         GetComponentInChildren <BoxCollider> ().enabled = false;
         controller.addHandler(bookRotate, controllerObject, true);
     }
 }
Exemplo n.º 19
0
    override public void handleUnfocus(ControlInput controller, ControlInput.ControllerDescription controllerObject)
    {
        if (!touchingTeleport.ContainsKey(controllerObject))
        {
            touchingTeleport[controllerObject] = false;
        }

        controller.setStandardBeam(controllerObject);
        touchingTeleport[controllerObject] = false;
    }
Exemplo n.º 20
0
 // Apply local font value to the book.
 public void applyFont(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         BookManager bm = GetComponentInParent <BookManager> ();
         bm.setFontSize(fontSize);
     }
     retrieveSettings();
     updateView();
 }
Exemplo n.º 21
0
 // Move the book closer.
 public void retrieveBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         triggerCleared = false;
         bookDirection  = transform.position - controller.avatar.transform.position;
         bookDistance   = bookDirection.magnitude;
         bookDirection  = Vector3.Normalize(bookDirection);
         controller.addHandler(bookRetrieve, controllerObject, true);
     }
 }
Exemplo n.º 22
0
 public void removeHandler(HandleControllerInputType h, ControlInput.ControllerDescription controllerObject)
 {
     if (exclusiveRegisteredHandlers[controllerObject].Contains(h))
     {
         exclusiveRegisteredHandlers[controllerObject].Remove(h);
     }
     if (registeredHandlers[controllerObject].Contains(h))
     {
         registeredHandlers[controllerObject].Remove(h);
     }
 }
Exemplo n.º 23
0
 private void collapseNode(TreeNode n, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         if (n.filepath != null)
         {
             Debug.Log("Collapsing");
             n.removeChildren(this);
             reflow();
         }
     }
 }
Exemplo n.º 24
0
 public void decreasePage(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         currentPage -= 10;
         if (currentPage < 0)
         {
             currentPage = 0;
         }
     }
     updateView();
 }
Exemplo n.º 25
0
 public void increasePage(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         currentPage += 10;
         BookManager bm = GetComponentInParent <BookManager> ();
         if (currentPage >= bm.getMaxPages())
         {
             currentPage = bm.getMaxPages() - 1;
         }
     }
     updateView();
 }
Exemplo n.º 26
0
    // Respond to a book being selected from a shelf. Leave the book on the shelf, but create
    // a readable version and load the book into it.
    public void selectBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        if (!initialize)
        {
            string     fname = button.GetComponent <BookProperties> ().props.filename;
            GameObject book  = Instantiate(bookTemplate);
            book.GetComponent <BookProperties> ().props = button.GetComponent <BookProperties> ().props;
            BookManager bookManager = book.GetComponent <BookManager> ();
//      StartCoroutine (bookManager.loadBook (fname, button.GetComponent <BookProperties> ().props));
//      book.GetComponent <BookMenuInteraction> ().pickupBook (controller, controllerObject, button, avatar);
            book.GetComponent <BookPlaceholdMenu> ().pickupBook(controller, controllerObject, button, avatar);
        }
    }
Exemplo n.º 27
0
    // Activate the book positioning process.
    public void moveBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
    {
        if (!initialize)
        {
            triggerCleared = false;
            bookDistance   = (transform.position - controllerObject.controllerObject.transform.position).magnitude;

            // Disable collider while moving so that it doesn't interfere with other objects.
            GetComponentInChildren <BoxCollider> ().enabled = false;

            controller.addHandler(bookMove, controllerObject, true);
        }
    }
Exemplo n.º 28
0
 // A response when clicking on the book itself. Currently: turn page if open, otherwise pick up.
 public void getBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         if (open)
         {
             nextPage(controller, controllerObject, button, avatar);
         }
         else
         {
             pickupBook(controller, controllerObject, button, avatar);
         }
     }
 }
Exemplo n.º 29
0
    // Book moves backwards or forwards along the line between controller and its original position. Aiming the controller up or down controls distance.
    public void bookRetrieve(ControlInput controller, ControlInput.ControllerDescription controllerObject, bool trigger, bool debounceTrigger, Vector3 direction, Vector3 position, GameObject avatar, bool touchpad, Vector2 touchposition)
    {
//           print ("Retrievingbook " + bookDistance + " " + direction);
        if (!debounceTrigger)
        {
            triggerCleared = true;
        }
        if (debounceTrigger && triggerCleared)
        {
            controller.removeHandler(bookRetrieve, controllerObject);
        }

        transform.position = avatar.transform.position + bookDirection * bookDistance * Mathf.Pow(2.0f, 5.0f * direction.y);
    }
Exemplo n.º 30
0
    // Show indicator of teleportation
    public void teleportRespond(MenuItem menuOption, ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject avatar)
    {
        if (!touchingTeleport.ContainsKey(controllerObject))
        {
            touchingTeleport[controllerObject] = false;
        }

        if (!touchingTeleport[controllerObject])
        {
            touchSound.Play();
            controller.setTeleportBeam(controllerObject);
            touchingTeleport[controllerObject] = true;
        }
    }