예제 #1
0
    // Update is called once per frame
    void Update()
    {
        if (_box.IsTouchingLayers() && inmunnity.Finished)
        {
            takeDamage(1);
            inmunnity.Run();
            //Debug.Log("vida: "+healt);
            if (health == 0)
            {
                Debug.Log("U DED");
                OnBecameInvisible();
                health = Max_health;
                scriptUI.setVida((int)Max_health);
            }
        }

        //_grounded = IsGrounded();


        if (Input.GetKeyDown(KeyCode.LeftShift))
        {
            _fixed = true;
        }
        if (Input.GetKeyUp(KeyCode.LeftShift))
        {
            _fixed = false;
        }

        if (Input.GetKeyDown(KeyCode.Q))
        {
            Ability(1);
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            Ability(2);
        }

        if (Input.GetKeyDown(KeyCode.R) && _playerIsLight != true)
        {
            slowFall();
        }

        if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.LeftArrow))
        {
            if (!selectorActivo)
            {
                scriptUI.activarUISelector();
                selectorActivo = true;
                StartCoroutine(deactivateUISelector());
            }
            else
            {
                StopCoroutine(deactivateUISelector());
                scriptUI.desactivarUISelector();
                selectorActivo = false;
            }
        }


        //_inputAxis = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
        if (IsGrounded())
        {
            _jump = true;
            _walk = true;
            _dash = true;
        }

        float horizontalInput = Input.GetAxisRaw("Horizontal");

        _movement = new Vector2(horizontalInput, 0f);

        Debug.Log(horizontalInput);
        if (!_fixed && Input.GetKeyDown(KeyCode.W))
        {
            _walk = false;
            if (IsGrounded())
            {
                //_rigidbody.velocity = _movement;
                _rigidbody.velocity = new Vector2(_rigidbody.velocity.x, 0);
                _rigidbody.AddForce(Vector2.up * jumpPower, ForceMode2D.Impulse);
            }
            else
            {
                if (_jump)
                {
                    _rigidbody.velocity = new Vector2(_rigidbody.velocity.x, 0);
                    _rigidbody.AddForce(Vector2.up * jumpPower, ForceMode2D.Impulse);
                    _jump = false;
                }
            }
        }
    }