Esempio n. 1
0
    void ControlaMovimento()
    {
        if (Input.GetAxis("Horizontal") == 0)
        {
            acaoAtual = Acao.Parado;
            animacao.state.SetAnimation(0, "Idle", true);
            animacao.timeScale = 0.5f;
        }
        else
        {
            acaoAtual = Acao.Andando;
            animacao.state.SetAnimation(0, "Run_3", true);
            animacao.timeScale = 1.5f;
            animacao.zSpacing  = 0f;

            if (Input.GetAxis("Horizontal") > 0)
            {
                olhar = Olhar.Direita;
            }
            else
            {
                olhar = Olhar.Esquerda;
            }
        }
    }
Esempio n. 2
0
 // Update is called once per frame
 void Update()
 {
     if (timerPulo >= 0)
     {
         timerPulo -= Time.deltaTime;
     }
     transform.localScale = new Vector3(-(int)olhar * escala.x, escala.y, escala.z);
     // FIXME debug flip
     if (Input.GetKeyDown(KeyCode.P))
     {
         olhar = (olhar == Olhar.Direita)? Olhar.Esquerda : Olhar.Direita;
     }
     // TODO adicionar animacoes
     if (estado == Estado.Vivo)
     {
         rigidbody2D.fixedAngle = true;
         SegueJogador();
         //animator.SetBool("EstaNoChao", estaNoChao);
         if (estaNoChao && querPular)
         {
             vaiPular = true;
         }
         if (!estaNoChao)
         {
             vaiPular = false;
         }
     }
     else
     {
         rigidbody2D.fixedAngle = false;
     }
 }
Esempio n. 3
0
    void ControlaMovimento()
    {
        if (inputX == 0)
        {
            acaoAtual = Acao.Parado;
        }
        else
        {
            acaoAtual = Acao.Andando;
            if (inputX > 0)
            {
                olhar = Olhar.Direita;
            }
            else
            {
                olhar = Olhar.Esquerda;
            }
        }

        estaNoChao = Physics2D.Linecast(transform.position, sensorChao.position,
                                        1 << LayerMask.NameToLayer("Chao"));
        animator.SetBool("EstaNoChao", estaNoChao);
        if (estaNoChao && Input.GetButtonDown("Jump"))
        {
            pular = true;
        }
        if (!estaNoChao)
        {
            pular = false;
        }
    }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     estado = Estado.Vivo;
     olhar = Olhar.Esquerda;
     escala = transform.localScale;
     timerPulo = 0;
     animator = GetComponent<Animator>();
 }
Esempio n. 5
0
 // Use this for initialization
 void Start()
 {
     estado    = Estado.Vivo;
     olhar     = Olhar.Esquerda;
     escala    = transform.localScale;
     timerPulo = 0;
     animator  = GetComponent <Animator>();
 }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     acaoAtual              = Acao.Parado;
     olhar                  = Olhar.Direita;
     offsetMira             = mira.position - transform.position;
     escala                 = transform.localScale;
     animator               = GetComponent <Animator>();
     JogoManager.i.gameOver = false;
 }
Esempio n. 7
0
 void SegueJogador()
 {
     Transform jogador = GameObject.FindWithTag("Player").transform;
     // fazer int. art.
     if(jogador.position.x > transform.position.x){
         olhar = Olhar.Direita;
     }
     else {
         olhar = Olhar.Esquerda;
     }
     querPular = (timerPulo <= 0)? true : false;
 }
Esempio n. 8
0
    void SegueJogador()
    {
        Transform jogador = GameObject.FindWithTag("Player").transform;

        // fazer int. art.
        if (jogador.position.x > transform.position.x)
        {
            olhar = Olhar.Direita;
        }
        else
        {
            olhar = Olhar.Esquerda;
        }
        querPular = (timerPulo <= 0)? true : false;
    }
Esempio n. 9
0
    // Use this for initialization
    void Start()
    {
        // Ocultar Cursor do Mouse
        Cursor.visible = false;
        Cursor.lockState = CursorLockMode.Confined;

        // Inicializaçao da variavel de Movimento
        move = GetComponent<Movimento> ();
        olhar = GetComponent<Olhar> ();
        acoes = GetComponent<Acoes> ();
        mira = GameObject.Find ("Mira").GetComponent<Mira> ();

        travarOlhar = false;
        travarMovimento = false;
        travarAcoes = false;
    }
Esempio n. 10
0
    void ControlaMovimento()
    {
        if(inputX == 0){
            acaoAtual = Acao.Parado;
        }
        else {
            acaoAtual = Acao.Andando;
            if(inputX > 0){
                olhar = Olhar.Direita;
            }
            else {
                olhar = Olhar.Esquerda;
            }
        }

        estaNoChao = Physics2D.Linecast(transform.position, sensorChao.position,
                                        1<<LayerMask.NameToLayer("Chao"));
        animator.SetBool("EstaNoChao", estaNoChao);
        if(estaNoChao && Input.GetButtonDown("Jump")){
            pular = true;
        }
        if(!estaNoChao) pular = false;
    }
