private void OnTriggerStay2D(Collider2D collision) { //Debug.Log("collision stay" + collision.name); if (collision.tag == "PickItem") { if (!can_pick && !can_collect && craftFunc) { //Debug.Log("empty"); picking_item = collision.GetComponent <CPickItem>(); picking_item.GetComponent <COutLine>().SetOutLine(true); if (!b_handling) { ChangeSlot(false, picking_item.id); } else { craftB = items[picking_item.id]; CheckCrafting(); } can_pick = true; } } else if (!can_collect && collision.tag == "PickCollection" && !can_pick && craftFunc) { can_collect = true; pick_collect = collision.transform.GetComponent <CPickCollection>(); pick_collect.GetComponent <COutLine>().SetOutLine(true); } }
private void OnTriggerExit2D(Collider2D collision) { if (collision.tag == "PickItem") { //if (pick_collect == null) return; if (picking_item != null && collision.gameObject == picking_item.gameObject) { //Debug.Log("the same"); picking_item.GetComponent <COutLine>().SetOutLine(false); picking_item = null; ChangeSlot(true, 0); if (can_pick) { can_pick = false; } } //if (can_pick) can_pick = false; } if (can_collect && collision.tag == "PickCollection") { //Debug.Log("LEAVE COLLECT"); //if (pick_collect == null) return; if (pick_collect != null && collision.gameObject == pick_collect.gameObject) { pick_collect.GetComponent <COutLine>().SetOutLine(false); can_collect = false; pick_collect = null; } } }
private void OnTriggerEnter2D(Collider2D collision) { //Debug.Log("enter"); if (collision.tag == "PickItem") { if (!can_pick && !can_collect && craftFunc) { picking_item = collision.gameObject.GetComponent <CPickItem>(); picking_item.GetComponent <COutLine>().SetOutLine(true); if (!b_handling) { //Debug.Log("going to pick"); ChangeSlot(false, picking_item.id); } else { //Debug.Log("going to craft"); craftB = items[picking_item.id]; CheckCrafting(); } can_pick = true; } } else if (!can_collect && collision.tag == "PickCollection" && !can_pick) { if (!craftFunc) { return; } can_collect = true; pick_collect = collision.transform.GetComponent <CPickCollection>(); pick_collect.GetComponent <COutLine>().SetOutLine(true); //Debug.Log(pick_collect.gameObject.name); } }