void Update()
    {
        //Movimiento

        if (!stunned)
        {
            float movX = 0, movY = 0;

            if (Input.GetAxis("Horizontal") >= 0.2)
            {
                movX = 1;
            }
            else if (Input.GetAxis("Horizontal") <= -0.2)
            {
                movX = -1;
            }
            if (Input.GetAxis("Vertical") >= 0.2)
            {
                movY = 1;
            }
            else if (Input.GetAxis("Vertical") <= -0.2)
            {
                movY = -1;
            }

            movement = new Vector2(movX, movY);
        }

        //Lanza
        if (Input.GetButtonDown("Fire2") && tengolanza && !stunned)
        {
            tengolanza = false;

            gm.changeSpearStateUI();

            GameObject projectile;

            if (venenoLanza)
            {
                projectile = Instantiate(lanza[1], direction.transform.position, direction.transform.rotation);
                PlayerAttackDMG dañoProy = projectile.GetComponent <PlayerAttackDMG>();
                if (dañoProy)
                {
                    dañoProy.ActivatePoison();
                }
            }
            else
            {
                projectile = Instantiate(lanza[0], direction.transform.position, direction.transform.rotation);
            }
        }
        else if (Input.GetButtonDown("Fire3"))
        {
            GameManager.GetInstance().Heal();
        }

        //Dash
        else if (Input.GetButtonDown("Jump") && dashCooldown <= 0 && !stunned)
        {
            dashScript.ExecuteDash(ref dashCooldown);
        }

        if (dashCooldown > 0)
        {
            dashCooldown -= Time.deltaTime;
        }

        //Ataque

        if (Input.GetButtonDown("Fire1") && !stunned)
        {
            Attack attack = (Attack)attackRoot[activeAttack];

            attack.DoAttack();
        }

        else if (haveTrice && Input.GetButtonDown("EscudoTriceratops") && !stunned)
        {
            Attack attackTriceratops = (Attack)attackRootTriceratops;

            attackTriceratops.DoAttack();
        }

        if (haveAnkylo && canChange && Input.GetAxis("ChangeAttackF") > 0.1)
        {
            ChangeAttack(1);
        }
        else if (haveAnkylo && !canChange && Input.GetAxis("ChangeAttackF") < 0.1)
        {
            canChange = true;
        }
        //MOVIMIENTO

        //izquierda
        if (movement.x < 0 && movement.y == 0)
        {
            playerAnimator.Play("PlayerLateralLeftWalking");

            direction.transform.up = Vector2.left;
        }

        //abajo
        else if (movement.x == 0 && movement.y < 0)
        {
            playerAnimator.Play("PlayerFrontWalking");

            direction.transform.up = Vector2.down;
        }

        //arriba
        else if (movement.x == 0 && movement.y > 0)
        {
            playerAnimator.Play("PlayerBackWalking");

            direction.transform.up = Vector2.up;
        }

        //derecha
        else if (movement.x > 0 && movement.y == 0)
        {
            playerAnimator.Play("PlayerLateralRightWalking");

            direction.transform.up = Vector2.right;
        }

        //diagonal abajo izquierda
        else if (movement.x < 0 && movement.y < 0)
        {
            playerAnimator.Play("PlayerDiagonalLeftWalking");

            direction.transform.up = Vector2.down + Vector2.left;
        }

        //diagonal arriba izquierda
        else if (movement.x < 0 && movement.y > 0)
        {
            playerAnimator.Play("PlayerDiagonalBackLeftWalking");

            direction.transform.up = Vector2.up + Vector2.left;
        }

        //diagonal abajo derecha
        else if (movement.x > 0 && movement.y < 0)
        {
            playerAnimator.Play("PlayerDiagonalRightWalking");

            direction.transform.up = Vector2.down + Vector2.right;
        }

        //diagonal arriba derecha
        else if (movement.x > 0 && movement.y > 0)
        {
            playerAnimator.Play("PlayerDiagonalBackRightWalking");

            direction.transform.up = Vector2.up + Vector2.right;
        }

        //parado
        else if ((movement.x == 0 && movement.y == 0))
        {
            playerAnimator.Play("PlayerStopped");

            //direction.transform.up = Vector2.down;
        }

        if (Input.GetButtonDown("MenuPausa"))
        {
            menuMg.MenuPausa();
        }
    }
Esempio n. 2
0
 public void Dash()
 {
     dash.ExecuteDash();
 }