private void Update()
    {
        horizontalInput = Input.GetAxisRaw("Horizontal");
        if (horizontalInput != 0)
        {
            facing = (int)horizontalInput;
        }

        movementScript.horizontalInput = horizontalInput;
        //Mouseposition
        mousePosScreen          = Input.mousePosition;
        mousePosWorld           = mainCamera.ScreenToWorldPoint(mousePosScreen);
        vectorToMouseRaw        = mousePosWorld - movementScript.collCenter;
        vectorToMouseNormalized = vectorToMouseRaw.normalized;
        //Jump
        if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.W))
        {
            movementScript.Jump();
        }
        //Drop down
        if (Input.GetKeyDown(KeyCode.S))
        {
            Physics2D.IgnoreLayerCollision(14, 13, true);
            transform.position += Vector3.up * 0.01f;
            timer = 0.2f;
        }
        else if (timer > 0 && !Input.GetKey(KeyCode.S))
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                Physics2D.IgnoreLayerCollision(14, 13, false);
            }
        }

        //Interact
        if (Input.GetKeyDown(KeyCode.E))
        {
            InteractButtonPressed?.Invoke(transform.position);
        }
        if (Input.GetMouseButton(0))
        {
            SweetStrikeButtonPressed?.Invoke(vectorToMouseNormalized);
        }
        if (Input.GetKey(KeyCode.Q))
        {
            SavorySprayButtonPressed?.Invoke(vectorToMouseNormalized);
        }
    }
Ejemplo n.º 2
0
    private void Controls()
    {
        horizontalAxis = Input.GetAxis("Horizontal");
        verticalAxis   = Input.GetAxis("Vertical");

        if (Input.GetButtonDown("Interaction"))
        {
            InteractButtonPressed?.Invoke();
        }

        if (Input.GetButtonDown("Sleep"))
        {
            GameManager.Instance.ActivateSleepMode(this);
        }
    }