Beispiel #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);
    }
 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));
     }
 }
Beispiel #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);
     }
 }
 public void resume(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         gameObject.SetActive(false);
     }
 }
Beispiel #5
0
 public void returnToLibrary(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         RoomChangeMenuInteraction.changeToRoom("Library", this);
     }
 }
 // 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();
         }
     }
 }
Beispiel #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();
        }
    }
Beispiel #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;
//       }
        }
    }
Beispiel #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));
        }
    }
    // 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);
        }
    }
Beispiel #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));
     }
 }
 // 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);
     }
 }
Beispiel #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;
 }
 // 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();
 }
 public void scaleBook(ControlInput controller, ControlInput.ControllerDescription controllerObject, GameObject button, GameObject avatar, bool initialize = false)
 {
     if (!initialize)
     {
         triggerCleared = false;
         controller.addHandler(bookScale, controllerObject, true);
     }
 }
Beispiel #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));
     }
 }
    // 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();
        }
    }
 // 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);
     }
 }
Beispiel #19
0
    override public void handleUnfocus(ControlInput controller, ControlInput.ControllerDescription controllerObject)
    {
        if (!touchingTeleport.ContainsKey(controllerObject))
        {
            touchingTeleport[controllerObject] = false;
        }

        controller.setStandardBeam(controllerObject);
        touchingTeleport[controllerObject] = false;
    }
 // 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();
 }
 // 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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #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();
         }
     }
 }
 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();
 }
 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();
 }
Beispiel #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);
        }
    }
    // 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);
        }
    }
 // 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);
         }
     }
 }
    // 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);
    }
Beispiel #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;
        }
    }