void Update() { if (interagir != null) { interagir.SetActive(false); } if (Objetivo.obj != "Broto" && Objetivo.obj != "Pá" && Objetivo.obj != "Vulcão") { this.gameObject.tag = "Removido"; fumaca.SetTrigger("Fumaca"); GetComponent <SpriteRenderer>().sprite = vulcoesAbertos[Random.Range(0, 2)]; } indicador.GetComponent <SpriteRenderer>().enabled = false; barra.GetComponent <SpriteRenderer>().enabled = false; barra.GetComponent <SpriteRenderer>().sprite = sNivel[nivel - 1]; hit = Physics2D.CircleCastAll(transform.position + (Vector3.up * 0.2f), 0.3f, transform.up); foreach (RaycastHit2D i in hit) { if (i.collider != null) { var other = i.collider.gameObject; //colisões if (other.tag == "Player" && Objetivo.obj == "Vulcão" && ((gameObject.tag == "Balde") ? ((other.GetComponent <controladorJogador>().encontrouRosa) ? true : false) : true)) { p = other.GetComponent <controladorJogador>(); indicador.GetComponent <SpriteRenderer>().enabled = p.podePa; barra.GetComponent <SpriteRenderer>().enabled = p.podePa; if (p.podePa) { #if UNITY_ANDROID interagir.SetActive(true); #endif if (direita && move) { indicador.transform.Translate(Vector3.right * Time.deltaTime * velocidadeBarra[nivel - 1]); print(velocidadeBarra[nivel - 1]); direita = (indicador.transform.localPosition.x < 4.8f); } else if (!direita && move) { indicador.transform.Translate(-Vector3.right * Time.deltaTime * velocidadeBarra[nivel - 1]); direita = (indicador.transform.localPosition.x <= -4.8f); } #if UNITY_ANDROID if (interagiu && move) { interagiu = false; switch (nivel) { case 1: if (indicador.transform.localPosition.x > -1.6 && indicador.transform.localPosition.x < 1.6) { StartCoroutine(Pisca(new Color(0.5f, 1, 0.5f, 1))); nivel++; } else { StartCoroutine(Pisca(new Color(1, 0.5f, 0.5f, 1))); } break; case 2: if (indicador.transform.localPosition.x > -1.6 && indicador.transform.localPosition.x < 1.6) { StartCoroutine(Pisca(new Color(0.5f, 1, 0.5f, 1))); nivel++; } else { StartCoroutine(Pisca(new Color(1, 0.5f, 0.5f, 1))); nivel = 1; } break; case 3: if (indicador.transform.localPosition.x > -1.6 && indicador.transform.localPosition.x < 1.6) { GameObject.FindWithTag("Sound").GetComponent <Sons>().PlaySound("vulcao"); p.contVulcao += (gameObject.tag == "Balde") ? 0 : 1; p.contador.text = (p.contVulcao.ToString() + "/5"); Destroy(indicador); Destroy(barra); if (p.contVulcao == 5) { p.MudaIconePa(); } if (gameObject.tag == "Balde") { this.gameObject.tag = "Removido"; Objetivo.SetObjetivo("Poço"); p.balde = true; Destroy(this.gameObject); } else { this.gameObject.tag = "Removido"; Objetivo.SetObjetivo("Vulcão"); other.GetComponent <Animator>().SetTrigger("pasadaVulcao"); Invoke("trocouVulcao", 1.5f); p.VulcaoDespisca(); fumaca.SetTrigger("Fumaca"); } interagir.SetActive(false); Destroy(this); } else { StartCoroutine(Pisca(new Color(1, 0.5f, 0.5f, 1))); nivel = 1; } break; } } #else if (Input.GetButtonDown("Fire1") && move) { switch (nivel) { case 1: if (indicador.transform.localPosition.x > -1.6 && indicador.transform.localPosition.x < 1.6) { StartCoroutine(Pisca(new Color(0.5f, 1, 0.5f, 1))); nivel++; } else { StartCoroutine(Pisca(new Color(1, 0.5f, 0.5f, 1))); } break; case 2: if (indicador.transform.localPosition.x > -1.6 && indicador.transform.localPosition.x < 1.6) { StartCoroutine(Pisca(new Color(0.5f, 1, 0.5f, 1))); nivel++; } else { StartCoroutine(Pisca(new Color(1, 0.5f, 0.5f, 1))); nivel = 1; } break; case 3: if (indicador.transform.localPosition.x > -1.6 && indicador.transform.localPosition.x < 1.6) { GameObject.FindWithTag("Sound").GetComponent <Sons>().PlaySound("vulcao"); p.contVulcao += (gameObject.tag == "Balde") ? 0 : 1; p.contador.text = (p.contVulcao.ToString() + "/5"); Destroy(indicador); Destroy(barra); if (p.contVulcao == 5) { p.MudaIconePa(); } if (gameObject.tag == "Balde") { this.gameObject.tag = "Removido"; Objetivo.SetObjetivo("Poço"); p.balde = true; Destroy(this.gameObject); } else { this.gameObject.tag = "Removido"; Objetivo.SetObjetivo("Vulcão"); other.GetComponent <Animator>().SetTrigger("pasadaVulcao"); Invoke("trocouVulcao", 1.5f); p.VulcaoDespisca(); fumaca.SetTrigger("Fumaca"); } Destroy(this); } else { StartCoroutine(Pisca(new Color(1, 0.5f, 0.5f, 1))); nivel = 1; } break; } } #endif } } } } }
private void Start() { player = GameObject.FindWithTag("Player").GetComponent <controladorJogador>(); }
void Start() { vida = GameObject.Find("Vidas").GetComponent <Life>(); player = GameObject.FindWithTag("Player"); playerS = GameObject.Find("Player").GetComponent <controladorJogador>(); }