Ejemplo n.º 1
0
    public void SetVisible(bool visible)
    {
        if (visible)
        {
            // Play speech bubble appearing sound.
            audioBubbleAppear.Play();
            // Make speech bubble visible.
            transform.localScale = new Vector3(1, 1, 1);
            // Update speech bubble state placeholders.
            state.UpdatePlaceholders();
            textNormal.text = state.text;

            if (lastState)
            {
                // Show stars on last state.
                StartCoroutine(ShowStarsAfterTime());
            }
            else
            {
                // No professor voice on last state.
                StartCoroutine(PlayVoiceAfterTime());
            }
        }
        else
        {
            // Play speech bubble disappearing sound.
            audioBubbleDisappear.Play();
            // Make speech bubble invisible but not inactive.
            transform.localScale = new Vector3(0, 0, 0);
        }
    }
Ejemplo n.º 2
0
    public void SetState(int id)
    {
        state = (SpeechBubbleState)states[id];
        if (state != null)
        {
            // Update speech bubble text placeholders.
            state.UpdatePlaceholders();

            // Resize speech bubble image to state size.
            RectTransform rtImage = (RectTransform)imageBubble.transform;
            rtImage.sizeDelta = new Vector2(state.width + 30, imageHeight);

            // Resize speech bubble text to fit in new size.
            RectTransform rtText    = (RectTransform)textNormal.transform;
            float         textWidth = state.width - 200;
            rtText.sizeDelta = new Vector2(textWidth, textHeight);
            textNormal.text  = state.text;

            // Move ok button to the mittle of the speech bubble if there is only one state.
            if (states.Values.Count == 1)
            {
                buttonOk.transform.localPosition = new Vector2(85, -125);
                buttonPrev.gameObject.SetActive(false);
                buttonNext.gameObject.SetActive(false);
            }
            else
            {
                buttonOk.transform.localPosition = buttonOkPos;
                buttonPrev.gameObject.SetActive(true);
                buttonNext.gameObject.SetActive(true);
                buttonPrev.interactable = false;
            }

            // Disable previous button if it's the first state of the sequence.
            if (state.id == 0)
            {
                buttonPrev.interactable = false;
            }
            else
            {
                buttonPrev.interactable = true;
            }

            if (state.id == states.Values.Count - 1)
            {
                // Hide next button and show ok button.
                buttonNext.gameObject.SetActive(false);
                buttonOk.gameObject.SetActive(true);
            }
            else
            {
                // Show next button and hide ok button.
                buttonNext.gameObject.SetActive(true);
                buttonOk.gameObject.SetActive(false);
            }
        }
    }