Exemple #1
0
    // Update is called once per frame
    void Update()
    {
        Vector2 newPos;

        if (state == AlphabetEntryState.delaying)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime > timeDelay)
            {
                state       = AlphabetEntryState.deploying;
                elapsedTime = 0.0f;
            }
        }

        if (state == AlphabetEntryState.deploying)
        {
            xPos += xSpeed;
            if (xPos > targetX)
            {
                xPos  = targetX;
                state = AlphabetEntryState.idle;
            }

            newPos = new Vector2(xPos, yPos);

            rect.localPosition = newPos;
        }
        if (state == AlphabetEntryState.idle)
        {
        }
        if (state == AlphabetEntryState.blinking)
        {
            int count;

            count = (int)(elapsedTime * 1000.0f);

            count = count % 80;

            if (count < 40)
            {
                barImage.enabled  = true;
                titleText.enabled = true;
            }
            else
            {
                barImage.enabled  = false;
                titleText.enabled = false;
            }

            elapsedTime += Time.deltaTime;

            if (elapsedTime > blinkTime)
            {
                barImage.enabled  = false;
                titleText.enabled = false;
                elapsedTime       = 0.0f;
                state             = AlphabetEntryState.idle;


                /* pour out the conversation into the dialogueController */
                dialogueController.setScroll(-75.0f);
                dialogueController.autoscroll = false;
                for (int i = 0; i < theConversation.textList.Count; ++i)
                {
                    if (theConversation.theSpeaker [i] == StoredConversationSpeaker.npc0)
                    {
                        dialogueController._wm_setSpeaker("left");
                    }
                    else
                    {
                        dialogueController._wm_setSpeaker("right");
                    }
                    dialogueController._wm_say(theConversation.textList [i], false, 0);
                }
            }
        }

        if (opacity < targetOpacity)
        {
            opacity += 1.6f * Time.deltaTime;
            if (opacity > targetOpacity)
            {
                opacity = targetOpacity;
            }
            barImage.color = new Vector4(colVec.x, colVec.y, colVec.z,
                                         colVec.w * opacity);

            titleText.color = new Vector4(textColor.r, textColor.g, textColor.b, textColor.a * opacity);
        }

        if (opacity > targetOpacity)
        {
            opacity -= 1.6f * Time.deltaTime;
            if (opacity < targetOpacity)
            {
                opacity = targetOpacity;
            }
            barImage.color = new Vector4(colVec.x, colVec.y, colVec.z,
                                         colVec.w * opacity);

            titleText.color = new Vector4(textColor.r, textColor.g, textColor.b, textColor.a * opacity);
        }
    }