Exemple #1
0
    public IEnumerator CallMinigame()
    {
        yield return(new WaitForSeconds(1));

        medleyController.EnableOverlay("tutorial");
        minigameIcon.tutorialInfo = currentMinigame;
        minigameIcon.Press();
    }
Exemple #2
0
    void Update()
    {
        if (controller == null)
        {
            Debug.Log("Controller not initialized");
            return;
        }

        if (!onInstr)
        {
            if (controller.GetPressDown(touchPad))
            {
                Vector2 press = controller.GetAxis();

                if (press.y >= 0)
                {
                    source.PlayOneShot(select);

                    buttons[i].GetComponent <Image>().sprite = sprites[i];

                    i--;

                    if (i == -1)
                    {
                        i = 3;
                    }

                    buttons[i].GetComponent <Image>().sprite = spritesHighlighted[i];
                }
                else
                {
                    source.PlayOneShot(select);

                    buttons[i].GetComponent <Image>().sprite = sprites[i];

                    i = (i + 1) % 4;

                    buttons[i].GetComponent <Image>().sprite = spritesHighlighted[i];
                }
            }
        }

        if (controller.GetPressDown(triggerButton))
        {
            if (!onInstr)
            {
                buttons[i].Press();

                if (i == 3)
                {
                    onInstr = true;
                }
            }
            else
            {
                done.Press();

                onInstr = false;
            }
        }
    }
Exemple #3
0
    void Update()
    {
        if (controller == null)         // Debug message for if controller doesn't exist
        {
            Debug.Log("Controller not initialized");
            return;
        }

        if (!onInstr)         // Ignore button inputs when on instructions screen
        {
            if (controller.GetPressDown(touchPad))
            {
                Vector2 press = controller.GetAxis();

                // If player presses up on controller, play sound effect and move selection up
                if (press.y >= 0)
                {
                    source.PlayOneShot(select);

                    buttons[i].GetComponent <Image>().sprite = sprites[i]; // De-highlight current button

                    i--;                                                   // Decrement button index

                    if (i == -1)                                           // If button index goes below zero, wrap-around to button 3
                    {
                        i = 3;
                    }

                    buttons[i].GetComponent <Image>().sprite = spritesHighlighted[i]; // Highlight new button
                }
                else                                                                  // If player presses down on controller, play sound effect and move selection down
                {
                    source.PlayOneShot(select);

                    buttons[i].GetComponent <Image>().sprite = sprites[i];            // De-highlight current button

                    i = (i + 1) % 4;                                                  // Increment button index; if button index goes above 3, wrap-around to button 0

                    buttons[i].GetComponent <Image>().sprite = spritesHighlighted[i]; // Highlight current button
                }
            }
        }

        if (controller.GetPressDown(triggerButton))
        {
            if (!onInstr)             // If player presses trigger when not on instructions screen, press highlighted button
            {
                buttons[i].Press();

                if (i == 3)                 // If highlighted button is instructions button, indicate player is on instructions screen
                {
                    onInstr = true;
                }
            }
            else             // If player presses trigger when on instructions screen, press "Done" button
            {
                done.Press();

                onInstr = false;                 // Indicate player is no longer on instructions screen
            }
        }
    }
    void Update()
    {
        if (controller == null)         // Debug message for if controller doesn't exist
        {
            Debug.Log("Controller not initialized");
            return;
        }

        // If touch pad is touched, move player in appropriate direction
        if (controller.GetTouch(touchPad))
        {
            Vector2 dir      = controller.GetAxis();                                     // Get touch coordinates
            float   rotation = -head.GetComponent <Transform> ().rotation.eulerAngles.y; // Rotate touch coordinates by player's y-axis rotation to ensure movement is relative to this rotation
            float   sin      = Mathf.Sin(rotation * Mathf.Deg2Rad);
            float   cos      = Mathf.Cos(rotation * Mathf.Deg2Rad);
            float   tx       = dir.x;
            float   ty       = dir.y;

            dir.x = (cos * tx) - (sin * ty);
            dir.y = (sin * tx) + (cos * ty);

            if (dir.x < -0.2)
            {
                if (dir.y < -0.2)
                {
                    cam.Move("Backward and Left");
                }
                else if (dir.y > 0.2)
                {
                    cam.Move("Forward and Left");
                }
                else
                {
                    cam.Move("Left");
                }
            }
            else if (dir.x > 0.2)
            {
                if (dir.y < -0.2)
                {
                    cam.Move("Backward and Right");
                }
                else if (dir.y > 0.2)
                {
                    cam.Move("Forward and Right");
                }
                else
                {
                    cam.Move("Right");
                }
            }
            else
            {
                if (dir.y < -0.2)
                {
                    cam.Move("Backward");
                }
                else if (dir.y > 0.2)
                {
                    cam.Move("Forward");
                }
            }
        }

        // If trigger button is pressed, pick up object
        if (controller.GetPressDown(triggerButton))
        {
            float minDistance = float.MaxValue;
            float distance;

            // Find the nearest object the hands are currently overlapping
            foreach (InteractableObject item in objectsHoveringOver)
            {
                distance = (item.transform.position - transform.position).sqrMagnitude;

                if (distance < minDistance)
                {
                    minDistance   = distance;
                    closestObject = item;
                }
            }

            interactingObject = closestObject; // Set this nearest object as the one being picked up by the hands
            closestObject     = null;          // Null out reference to closest object

            if (interactingObject)
            {
                // If nearest object is already held by opposite hand when trigger button is pressed, drop it from that hand before attaching it to this hand
                if (interactingObject.IsInteracting())
                {
                    interactingObject.EndInteraction(this);
                }

                interactingObject.BeginInteraction(this);
            }

            // If the trigger button is pressed while the Restart button is enabled, reset the scene
            if (restart.enabled == true)
            {
                restart.Press();
            }
        }

        // If trigger button is unpressed while hand is holding an object, drop object
        if (controller.GetPressUp(triggerButton) && interactingObject != null)
        {
            interactingObject.EndInteraction(this);
        }

        // If grip button is pressed while player is not crouched, move player to crouching position
        if (controller.GetPressDown(gripButton) && (Data.crouched == Data.UNCROUCHED))
        {
            Vector3 temp = player.GetComponent <Transform>().position;

            temp.y = (temp.y - 50) * Time.deltaTime;

            player.GetComponent <Transform>().position = temp;
            Data.crouched = Data.CROUCHED;
        }

        // If grip button is released while player is crouched, move player out of crouching position
        if (controller.GetPressUp(gripButton) && (Data.crouched == Data.CROUCHED))
        {
            Vector3 temp = player.GetComponent <Transform>().position;

            temp.y = (temp.y + 50) * Time.deltaTime;

            player.GetComponent <Transform>().position = temp;
            Data.crouched = Data.UNCROUCHED;
        }
    }