// Update is called once per frame
    new void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            clickPosition = Input.mousePosition;
        }

        if (Input.GetMouseButton(0))
        {
            Vector2 currentPos = Input.mousePosition;

            deltaY = currentPos.y - clickPosition.y;

            dialogueController.setScroll(lastScroll + deltaY);
        }

        if (Input.GetMouseButtonUp(0))
        {
            lastScroll += deltaY;
            if (lastScroll > dialogueController.getMaxScroll())
            {
                lastScroll = dialogueController.getMaxScroll();
            }
            if (lastScroll < dialogueController.getMinScroll())
            {
                lastScroll = dialogueController.getMinScroll();
            }
        }

        if (status == AlphabetState.exitting)
        {
            if (!isWaitingForActionToComplete)
            {
                if (mcRef == null)
                {
                    return;
                }

                DataStorage ds          = mcRef.getStorage();
                string      returnLevel = ds.retrieveStringValue("ReturnLocation");
                if (!returnLevel.Equals(""))
                {
                    SceneManager.LoadScene(returnLevel);
                }
            }
        }

        if (scrollbar.gameObject.activeSelf)
        {
            float   viewportHeight = container.GetComponent <RectTransform> ().rect.height - 106;
            float   maxHeight      = conversationList.Count * 100;
            float   scrollvalue    = scrollbar.GetComponent <Scrollbar> ().value;
            float   yPos           = scrollvalue * (maxHeight - viewportHeight);
            Vector3 pos            = container.transform.position;
            pos.y = Screen.height / 2 + yPos;
            container.transform.position = pos;
        }
    }
示例#2
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);
        }
    }