コード例 #1
0
    void Start()
    {
#if UNITY_ANDROID
        primeiroPoco = false;
        mobileButtons.SetActive(true);
        jaEnsinou = true;
#else
        primeiroPoco = true;
        mobileButtons.SetActive(false);
#endif
        if (Objetivo.obj == "Balde")
        {
            Objetivo.SetObjetivo("Rosa");
        }

        Pa.SetActive(Objetivo.obj == "Pá");
        planeta.transform.eulerAngles = Vector3.forward * rotaCheck;
        Time.timeScale = 1;
        level          = 0;
        contVulcao     = 0;
        tocaSons       = GameObject.FindWithTag("Sound");
        animator       = GetComponent <Animator>();
        renderer       = GetComponent <SpriteRenderer>();
        rbPlayer       = GetComponent <Rigidbody2D>();
        parar          = true;
        Invoke("NoParar", 6.5f);
    }
コード例 #2
0
    void Update()
    {
        podePa = Objetivo.obj != "Pá";

        aceleracao = aclPubli;

        pJoy.SetActive(!MenuBotoesBehaviour.controleVisivel);
        pBut.SetActive(MenuBotoesBehaviour.controleVisivel);

        if (Input.GetButtonDown("Cancel"))
        {
            if (pause.GetComponent <Animator>().GetBool("perde"))
            {
                pause.GetComponent <MenuBotoesBehaviour>().Despausa();
            }
            else
            {
                pause.GetComponent <Animator>().SetBool("perde", !pause.GetComponent <Animator>().GetBool("perde"));
                Time.timeScale = 0;
            }
        }
#if UNITY_STANDALONE
        movimento = Input.GetAxisRaw("Horizontal");
#elif UNITY_ANDROID
        movimento = joystick.Horizontal;
#endif
        if (contBroto == 6)
        {
            Objetivo.SetObjetivo("Vulcão");
            rotaCheck     = 140;
            contador.text = (contVulcao.ToString() + "/5");
            iconeBroto.GetComponent <Image>().color  = new Color(1, 1, 1, 0.5f);
            iconeBroto.GetComponent <Image>().sprite = imgVulcao;
            iconeBroto.GetComponent <IconesBehaviour>().Comeca();
            contBroto++;
        }
        if (contVulcao == 5)
        {
            contVulcao++;
            Objetivo.SetObjetivo("Rosa");
        }
        if (contBaldada == 6)
        {
            contBaldada++;
            Objetivo.SetObjetivo("eventWins");
        }
        Jump();
        Raycasts();
    }
コード例 #3
0
    void Raycasts()
    {
        hit    = Physics2D.RaycastAll(transform.position - new Vector3(0, 0.8f), -transform.up, 0.7f);
        noChao = Physics2D.OverlapCircle(transform.position - new Vector3(0, 0.84f), 1f, LayerMask.GetMask("Chao"));
        for (int i = 0; i < hit.Length; i++)
        {
            if (hit[i].collider != null)
            {
#if UNITY_ANDROID
                interagir.SetActive(hit[i].collider.gameObject.tag == "Broto" && podePa);
#endif
                if (hit[i].collider.gameObject.tag == "Broto")
                {
                    var other = hit[i].collider.gameObject;
                    if (other.tag == "Broto" && (Input.GetButtonDown("Fire1") || coletar) && podePa && !(contBroto >= 6) && velocidade <= 0.0001)
                    {
                        coletar   = false;
                        other.tag = "Removido";
                        Objetivo.SetObjetivo("Broto");
                        other.transform.GetChild(1).gameObject.SetActive(false);
                        tocaSons.GetComponent <Sons>().PlaySound("broto");
                        contBroto++;
                        contador.text = (contBroto.ToString() + "/6");
                        animator.SetTrigger("pasada");
                        other.GetComponent <SpriteRenderer>().sprite = terra;
                        //other.GetComponent<Transform>().localScale /= 2;
                        Destroy(other.GetComponent <BoxCollider2D>());
                        iconeBroto.GetComponent <IconesBehaviour>().QuebraRepeticao();
                        iconeBroto.GetComponent <Image>().enabled = true;
                        iconeBroto.GetComponent <Image>().color   = new Color(1, 1, 1, 1);
                        other.GetComponent <Broto>().Poeira();
                        parar = true;
                        Invoke("NoParar", 0.8f);
                    }
                    else if (other.tag == "Broto" && Input.GetButtonDown("Fire1") && !podePa && iconeUmaVez)
                    {
                        iconeUmaVez = false;
                        iconePa.GetComponent <IconesBehaviour>().Comeca();
                    }
                }
            }
        }
    }
