Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D col)
    {
        if (this.enabled)
        {
            Item_Component item = col.GetComponent <Item_Component>();

            pickUp.PickedUp(item);
        }
    }
Beispiel #2
0
    private void FixedUpdate()
    {
        Collider2D[] col = Physics2D.OverlapCircleAll(transform.position, pickUpRadius, mask);

        foreach (Collider2D c in col)
        {
            if (c.GetComponent <Item_Component>())
            {
                //here we update to inventory Ui
                Item_Component item = c.transform.gameObject.GetComponent <Item_Component>();
                pickUp.PickedUp(item);
            }
        }
    }
Beispiel #3
0
    private void FixedUpdate()
    {
        posInDirection = ((Vector2)transform.position) + (directionInput * distance);
        if (directionInput != Vector2.zero)
        {
            Collider2D[] col = Physics2D.OverlapCircleAll(posInDirection, pickUpRadius, mask);

            foreach (Collider2D c in col)
            {
                if (c.GetComponent <Item_Component>())
                {
                    //here we update to inventory Ui

                    Item_Component item = c.transform.gameObject.GetComponent <Item_Component>();
                    pickUp.PickedUp(item);
                }
            }
        }
    }
Beispiel #4
0
    void GetItem()
    {
        RaycastHit2D hit = Physics2D.Raycast(mousePosition, Vector2.up, 1, mask);

        if (hit.collider != null)
        {
            print("Hit Something");
            if (hit.transform.GetComponent <Item_Component>())
            {
                distanceFromClick = (Vector2)transform.position - (Vector2)hit.transform.position;


                if (distanceFromClick.magnitude < maxDistance)
                {
                    Item_Component item = hit.transform.gameObject.GetComponent <Item_Component>();
                    pickUp.PickedUp(item);
                }
            }
        }
    }