Пример #1
0
    void Update()
    {
        Color curColor  = this.image.color;
        float alphaDiff = Mathf.Abs(curColor.a - this.targetAlpha);

        if (alphaDiff > 0.0001f)
        {
            curColor.a                    = Mathf.Lerp(curColor.a, targetAlpha, this.FadeRate * Time.deltaTime);
            this.image.color              = curColor;
            this.leftPortraitImage.color  = curColor;
            this.rightPortraitImage.color = curColor;
        }
        Color curColorText = this.myText.color;

        //float alphaDiffText = Mathf.Abs(curColorText.a - this.targetAlpha);
        if (alphaDiff > 0.0001f)
        {
            curColorText.a    = Mathf.Lerp(curColorText.a, targetAlpha, this.FadeRate * Time.deltaTime);
            this.myText.color = curColorText;
        }

        if (myText.text == string.Empty && messageQueue.Count == 0 && this.targetAlpha != 0)
        {
            FadeOut();
        }


        speedUpText = Input.anyKey;

        if (!currentlySpammingText)                              //Vi väntar på input ifrån spelaren
        {
            if (messageQueue.Count > 0 && this.targetAlpha == 0) //Vi håller på att fadea ut eller har fadeat ut.
            {
                if (!waitingToSpamText)
                {
                    FadeIn();
                    StartCoroutine(AddText(true));
                }
            }

            if (currentMessageIsClickToAdvance && Input.GetButtonDown(Inputs.AButton()))  //Spelaren vill få nästa äventyrsbubbla
            {
                if (clickToGetToNextMessageBubble)
                {
                    StartCoroutine(AddText());
                }
                else
                {
                    this.ClearText();
                }
            }

            if (!currentlySpammingText && messageQueue.Count > 0 && myText.text == string.Empty && !currentMessageIsClickToAdvance)
            {
                StartCoroutine(AddText());
            }
        }
        //Debug.Log(Time.time + "speedUpText = " + speedUpText);
        //Debug.Log(Time.time + "currentRateOfText = " + currentRateOfText);
    }
Пример #2
0
    void FixedUpdate()
    {
        float y, x;

        y = x = 0;

        if (Inputs.AButton(playerId) && CanJump() && rb.velocity.y <= 0f)
        {
            y = Jump();
        }

        x = Inputs.Horizontal(playerId) * movementSpeed;

        //Handles extra applied force, outside walking speed
        if (Mathf.Abs(rb.velocity.x) > maxSpeed)
        {
            float extraX = rb.velocity.x;
            if (extraX < 0)
            {
                x = Mathf.Max(extraX, extraX + x * recoverySpeed * Time.deltaTime);
            }
            if (extraX > 0)
            {
                x = Mathf.Min(extraX, extraX + x * recoverySpeed * Time.deltaTime);
            }
        }

        rb.velocity = new Vector2(x, rb.velocity.y + y);
    }
Пример #3
0
 void Update()
 {
     if (Input.GetButton(Inputs.AButton()) || Input.GetKeyUp(KeyCode.Space))
     {
         if (timestamp + cooldown < Time.time)
         {
             timestamp          = Time.time;
             currentIntroFrame += 1;
             if (currentIntroFrame == listOfIntroSprites.Count)
             {
                 SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
             }
             else
             {
                 myRenderer.sprite = listOfIntroSprites[currentIntroFrame];
             }
         }
     }
 }