コード例 #4
0
 private void OnTriggerStay2D(Collider2D other)
 {
     if (other.tag == "Pá")
     {
         Objetivo.SetObjetivo("Broto");
         rotaCheck = -45;
         tocaSons.GetComponent <Sons>().PlaySound("pá");
         podePa = true;
         Destroy(iconePa.GetComponent <IconesBehaviour>());
         iconePa.GetComponent <Image>().enabled = true;
         iconePa.GetComponent <Image>().color   = new Color(1, 1, 1, 1);
         iconeBroto.GetComponent <IconesBehaviour>().Comeca();
         Destroy(other.gameObject);
     }
     else if (other.tag == balaoNoSim && podePa && !jaEnsinou)
     {
         other.transform.GetChild(1).gameObject.SetActive(true);
         jaEnsinou = true;
     }
 }
コード例 #5
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (col.tag == "eventRosa" && contVulcao >= 5)
     {
         rotaCheck = 250;
         Objetivo.SetObjetivo("Balde");
         tocaSons.GetComponent <Sons>().PlaySound("rosa");
         col.gameObject.transform.parent.GetComponent <Animator>().SetBool("murchando", true);
         RealcaIconePa();
         encontrouRosa = true;
         parar         = true;
         flor.GetComponent <Animator>().SetBool("encontrouRosa", true);
         Invoke("NoParar", 2f);
         Destroy(col.gameObject);
     }
     if (col.tag == "eventWins" && contVulcao >= 5 && contBaldada >= 6)
     {
         col.gameObject.transform.parent.GetComponent <Animator>().SetBool("murchando", false);
         PlayerPrefs.SetInt("Planet", 0);
         //if (!ExploreController.instance.arcade) SceneManager.LoadScene("AvoidanceTravel");
         //if (ExploreController.instance.arcade)
         SceneManager.LoadScene("Wins");
     }
 }
