Ejemplo n.º 1
0
        private void enterState(SpeechBubbleState state)
        {
            switch (state)
            {
            case SpeechBubbleState.Message:
                if (currentState == SpeechBubbleState.AwaitingModeration)
                {
                    setMessageToApproved();
                }
                else if (!isLocalPlayerChat())
                {
                    showChatMessage(isAwaitingModeration: false);
                }
                currentState = state;
                break;

            case SpeechBubbleState.ChatPhraseMessage:
                showChatMessage(isAwaitingModeration: false);
                currentState = state;
                break;

            case SpeechBubbleState.AwaitingModeration:
                currentState = state;
                showChatMessage(isAwaitingModeration: true);
                break;

            case SpeechBubbleState.Blocked:
                currentState = state;
                showBlockedChat();
                break;

            case SpeechBubbleState.Typing:
                if (currentState == SpeechBubbleState.Inactive)
                {
                    showActiveChat();
                    currentState = state;
                }
                else if (currentState == SpeechBubbleState.Message)
                {
                    currentState = SpeechBubbleState.TypingPending;
                }
                break;

            case SpeechBubbleState.Inactive:
                if (!isMessageShowing)
                {
                    if (currentState == SpeechBubbleState.TypingPending)
                    {
                        currentState = state;
                        enterState(SpeechBubbleState.Typing);
                    }
                    else
                    {
                        currentState = state;
                        hideMessage();
                    }
                }
                break;
            }
        }
Ejemplo n.º 2
0
 private void Start()
 {
     upPos = transform.localPosition;
     transform.position -= (Vector3.up * stage.Area.height * 2);
     downPos             = transform.localPosition;
     state = SpeechBubbleState.Down;
     timer = 0;
 }
Ejemplo n.º 3
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);
            }
        }
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     states = new System.Collections.Generic.Dictionary <int, SpeechBubbleState>();
     // Add each child object (SpeechBubbleState) to the states.
     foreach (Transform child in transform)
     {
         SpeechBubbleState s = child.gameObject.GetComponent <SpeechBubbleState>();
         states.Add(s.id, s);
     }
 }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        states = new System.Collections.Generic.Dictionary <int, SpeechBubbleState>();
        // Add each child object (SpeechBubbleState) to the states.
        Debug.Log(">> No of Childs=" + transform.GetChildCount());
        foreach (Transform child in transform)
        {
            SpeechBubbleState s = child.gameObject.GetComponent <SpeechBubbleState>();
            try { states.Add(s.id, s); }
            catch (ArgumentException e) {
                Debug.Log("Error while adding child (id=" + s.id + ") | text=" + s.text + "; collection contains value for that id: " + states[id].text);

                Debug.LogError(e.StackTrace);
            }
        }
    }
Ejemplo n.º 6
0
        private void Update()
        {
            switch (state)
            {
            case SpeechBubbleState.Up:
                timer += Time.deltaTime * speed;
                if (timer >= 1)
                {
                    timer = 1;
                    state = SpeechBubbleState.IdleUp;
                }
                break;

            case SpeechBubbleState.Down:
                timer -= Time.deltaTime * speed;
                if (timer <= 0)
                {
                    timer = 0;
                    state = SpeechBubbleState.IdleDown;
                }
                break;
            }
            transform.localPosition = Vector3.Lerp(downPos, upPos, transition.Evaluate(timer));
        }
Ejemplo n.º 7
0
 public void Hide()
 {
     state = SpeechBubbleState.Down;
     root.BubbleLightOff();
 }
Ejemplo n.º 8
0
 public void Show()
 {
     state = SpeechBubbleState.Up;
     root.BubbleLightOn();
 }
Ejemplo n.º 9
0
 private void OnDisable()
 {
     currentState = SpeechBubbleState.Inactive;
 }