Esempio n. 1
0
    void FixedUpdate()
    {
        if (!waiting || !stop)
        {
            if (Starting && !stop)
            {
                timer.text = (contStart -= Time.fixedDeltaTime).ToString().Substring(0, 1);
                if (contStart <= 0f)
                {
                    GO.gameObject.SetActive(true);
                    timer.gameObject.SetActive(false);
                    ST.gameObject.SetActive(false);
                }
                if (contStart <= -1.5f)
                {
                    GO.gameObject.SetActive(false);
                    Starting = false;
                }
            }
            else
            {
                if (SUsuario.Length == 100)
                {
                    stop = true;
                    tryagain.gameObject.SetActive(true);
                    points.gameObject.SetActive(true);
                    points.text = check() + "/100";
                }
                if (Input.anyKeyDown)
                {
                    contLetras += 1;
                    for (int i = 0; i < SUsuario.Length; i++)
                    {
                        if (SUsuario.Substring(i, 1) == " " && contLetras <= 5)
                        {
                            SUsuario = SUsuario.Substring(0, i) + Input.inputString + SUsuario.Substring(i + 1, SUsuario.Length - i - 1);
                            Debug.Log(SUsuario);
                            break;
                        }
                    }
                }
                if (cont != 104)
                {
                    L1.rectTransform.localPosition += new Vector3(0f, -1f * speed, 0f);
                    L2.rectTransform.localPosition += new Vector3(0f, -1f * speed, 0f);
                    L3.rectTransform.localPosition += new Vector3(0f, -1f * speed, 0f);
                    L4.rectTransform.localPosition += new Vector3(0f, -1f * speed, 0f);
                    L5.rectTransform.localPosition += new Vector3(0f, -1f * speed, 0f);
                }


                for (int i = contTest - 4; i <= cont; i++)
                {
                    if (i == contTest - 4)
                    {
                        if (STutorial.Substring(i, 1) == SUsuario.Substring(i, 1))
                        {
                            L5.color = new Color(0f, 1f, 0f);
                        }
                        else if (SUsuario.Substring(i, 1) == " ")
                        {
                            L5.color = new Color(1f, 1f, 1f);
                        }
                        else
                        {
                            L5.color = new Color(1f, 0f, 0f);
                        }
                    }
                    if (i == contTest - 3)
                    {
                        if (STutorial.Substring(i, 1) == SUsuario.Substring(i, 1))
                        {
                            L4.color = new Color(0f, 1f, 0f);
                        }
                        else if (SUsuario.Substring(i, 1) == " ")
                        {
                            L4.color = new Color(1f, 1f, 1f);
                        }
                        else
                        {
                            L4.color = new Color(1f, 0f, 0f);
                        }
                    }
                    if (i == contTest - 2)
                    {
                        if (STutorial.Substring(i, 1) == SUsuario.Substring(i, 1))
                        {
                            L3.color = new Color(0f, 1f, 0f);
                        }
                        else if (SUsuario.Substring(i, 1) == " ")
                        {
                            L3.color = new Color(1f, 1f, 1f);
                        }
                        else
                        {
                            L3.color = new Color(1f, 0f, 0f);
                        }
                    }
                    if (i == contTest - 1)
                    {
                        if (STutorial.Substring(i, 1) == SUsuario.Substring(i, 1))
                        {
                            L2.color = new Color(0f, 1f, 0f);
                        }
                        else if (SUsuario.Substring(i, 1) == " ")
                        {
                            L2.color = new Color(1f, 1f, 1f);
                        }
                        else
                        {
                            L2.color = new Color(1f, 0f, 0f);
                        }
                    }
                    if (i == contTest)
                    {
                        if (STutorial.Substring(i, 1) == SUsuario.Substring(i, 1))
                        {
                            L1.color = new Color(0f, 1f, 0f);
                        }
                        else if (SUsuario.Substring(i, 1) == " ")
                        {
                            L1.color = new Color(1f, 1f, 1f);
                        }
                        else
                        {
                            L1.color = new Color(1f, 0f, 0f);
                        }
                    }
                }

                if (L1.rectTransform.localPosition.y <= -780f && cont != 104)
                {
                    L1.rectTransform.localPosition = new Vector2(-80f, 290f);
                    L2.rectTransform.localPosition = new Vector2(-80f, 160f);
                    L3.rectTransform.localPosition = new Vector2(-80f, 30f);
                    L4.rectTransform.localPosition = new Vector2(-80f, -100f);
                    L5.rectTransform.localPosition = new Vector2(-80f, -230f);

                    for (int i = cont - 4; i <= cont; i++)
                    {
                        if (i == cont - 4)
                        {
                            TL5.text = (STutorial.Substring(cont - 4, 1)).ToUpper();
                        }
                        if (i == cont - 3)
                        {
                            TL4.text = (STutorial.Substring(cont - 3, 1)).ToUpper();
                        }
                        if (i == cont - 2)
                        {
                            TL3.text = (STutorial.Substring(cont - 2, 1)).ToUpper();
                        }
                        if (i == cont - 1)
                        {
                            TL2.text = (STutorial.Substring(cont - 1, 1)).ToUpper();
                        }
                        if (i == cont)
                        {
                            TL1.text = (STutorial.Substring(cont, 1)).ToUpper();
                        }
                    }
                    cont     += 5;
                    speed    += 0.2f;
                    contTest += 5;
                    for (int i = 0; i < SUsuario.Length; i++)
                    {
                        if (SUsuario.Substring(i, 1) == " ")
                        {
                            SUsuario = SUsuario.Substring(0, i) + "X" + SUsuario.Substring(i + 1, SUsuario.Length - i - 1);
                            Debug.Log(SUsuario);
                            Debug.Log(SUsuario.Length);
                        }
                    }
                    SUsuario  += "     ";
                    contLetras = 0;
                }
                animator.SetBool("DBaixo", false);
                animator.SetBool("DDir", false);
                animator.SetBool("DEsq", false);
                animator.SetBool("SocoEsq", false);
                animator.SetBool("SocoDir", false);
                animator.SetBool("InimigoBaixo", false);
                animator.SetBool("InimigoCima", false);
                if (Input.GetKeyDown("w"))
                {
                    animator.SetBool("Dcima", true);
                    animator.SetBool("DBaixo", false);
                }
                if (Input.GetKeyDown("s"))
                {
                    animator.SetBool("DBaixo", true);
                    animator.SetBool("Dcima", false);
                    dodge2.Play();
                }
                if (Input.GetKeyDown("q"))
                {
                    animator.SetBool("DEsq", true);
                    animator.SetBool("DDir", false);
                    dodge1.Play();
                }
                if (Input.GetKeyDown("e"))
                {
                    animator.SetBool("DDir", true);
                    animator.SetBool("DEsq", false);
                    dodge1.Play();
                }
                if (Input.GetKeyDown("j"))
                {
                    animator.SetBool("SocoEsq", true);
                    AL.Play();
                }
                if (Input.GetKeyDown("l"))
                {
                    AR.Play();
                    animator.SetBool("SocoDir", true);
                }
            }
        }
        else
        {
            contStart = 10f;
        }
    }