Esempio n. 11
0
    // Update is called once per frame
    void Update()
    {
        if(timerPulo >= 0) timerPulo -= Time.deltaTime;
        transform.localScale = new Vector3(-(int)olhar * escala.x, escala.y, escala.z);
        // FIXME debug flip
        if(Input.GetKeyDown(KeyCode.P)){
            olhar = (olhar == Olhar.Direita)? Olhar.Esquerda : Olhar.Direita;
        }
        // TODO adicionar animacoes
        if(estado == Estado.Vivo){
            rigidbody2D.fixedAngle = true;
            SegueJogador();
            //animator.SetBool("EstaNoChao", estaNoChao);
            if(estaNoChao && querPular){
                vaiPular = true;
            }
            if(!estaNoChao) vaiPular = false;

        }
        else {
            rigidbody2D.fixedAngle = false;
        }
    }
Esempio n. 12
0
    void ControlaTiros()
    {
        if (Input.GetButton("Atirar") && gJogo.g.inventario.ContaItem(gJogo.g.inventario.municao) <= 0)
        {
            StartCoroutine(gJogo.g.MostraMsgJogadorCurta("no ammo!"));
        }

        // quando acabou de pressionar o botao de tiro
        if (Input.GetButtonDown("Atirar") && acaoAtual != Acao.Atirando && gJogo.g.inventario.ContaItem(gJogo.g.inventario.municao) > 0)
        {
            acaoAtual = Acao.Atirando;
            animacao.state.SetAnimation(0, "Idle", true);
            motor.canControl = false;
            mira.gameObject.SetActive(true);

            if (olhar == Olhar.Direita)
            {
                mira.position = transform.position + new Vector3(offsetMira.x, offsetMira.y, 0);
            }
            else
            {
                mira.position = transform.position + new Vector3(-offsetMira.x, offsetMira.y, 0);
            }
        }

        // quando esta segurando o botao de tiro
        if (Input.GetButton("Atirar") && acaoAtual == Acao.Atirando)
        {
            float novoAnguloMira = 0f;

            float anguloAnterior =
                Mathf.Atan2(mira.position.y - transform.position.y,
                            mira.position.x - transform.position.x) * 180 / Mathf.PI;


            if (anguloAnterior <= 90f && anguloAnterior >= -90f)
            {
                olhar = Olhar.Direita;
            }
            if (anguloAnterior > 90f || anguloAnterior < -90f)
            {
                olhar = Olhar.Esquerda;
            }

            if (Input.GetAxis("Vertical") > 0)
            {
                novoAnguloMira += (olhar == Olhar.Direita)?
                                  velocidadeMira : -velocidadeMira;
            }
            else if (Input.GetAxis("Vertical") < 0)
            {
                novoAnguloMira += (olhar == Olhar.Esquerda)?
                                  velocidadeMira : -velocidadeMira;
            }

            float anguloFinal = anguloAnterior + novoAnguloMira;

            if (olhar == Olhar.Direita)
            {
                anguloFinal = Mathf.Clamp(
                    anguloFinal, -90f + velocidadeMira * 2,
                    90f - velocidadeMira * 2);
            }
            if (olhar == Olhar.Esquerda)
            {
                if (anguloFinal > -90f - velocidadeMira * 2 && anguloFinal < 0)
                {
                    anguloFinal = -90f - velocidadeMira * 2;
                }
                else if (anguloFinal < 90f + velocidadeMira * 2 && anguloFinal > 0)
                {
                    anguloFinal = 90f + velocidadeMira * 2;
                }
            }

            anguloFinal -= anguloAnterior;
            mira.RotateAround(transform.position, transform.forward, anguloFinal);
        }

        // quando solta o botao de tiro
        if (Input.GetButtonUp("Atirar") && acaoAtual == Acao.Atirando)
        {
            acaoAtual        = Acao.Parado;
            motor.canControl = true;
            if (gJogo.g.inventario.DescarregaItem(gJogo.g.inventario.BuscaItemCarregado(gJogo.g.inventario.municao)))
            {
                Transform projetil = GameObject.Instantiate(
                    Resources.Load <Transform>("Itens/" + gJogo.g.inventario.municao),
                    transform.position + new Vector3((int)olhar * 0.6f, 1.5f, 0f),
                    Quaternion.identity
                    ) as Transform;
                projetil.GetComponent <ItemMundo>().info = gJogo.g.inventario.BuscaItemInfo(gJogo.g.inventario.municao);
                projetil.LookAt(mira.position);
                projetil.rigidbody.AddForce(projetil.forward * 20f, ForceMode.VelocityChange);
            }
            else
            {
                StartCoroutine(gJogo.g.MostraMsgJogadorCurta("no ammo!"));
            }
            mira.gameObject.SetActive(false);
        }
    }
Esempio n. 13
0
 // Use this for initialization
 void Start()
 {
     acaoAtual = Acao.Parado;
     olhar = Olhar.Direita;
     offsetMira = mira.position - transform.position;
     escala = transform.localScale;
     animator = GetComponent<Animator>();
     //JogoManager.i.gameOver = false;
 }