コード例 #6
0
    void Update()
    {
        indexArray       = (profundidade <= 0 && bPoco) ? ((cAgua) ? 2 : 1) : 0;
        cRenderer.sprite = sprites[indexArray];
        hit = Physics2D.CircleCastAll(this.transform.position, 2, -transform.up, 2);

        for (int i = 0; i < hit.Length; i++)
        {
            if (hit[i].collider != null)
            {
                var other = hit[i].collider.gameObject;
                if (other.tag == "Player")
                {
#if UNITY_ANDROID
                    if (bPoco)
                    {
                        setas.SetActive(true);
                    }
                    else
                    {
                        setas.SetActive(false);
                    }
                    if (other.GetComponent <controladorJogador>().balde || (bPoco && profundidade <= 0))
                    {
                        interagir.SetActive(true);
                    }
                    else
                    {
                        interagir.SetActive(false);
                    }
                    if (interagiu && other.GetComponent <controladorJogador>().balde&& !bPoco)
                    {
                        interagiu = false;
                        cAgua     = false;
                        other.GetComponent <controladorJogador>().balde = false;
                        bPoco = true;
                        iconeBalde.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1);
                    }
                    else if (interagiu && !other.GetComponent <controladorJogador>().balde&& bPoco && profundidade <= 0)
                    {
                        interagiu = false;
                        if (capacidade <= 0)
                        {
                            this.transform.GetChild(0).gameObject.tag = "Removido";
                            Objetivo.SetObjetivo("Poço");
                            Feed();
                        }
                        bPoco = false;
                        other.GetComponent <controladorJogador>().balde  = true;
                        iconeBalde.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.5f);
                        if (indexArray == 2)
                        {
                            other.GetComponent <controladorJogador>().aguaCantil.fillAmount += 0.15f;
                            other.GetComponent <controladorJogador>().AddFlor();
                            other.GetComponent <controladorJogador>().contBaldada++;
                        }
                    }
                    if (bPoco)
                    {
                        if (vertical > 0)
                        {
                            profundidade -= (profundidade < 0) ? 0 : Time.deltaTime;
                            cAnim.enabled = (vertical != 0 && profundidade >= 0);
                        }
                        else if (vertical < 0)
                        {
                            profundidade += (profundidade > 1) ? 0 : Time.deltaTime;
                            cAnim.enabled = (vertical != 0 && profundidade <= 1);
                        }
                        else
                        {
                            profundidade  = (Mathf.Abs(profundidade) < 0.05f) ? 0 : profundidade;
                            cAnim.enabled = false;
                        }
                        if (capacidade > 0 && profundidade >= 1 && !cAgua)
                        {
                            baldeIn.Play();
                            cAgua = true;
                            capacidade--;
                        }
                        else if (capacidade <= 0 && profundidade <= 0.08f && !cAgua)
                        {
                            cAgua = false;
                        }
                    }
#else
                    if (Input.GetButtonDown("Fire1") && other.GetComponent <controladorJogador>().balde&& !bPoco)
                    {
                        cAgua = false;
                        other.GetComponent <controladorJogador>().balde = false;
                        bPoco = true;
                        iconeBalde.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1);
                    }
                    else if (Input.GetButtonDown("Fire1") && !other.GetComponent <controladorJogador>().balde&& bPoco && profundidade <= 0)
                    {
                        if (capacidade <= 0)
                        {
                            this.transform.GetChild(0).gameObject.tag = "Removido";
                            Objetivo.SetObjetivo("Poço");
                            Feed();
                        }
                        bPoco = false;
                        other.GetComponent <controladorJogador>().balde  = true;
                        iconeBalde.GetComponent <SpriteRenderer>().color = new Color(1, 1, 1, 0.5f);
                        if (indexArray == 2)
                        {
                            other.GetComponent <controladorJogador>().aguaCantil.fillAmount += 0.15f;
                            other.GetComponent <controladorJogador>().AddFlor();
                            other.GetComponent <controladorJogador>().contBaldada++;
                        }
                    }
                    if (bPoco)
                    {
                        if (Input.GetAxisRaw("Vertical") > 0)
                        {
                            profundidade -= (profundidade < 0) ? 0 : Time.deltaTime;
                            cAnim.enabled = (Input.GetAxisRaw("Vertical") != 0 && profundidade >= 0);
                        }
                        else if (Input.GetAxisRaw("Vertical") < 0)
                        {
                            profundidade += (profundidade > 1) ? 0 : Time.deltaTime;
                            cAnim.enabled = (Input.GetAxisRaw("Vertical") != 0 && profundidade <= 1);
                        }
                        else
                        {
                            profundidade  = (Mathf.Abs(profundidade) < 0.05f) ? 0 : profundidade;
                            cAnim.enabled = false;
                        }
                        if (capacidade > 0 && profundidade >= 1 && !cAgua)
                        {
                            baldeIn.Play();
                            cAgua = true;
                            capacidade--;
                        }
                        else if (capacidade <= 0 && profundidade <= 0.08f && !cAgua)
                        {
                            cAgua = false;
                        }
                    }
#endif
                }
            }
        }
    }
コード例 #7
0
    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
                    }
                }
            }
        }
    }