Exemple #1
0
    // Use this for initialization
    void Start()
    {
        controle = GetComponent<CharacterController>();
        animator = GetComponent<Animator>();
        H = GameObject.FindGameObjectWithTag("Player").GetComponent<heroi>();

        Y = new caracteristicasBasicas();
        if (!GameObject.Find("CriatureAtivo") && !variaveisChave.shift["adiciona O Criature"])
            adicionaOCriature();

        cam = GetComponent<cameraPrincipal>();

        textos = bancoDeTextos.falacoes[heroi.lingua]["movimentoBasico"].ToArray();
    }
Exemple #2
0
    void maisUmAtualizaSuavemente(float v, float h, caracteristicasBasicas X, Vector3 direcaoAlvo)
    {
        // moveDirection is always normalized, and we only update it if there is user input.
        if (direcaoAlvo != Vector3.zero)
        {
            // If we are really slow, just snap to the target direction
            if (controle.velocity.magnitude < X.velocidadeCorrendo * 0.9f && noChao(X.distanciaFundamentadora))
            {
                direcaoMovimento = direcaoAlvo.normalized;
            }
            // Otherwise smoothly turn towards it
            else
            {
                direcaoMovimento = Vector3.RotateTowards(direcaoMovimento, direcaoAlvo, 500 * Mathf.Deg2Rad * Time.deltaTime, 1000);

                direcaoMovimento = direcaoMovimento.normalized;
            }
        }
    }
Exemple #3
0
    protected void verificaPulo(Vector3 direcaoMovimento, caracteristicasBasicas Y)
    {
        if (estavaPulando == false && pulo == true)
        {
            tempoDePulo = 0;
        }

        estavaPulando = pulo;

        //print(tempoDePulo+" : "+tempoMaxPulo+" : "+pulo);
        if (
            pulo == true
            &&
            (transform.position.y - ultimoYFundamentado < Y.apiceDoPulo
             &&
             tempoDePulo < tempoMaxPulo
            ))
        {
            tempoDePulo      += Time.deltaTime;
            movimentoVertical = (direcaoMovimento * Y.velocidadeNoAr + Vector3.up * Y.velocidadeSubindo);
            controle.Move(movimentoVertical * Time.deltaTime);
        }
        else if (
            (transform.position.y - ultimoYFundamentado >= Y.apiceDoPulo
             ||
             tempoDePulo >= tempoMaxPulo
            )
            &&
            pulo == true)
        {
            pulo = false;
        }
        else if (pulo == false)
        {
            movimentoVertical = Vector3.Lerp(movimentoVertical,
                                             (direcaoMovimento * Y.velocidadeAndando + Vector3.down * Y.velocidadeCaindo),
                                             3 * Time.deltaTime);          //Y.apliqueGravidade(movimentoVertical,direcaoMovimento);
            controle.Move(movimentoVertical * Time.deltaTime);
            //tempoDePulo = 0;
        }
    }
Exemple #4
0
    protected void aplicaRotacao(caracteristicasBasicas Y, Vector3 direcaoMovimento, float v, float h)
    {
        if (Input.GetButton("Correr"))
        {
            Y.rot = Y.velocidadeDeRotacaoCorrendo;
            //Y.velocidade = Y.velocidadeCorrendo;
        }
        else
        {
            Y.rot = Y.velocidadeDeRotacao;
            //Y.velocidade = Y.velocidadeAndando;
        }

        if (v > 0)
        {
            //controle.Move ((direcaoMovimento)*velocidade*Time.deltaTime);
            transform.rotation = Quaternion.Lerp(
                transform.rotation,
                Quaternion.LookRotation(direcaoMovimento),
                Time.deltaTime * Y.rot
                );
        }
        else if (Mathf.Abs(h) > 0 && v >= 0)
        {
            transform.rotation = Quaternion.Lerp(
                transform.rotation,
                Quaternion.LookRotation(direcaoMovimento),
                Time.deltaTime * Y.velocidadeDeRotacaoParado
                );
        }
        else if (v < 0)
        {
            transform.rotation = Quaternion.Lerp(
                transform.rotation,
                Quaternion.LookRotation(direcaoMovimento),
                Time.deltaTime * Y.velocidadeDeRotacao
                );
        }
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        controle = GetComponent<CharacterController> ();
        animator = GetComponent<Animator> ();
        H = GameObject.FindGameObjectWithTag("Player").GetComponent<heroi>();

        Y = new caracteristicasBasicas ();
        if(!GameObject.Find("CriatureAtivo") && !variaveisChave.shift["adiciona O Criature"])
            adicionaOCriature();

        cam = GetComponent<cameraPrincipal>();

        textos = bancoDeTextos.falacoes[heroi.lingua]["movimentoBasico"].ToArray();
    }
