Beispiel #1
0
    //Faz a tela sumir.
    private IEnumerator CoroutineFadeOut(CanvasGroup canvasGroup)
    {
        //Faz os botão não serem acionados durante o tutorial
        if (canvasGroup.Equals(buttons) || canvasGroup.Equals(gui))
        {
            canvasGroup.interactable = false;
        }

        while (canvasGroup.alpha > 0f)
        {
            canvasGroup.alpha -= Time.deltaTime / 1f;

            yield return(null);
        }

        //Se a UI de tutorial for sumir, ela é desativada depois.
        if (canvasGroup.Equals(tutorialsCanvasGroup))
        {
            //Caso esteja desabilitado, o gesto é ativado outra vez.

            /*if (!tutorialsGesture.enabled)
             * {
             *  tutorialsGesture.enabled = true;
             * }*/

            tutorials.SetActive(false);
        }
    }
Beispiel #2
0
    //Faz a tela aparecer.
    private IEnumerator CoroutineFadeIn(CanvasGroup canvasGroup)
    {
        //Faz os botão serem acionados depois que o tutorial acabar.
        if (canvasGroup.Equals(buttons) || canvasGroup.Equals(gui))
        {
            canvasGroup.interactable = true;
        }

        while (canvasGroup.alpha < 1f)
        {
            canvasGroup.alpha += Time.deltaTime / 1f;

            yield return(null);
        }
    }
Beispiel #3
0
    /// <summary>
    /// Deactivate a specific group of sub buttons.
    /// </summary>
    /// <param name="subButtons">subButtons to deactivate.</param>
    public void DeactivateSubButtons(CanvasGroup subButtons)
    {
        subButtons.alpha = 0;
        animator.SetInteger("buttonSelected", -1);

        // Reset the Button Animator.
        if (subButtons.Equals(subButtons1Group))
        {
            ResetSubButtonAnimator(subButtons1Buttons);
        }
        else if (subButtons.Equals(subButtons2Group))
        {
            ResetSubButtonAnimator(subButtons2Buttons);
        }
        else
        {
            ResetSubButtonAnimator(subButtons3Buttons);
        }
    }
Beispiel #4
0
    /// <summary>
    /// Activate a specific group of sub buttons. By doing so, also deactivate any other sub buttons
    /// that are currently activated.
    /// </summary>
    /// <param name="subButtons">subButtons to activate.</param>
    public void ActivateSubButtons(CanvasGroup subButtons)
    {
        // Activate the given subButtons.
        //subButtons.blocksRaycasts = true;
        subButtons.alpha  = 1;
        subButtonsEnabled = subButtons;

        // Deactivate the other subButtons.
        if (subButtons.Equals(subButtons1Group))
        {
            DeactivateSubButtons(subButtons2Group);
            DeactivateSubButtons(subButtons3Group);
        }
        else if (subButtons.Equals(subButtons2Group))
        {
            DeactivateSubButtons(subButtons1Group);
            DeactivateSubButtons(subButtons3Group);
        }
        else
        {
            DeactivateSubButtons(subButtons1Group);
            DeactivateSubButtons(subButtons2Group);
        }
    }
Beispiel #5
0
    /// <summary>
    /// Control inputs from the player, if the panel is enabled.
    /// </summary>
    private void Update()
    {
        if (!panelEnabled)
        {
            return;
        }

        // Get input.
        float hInput = Input.GetAxis("Horizontal");
        float vInput = Input.GetAxis("Vertical");
        bool  left   = hInput < 0;
        bool  right  = hInput > 0;
        bool  up     = vInput > 0;
        bool  down   = vInput < 0;


        // Listen for input in order to control the event of the buttons.
        if (subButtonsEnabled != null)
        {
            // If we are activating sub buttons, then button inputs depend on the Inputs from the player.
            // A button will be highlighted based on the Inputs, NOT immediately selected.
            if (subButtonsEnabled.Equals(subButtons1Group))
            {
                if (up)
                {
                    EventSystem.current.SetSelectedGameObject(subButtons1Buttons[0].gameObject);
                    SetInteractible(subButtons1Buttons, 0, 1);
                    Input.ResetInputAxes();
                }
                else if (left)
                {
                    EventSystem.current.SetSelectedGameObject(subButtons1Buttons[1].gameObject);
                    SetInteractible(subButtons1Buttons, 1, 0);
                    Input.ResetInputAxes();
                }
                // When the player chooses the "opposite button", "Cancel" the selected sub button and hide all other sub buttons.
                else if (right || down)
                {
                    DeactivateSubButtons(subButtonsEnabled);
                    subButtonsEnabled = null;
                    Input.ResetInputAxes();
                }
            }
            else if (subButtonsEnabled.Equals(subButtons2Group))
            {
                if (up)
                {
                    EventSystem.current.SetSelectedGameObject(subButtons2Buttons[0].gameObject);
                    SetInteractible(subButtons2Buttons, 0, 1);
                    Input.ResetInputAxes();
                }
                else if (right)
                {
                    EventSystem.current.SetSelectedGameObject(subButtons2Buttons[1].gameObject);
                    SetInteractible(subButtons2Buttons, 1, 0);
                    Input.ResetInputAxes();
                }
                // When the player chooses the "opposite button", "Cancel" the selected sub button and hide all other sub buttons.
                else if (left || down)
                {
                    DeactivateSubButtons(subButtonsEnabled);
                    subButtonsEnabled = null;
                    Input.ResetInputAxes();
                }
            }
            else if (subButtonsEnabled.Equals(subButtons3Group))
            {
                if (left)
                {
                    EventSystem.current.SetSelectedGameObject(subButtons3Buttons[0].gameObject);
                    SetInteractible(subButtons3Buttons, 0, 1);
                    Input.ResetInputAxes();
                }
                else if (right)
                {
                    EventSystem.current.SetSelectedGameObject(subButtons3Buttons[1].gameObject);
                    SetInteractible(subButtons3Buttons, 1, 0);
                    Input.ResetInputAxes();
                }
                else if (up)
                {
                    DeactivateSubButtons(subButtonsEnabled);
                    subButtonsEnabled = null;
                    Input.ResetInputAxes();
                }
            }
        }
        else
        {
            if (left)
            {
                button1.onClick.Invoke();
                Input.ResetInputAxes();
            }
            else if (right)
            {
                button2.onClick.Invoke();
                Input.ResetInputAxes();
            }
            else if (down)
            {
                button3.onClick.Invoke();
                Input.ResetInputAxes();
            }
        }
    }