Ejemplo n.º 1
0
    private void SetGrounded(Collision2D collision, bool grounded)
    {
        GameObject collisionObject = collision.gameObject;

        if (collisionObject.CompareTag(GameConstants.PLATFORM_TAG) || collisionObject.CompareTag(GameConstants.TRAMPOLINE_TAG))
        {
            OnGroundHit?.Invoke(grounded);
        }
    }
Ejemplo n.º 2
0
    public void Raycasting()
    {
        Vector2      CurMousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        RaycastHit2D hit         = Physics2D.Raycast(CurMousePos, Vector2.zero);

        if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            if (hit.collider.GetComponent <PlayerCircle>())
            {
                OnPlayerHit?.Invoke();

                return;
            }
        }
        if (Input.GetMouseButton(0) && timer > _timeForNextRay && !EventSystem.current.IsPointerOverGameObject())
        {
            //  Debug.DrawLine(Camera.main.transform.position, hit.point, Color.green, 1f);
            if (hit.collider.GetComponent <PlayerCircle>())
            {
                return;
            }
            OnGroundHit?.Invoke(CurMousePos);
            timer = 0;
        }
        if (Input.GetMouseButtonUp(0) && !EventSystem.current.IsPointerOverGameObject())
        {
            //  Debug.DrawLine(Camera.main.transform.position, hit.point, Color.green, 1f);
            if (hit.collider.GetComponent <PlayerCircle>())
            {
                return;
            }
            OnGroundHit?.Invoke(CurMousePos);
            timer = 0;
        }
        timer += Time.deltaTime;
    }