// Update is called once per frame
    void Update()
    {
        if (isTriggered)
        {
            textKeyTimer += Time.unscaledDeltaTime;
            if (textKeyTimer > textKeyThreshold && !isReachedEndOfMessage)
            {
                textKeyTimer -= textKeyThreshold;
                charCount++;

                if (!isReachedEndOfMessage && charCount >= charThreshold)
                {
                    isReachedEndOfMessage = true;
                }
                else
                {
                    displayString += contentString[charCount];
                }
            }

            if (isReachedEndOfMessage)
            {
                fadeOutTimer += Time.unscaledDeltaTime;

                this.transform.localScale = new Vector3(startScale.x * xScaleCurve.Evaluate(fadeOutTimer / fadeOutThreshold), startScale.y * yScaleCurve.Evaluate(fadeOutTimer / fadeOutThreshold), startScale.z);
                if (fadeOutTimer > fadeOutThreshold)
                {
                    isReachedEndOfMessage     = false;
                    isTriggered               = false;
                    this.transform.localScale = new Vector3(0f, 0f, 0f);
                    textBack.fadeOutBlack();
                }
            }
        }

        if (txtMesh.text.GetHashCode() != displayString.GetHashCode())
        {
            txtMesh.text = displayString;
        }
    }
Exemple #2
0
    // Update is called once per frame
    void Update()
    {
        if (isTriggered)
        {
            if (!isTypeable)
            {
                //keyTimer += Time.deltaTime;
                keyTimer += Time.unscaledDeltaTime;
                if (keyTimer > keyThreshold)
                {
                    keyTimer -= keyThreshold;

                    displayString += beginningString[stringIter];
                    //queryString += beginningString[stringIter];

                    stringIter++;
                    if (stringIter >= beginningString.Length)
                    {
                        displayString += "\n";
                        //queryString += "\n";
                        isTypeable = true;
                    }
                    //txtMesh.text = displayString;
                }
            }
            else
            {
                typingTimer += Time.unscaledDeltaTime;
                //typingTimer += Time.deltaTime;

                if (Input.inputString != "")
                {
                    currAddString = "";
                    if (Random.Range(0f, 1f) < probabilityCurve.Evaluate(typingTimer / typingThreshold))
                    {
                        currAddString += messupString[Random.Range(0, messupString.Length)];
                        //displayString += messupString[Random.Range(0, messupString.Length)];
                        //typeCount += 1;
                    }
                    else
                    {
                        currAddString = Input.inputString;
                        //displayString += Input.inputString;
                        //typeCount += Input.inputString.Length;
                    }

                    displayString += currAddString;
                    queryString   += currAddString;

                    typeCount += currAddString.Length;

                    if (typeCount > typeOverflowAbsThreshold)
                    {
                        displayString += "\n";
                        queryString   += "\n";
                        typeCount      = 0;
                    }
                    else if (typeCount > typeOverflowThreshold && currAddString.Contains(" "))
                    {
                        displayString += "\n";
                        queryString   += "\n";
                        typeCount      = 0;
                    }


                    //Debug.Log("Input string is not empty!");
                }
                else
                {
                    //Debug.Log("Input string is empty");
                }
            }

            if (displayString.GetHashCode() != txtMesh.text.GetHashCode())
            {
                txtMesh.text = displayString + "_";
            }


            if (!isDoneTyping && typingTimer > typingThreshold)
            {
                isDoneTyping = true;

                liesDB.InsertMessage(queryString);
                //
                textBackScript.fadeOutBlack();
                //SUBMIT
                Debug.Log(queryString);
            }

            detonationText.color = Color.Lerp(detonationText.color, startColorDetonate, Time.unscaledDeltaTime * 1f);
            detonationText.text  = "Detonation in " + (typingThreshold - typingTimer).ToString("F3");
        }

        if (typingTimer > typingThreshold + 1.5f)
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        if (typingTimer > (typingThreshold * 0.8f))
        {
            whiteOutRend.color = Color.Lerp(whiteOutRend.color, Color.white, Time.unscaledDeltaTime * 2f);
        }

        glassMask.transform.localScale = Vector3.Lerp(glassMask.transform.localScale, glassTargetScale, 3f * Time.unscaledDeltaTime);
    }