Exemplo n.º 1
0
 /// <summary>
 /// Observable ValueChanged event
 /// </summary>
 /// <param name="events"></param>
 /// <returns></returns>
 public static IObservable <Control3DEventArgs> ValueChangedAsObservable(this VRTK_Button events)
 {
     return(Observable.FromEvent <Control3DEventHandler, Control3DEventArgs>(
                h => (s, e) => h(e),
                h => events.ValueChanged += h,
                h => events.ValueChanged -= h));
 }
Exemplo n.º 2
0
 private void SetButton3D()
 {
     if (b3d == null)
     {
         b3d = GetComponent <VRTK_Button>();
     }
 }
Exemplo n.º 3
0
 public void ActivateCircle(VRTK_Button button)
 {
     if (button.circleActivated != null)
     {
         startAnimRotation startAnim = button.circleActivated.GetComponent <startAnimRotation>();
         if (startAnim.firstCircle)
         {
             StartCoroutine(ActivateCircleCoroutine(3f, startAnim, 0));
             button.circleActivated.GetComponent <AudioSource>().PlayDelayed(3f);
         }
         else if (startAnim.secondCircle)
         {
             StartCoroutine(ActivateCircleCoroutine(3f, startAnim, 1));
             button.circleActivated.GetComponent <AudioSource>().PlayDelayed(3f);
         }
         else if (startAnim.thirdCircle)
         {
             StartCoroutine(ActivateCircleCoroutine(3f, startAnim, 2));
             button.circleActivated.GetComponent <AudioSource>().PlayDelayed(3f);
         }
     }
 }
Exemplo n.º 4
0
    public void UpdateButton(VRTK_Button button)
    {
        int id = buttons.FindIndex(e => e.GetInstanceID() == button.GetInstanceID());

        // Don't try to access element before 0
        if (id - 1 > 0)
        {
            // If the previous one needed the next one to be completed
            if (buttons[id - 1].doneOnNext && buttons[id - 1].ReachedActivationDistance())
            {
                // Deactivate previous button
                buttons[id - 1].active = false;
                buttons[id - 1].done   = true;
                buttons[id - 1].GetComponent <VRTK_InteractableObject>().enabled = false;
                buttons[id - 1].GetComponent <MeshRenderer>().material.color     = Color.green;
                //buttons[id - 1].GetComponent<AudioSource>().Play();

                // Deactivate the button who called the method
                buttons[id].active = false;
                buttons[id].GetComponent <VRTK_InteractableObject>().enabled = false;
                buttons[id].GetComponent <MeshRenderer>().material.color     = Color.green;

                ActivateCircle(buttons[id]);

                // Prepare next button of the puzzle
                if (id != buttons.Count - 1)
                {
                    buttons[id + 1].active = true;
                    buttons[id + 1].GetComponent <VRTK_InteractableObject>().enabled = true;
                    buttons[id + 1].GetComponent <MeshRenderer>().material.color     = buttons[id + 1].GetComponent <ActiveColor>().m_activeColor;
                }
            }
            else if (buttons[id - 1].doneOnNext && !buttons[id - 1].ReachedActivationDistance())
            {
                buttons[id].done = false;

                /*
                 * buttons[id].active = false;
                 * buttons[id].GetComponent<VRTK_InteractableObject>().enabled = false;
                 * buttons[id].GetComponent<MeshRenderer>().material.color = Color.green;
                 *
                 * if (id != buttons.Count - 1) {
                 *  buttons[id + 1].active = true;
                 *  buttons[id + 1].GetComponent<VRTK_InteractableObject>().enabled = true;
                 *  buttons[id + 1].GetComponent<MeshRenderer>().material.color = Color.yellow;
                 * }
                 */
                // If the call wasn't made by a doneOnNext type of button
            }
            else if (!buttons[id].doneOnNext)
            {
                buttons[id].active = false;
                buttons[id].GetComponent <VRTK_InteractableObject>().enabled = false;
                buttons[id].GetComponent <MeshRenderer>().material.color     = Color.green;
                buttons[id].GetComponent <AudioSource>().Play();


                ActivateCircle(buttons[id]);

                if (id != buttons.Count - 1)
                {
                    buttons[id + 1].active = true;
                    buttons[id + 1].GetComponent <VRTK_InteractableObject>().enabled = true;
                    buttons[id + 1].GetComponent <MeshRenderer>().material.color     = buttons[id + 1].GetComponent <ActiveColor>().m_activeColor;
                }
                // If the call was made by a doneOnNext button type
            }
            else if (buttons[id].doneOnNext)
            {
                buttons[id + 1].active = true;
                buttons[id + 1].GetComponent <VRTK_InteractableObject>().enabled = true;
                buttons[id + 1].GetComponent <MeshRenderer>().material.color     = Color.yellow;
            }
        }
        else
        {
            if (!buttons[id].doneOnNext)
            {
                buttons[id].active = false;
                buttons[id].GetComponent <VRTK_InteractableObject>().enabled = false;
                buttons[id].GetComponent <MeshRenderer>().material.color     = Color.green;
                buttons[id].GetComponent <AudioSource>().Play();


                ActivateCircle(buttons[id]);
            }

            if (id != buttons.Count - 1)
            {
                buttons[id + 1].active = true;
                buttons[id + 1].GetComponent <VRTK_InteractableObject>().enabled = true;
                buttons[id + 1].GetComponent <MeshRenderer>().material.color     = buttons[id + 1].GetComponent <ActiveColor>().m_activeColor;
            }
        }
    }