Esempio n. 2
0
    void FixedUpdate()
    {
        Debug.Log(contSocos);
        HB.fillAmount    = vida / Startvida;
        HB.color         = new Color(1f - vida / Startvida, vida / Startvida, 0, 1);
        Pbar.fillAmount  = pontos / 4f;
        PGbar.fillAmount = pontos / 4f;

        if (PauseMenu.UPHP)
        {
            addHP         += 20f;
            Startvida     += 20f;
            PauseMenu.UPHP = false;
        }
        if (PauseMenu.UPVel)
        {
            addVel         += 0.5f;
            vel            += 0.5f;
            PauseMenu.UPVel = false;
        }
        if (PauseMenu.UpForça)
        {
            addDano          += 1.5f;
            PauseMenu.UpForça = false;
        }
        if (PauseMenu.curar)
        {
            vida            = Startvida;
            PauseMenu.curar = false;
        }
        if (contInicio <= 120)
        {
            contInicio++;
        }
        if (HUD.parada || contInicio < 120)
        {
            playerpos = transform;
            animator.SetBool("DBaixo", false);
            animator.SetBool("DDir", false);
            animator.SetBool("DEsq", false);
            animator.SetBool("SocoEsq", false);
            animator.SetBool("SocoDir", false);
            animator.SetBool("InimigoBaixo", false);
            animator.SetBool("InimigoCima", false);
            rb.velocity = new Vector2(0, 0);
            return;
        }
        if (contSocos == 30)
        {
            if (pontos < 4)
            {
                pontos += 1;
            }
            contSocos = 0;
        }
        if (Perdeu)
        {
            SceneManager.LoadScene("FLOSE");
        }
        if (vida <= 0)
        {
            animator.SetTrigger("Cair");
            dead.Play();
            if (contMorto < vidas)
            {
                vida          = 3f / 4f * Startvida;
                HB.fillAmount = vida / Startvida;
                contMorto    += 1;
            }
            else
            {
                animator.SetBool("Morto", true);
                Perdeu = true;
            }
        }
        cont++;
        if (IA.AtackDL || IA.AtackDR || IA.AtackUL || IA.AtackUR)
        {
            if (!(DEsq || DDir || EDown) && vida > 0)
            {
                DANO(5f);
                if (DBaixo)
                {
                    animator.SetBool("InimigoBaixo", true);
                }
                else
                {
                    animator.SetBool("InimigoCima", true);
                }
            }
            IA.AtackDL = false;
            IA.AtackDR = false;
            IA.AtackUL = false;
            IA.AtackUR = false;
        }
        if (cont % 9 == 0)
        {
            DEsq  = false;
            DDir  = false;
            EDown = false;
            cont  = 0;
        }
        playerpos = transform;
        animator.SetBool("DBaixo", false);
        animator.SetBool("DDir", false);
        animator.SetBool("DEsq", false);
        animator.SetBool("SocoEsq", false);
        animator.SetBool("SocoDir", false);
        animator.SetBool("InimigoBaixo", false);
        animator.SetBool("InimigoCima", false);
        rb.velocity = new Vector2(0, 0);

        if (Input.GetKeyDown("w"))
        {
            animator.SetBool("Dcima", true);
            animator.SetBool("DBaixo", false);
            Dcima  = true;
            DBaixo = false;
            isDown = false;
        }
        if (Input.GetKeyDown("s"))
        {
            animator.SetBool("DBaixo", true);
            animator.SetBool("Dcima", false);
            DBaixo = true;
            Dcima  = false;
            if (isDown)
            {
                EDown = true;
                cont  = 0;
                dodge2.Play();
            }
            else
            {
                isDown = true;
                EDown  = false;
            }
        }
        if (Input.GetKey("a"))
        {
            if (transform.position.x >= -6.85f)
            {
                rb.velocity = new Vector2(-vel, 0);
            }
        }
        if (Input.GetKey("d"))
        {
            if (transform.position.x <= 6.96f)
            {
                rb.velocity = new Vector2(vel, 0);
            }
        }
        if (Input.GetKeyDown("q"))
        {
            animator.SetBool("DEsq", true);
            animator.SetBool("DDir", false);
            DEsq = true;
            DDir = false;
            cont = 0;
            dodge1.Play();
        }
        if (Input.GetKeyDown("e"))
        {
            animator.SetBool("DDir", true);
            animator.SetBool("DEsq", false);
            DDir = true;
            DEsq = false;
            cont = 0;
            dodge1.Play();
        }
        if (contDelay <= 15)
        {
            contDelay++;
        }

        if (Input.GetKeyDown("j"))
        {
            animator.SetBool("SocoEsq", true);
            SocoEsq = true;
            if (Dcima)
            {
                AL.Play();
            }
            else
            {
                ADown.Play();
            }
            contDelay = 0;
        }
        if (Input.GetKeyDown("l"))
        {
            animator.SetBool("SocoDir", true);
            SocoDir = true;
            if (Dcima)
            {
                AR.Play();
            }
            else
            {
                ADown.Play();
            }
            contDelay = 0;
        }
        if (Input.GetKeyDown("esc"))
        {
            Bpause = !Bpause;
            pause.gameObject.SetActive(Bpause);
        }
    }