public int check() { int contador = 0; for (int i = 0; i < 100; i++) { if (STutorial.Substring(i, 1) == SUsuario.Substring(i, 1)) { contador++; } } return(contador); }
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; } }