Exemplo n.º 1
0
    public void Juntar(ObjLixoMisturado outro)
    {
        int novoNivel = this.Nivel() + outro.Nivel();

        Vector2 pos = (Vector2) transform.position;

        this.Remover();
        outro.Remover();

        ObjGerenciadorLixo.CriarLixoEstatico(novoNivel, pos);

        //lixoMisturado.Fundir(outro.lixoMisturado);
        //AjeitarTexto();
        //Debug.Log ("Aumentar tamanho e afins");
        //PararBrilhoJuntar();
    }
Exemplo n.º 2
0
    void JuntarLixo()
    {
        PararJuncao();
        if (listaLixos.Count > 1)
        {
            // -1: aleatorio; 0: menor; 1: maior;
            int tipoDeBusca = -1;
            if (Random.value < 0.6f)
            {
                tipoDeBusca = 0;
            }
            else if (tipoDeBusca < 0.8f)
            {
                tipoDeBusca = 1;
            }

            if (tipoDeBusca == 0)
            {
                lixoPuxando = PegarMenorLixo();
                foreach(ObjLixoMisturado olm in listaLixos)
                {
                    if (olm.PodeJuntar(lixoPuxando) &&
                        olm.Nivel() <= lixoPuxando.Nivel())
                    {
                        lixoSendoPuxado = olm;
                        break;
                    }
                }
                if (lixoSendoPuxado == null)
                {
                    int i = (listaLixos.IndexOf(lixoPuxando) + 1)
                        % listaLixos.Count;
                    lixoSendoPuxado = listaLixos[i];
                }

                //Debug.Log("Juntar menores");
            }
            else if (tipoDeBusca == 1)
            {
                lixoPuxando = PegarMaiorLixo();
                foreach(ObjLixoMisturado olm in listaLixos)
                {
                    if (olm.PodeJuntar(lixoPuxando) &&
                        olm.Nivel() >= lixoPuxando.Nivel())
                    {
                        lixoSendoPuxado = olm;
                        break;
                    }
                }
                if (lixoSendoPuxado == null)
                {
                    int i = (listaLixos.IndexOf(lixoPuxando) + 1)
                        % listaLixos.Count;
                    lixoSendoPuxado = listaLixos[i];
                }
                //Debug.Log("Juntar maiores");
            }
            else
            {
                int i = Random.Range (0, listaLixos.Count);
                lixoPuxando = listaLixos[i];
                lixoSendoPuxado = lixoPuxando;
                int contador = 1000;
                while (lixoPuxando == lixoSendoPuxado && contador > 0)
                {
                    i = Random.Range (0, listaLixos.Count);
                    lixoSendoPuxado = listaLixos[i];
                    contador--;
                }
                if (contador <= 0)
                {
                    i = (listaLixos.IndexOf(lixoPuxando) + 1)
                        % listaLixos.Count;
                    lixoSendoPuxado = listaLixos[i];
                }
                //Debug.Log("Juntar aleatórios");
            }

            if (lixoSendoPuxado != null)
            {
                juntandoLixos	= true;
                podeJuntarLixo	= false;

                lixoPuxando.BrilharJuntar();
                lixoSendoPuxado.BrilharJuntar();

                velocidadeJuncaoLixos =
                    lixoPuxando.transform.position -
                        lixoSendoPuxado.transform.position;

                velocidadeJuncaoLixos /= demoraPraJuntarLixos;

                proximoTempoFinalizarJuncao =
                    Time.time + demoraPraJuntarLixos;
            }
        }
    }