Exemple #6
0
    void maisUmAtualizaSuavemente(float v,float h,caracteristicasBasicas X,Vector3 direcaoAlvo)
    {
        // moveDirection is always normalized, and we only update it if there is user input.
        if (direcaoAlvo != Vector3.zero)
        {
            // If we are really slow, just snap to the target direction
            if (controle.velocity.magnitude < X.velocidadeCorrendo* 0.9f  && noChao(X.distanciaFundamentadora))
            {
                direcaoMovimento = direcaoAlvo.normalized;
            }
            // Otherwise smoothly turn towards it
            else
            {
                direcaoMovimento = Vector3.RotateTowards(direcaoMovimento, direcaoAlvo, 500 * Mathf.Deg2Rad * Time.deltaTime, 1000);

                direcaoMovimento = direcaoMovimento.normalized;
            }
        }
    }
Exemple #7
0
    protected void verificaPulo(Vector3 direcaoMovimento,caracteristicasBasicas Y)
    {
        if(estavaPulando==false&& pulo==true)
            tempoDePulo = 0;

        estavaPulando = pulo;

        //print(tempoDePulo+" : "+tempoMaxPulo+" : "+pulo);
        if (
            pulo == true
            &&
            (transform.position.y - ultimoYFundamentado < Y.apiceDoPulo
         &&
         tempoDePulo<tempoMaxPulo
         ))
        {
            tempoDePulo+=Time.deltaTime;
            movimentoVertical = (direcaoMovimento * Y.velocidadeNoAr + Vector3.up * Y.velocidadeSubindo);
            controle.Move (movimentoVertical * Time.deltaTime);
        } else if (
            (transform.position.y - ultimoYFundamentado >= Y.apiceDoPulo
         ||
         tempoDePulo>=tempoMaxPulo
         )
            &&
            pulo == true) {
            pulo = false;
        } else if (pulo == false) {
            movimentoVertical = Vector3.Lerp(movimentoVertical,
                                             (direcaoMovimento * Y.velocidadeAndando + Vector3.down * Y.velocidadeCaindo),
                                             3*Time.deltaTime);//Y.apliqueGravidade(movimentoVertical,direcaoMovimento);
            controle.Move (movimentoVertical * Time.deltaTime);
            //tempoDePulo = 0;

        }
    }
Exemple #8
0
    protected void aplicaRotacao(caracteristicasBasicas Y,Vector3 direcaoMovimento,float v,float h)
    {
        if (Input.GetButton ("Correr")) {
            Y.rot = Y.velocidadeDeRotacaoCorrendo;
            //Y.velocidade = Y.velocidadeCorrendo;
        } else {
            Y.rot = Y.velocidadeDeRotacao;
            //Y.velocidade = Y.velocidadeAndando;
        }

        if (v > 0) {

            //controle.Move ((direcaoMovimento)*velocidade*Time.deltaTime);
            transform.rotation = Quaternion.Lerp (
                transform.rotation,
                Quaternion.LookRotation (direcaoMovimento),
                Time.deltaTime * Y.rot
                );
        } else if (Mathf.Abs (h) > 0 && v>=0)
            transform.rotation = Quaternion.Lerp (
                transform.rotation,
                Quaternion.LookRotation (direcaoMovimento),
                Time.deltaTime * Y.velocidadeDeRotacaoParado
                );
        else if(v<0)
            transform.rotation = Quaternion.Lerp (
                transform.rotation,
                Quaternion.LookRotation (direcaoMovimento),
                Time.deltaTime * Y.velocidadeDeRotacao
                );
    }