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); } }
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); } }
void PickItem() { if (!can_pick || picking_item == null) { return; } if (useController) { if (Input.GetButtonDown(whichPlayer + "LB")) { if (!LBFixed) { return; } LBFixed = false; if (CItemDataBase.items[picking_item.id].elementID < -20) { TeamHp.ChangeHp(true, 0.15f); healEffect.SetHealEffectAni(); picking_item.GetComponent <COutLine>().SetOutLine(false); picking_item.SetInFree(); ChangeSlot(true, -1); if (test) { tutorialRequest.DonePickUp(true); } } else { handle.enabled = true; if (!b_handling) { b_handling = true; craftA = items[picking_item.id]; handling_item = picking_item.gameObject; handling_item.transform.parent = transform.GetChild(0); handling_item.transform.position = this.transform.position; handling_item.GetComponent <COutLine>().SetOutLine(false); handling_item.SetActive(false); handle.sprite = CItemDataBase.spriteList[craftA.id]; handling_item.GetComponent <CPickItem>().SetLifeTime(0.0f); ChangeSlot(true, 0); ArrowEnable(true); if (test) { tutorialRequest.DonePickUp(true); } } else { OnCrafting(); } } can_pick = false; picking_item = null; //if (picking_item == null) return; //crafterAnimator.SetBool("is_gather", true); ////Debug.Log("設動畫"); } } else { if (Input.GetKeyDown(KeyCode.E)) { //if (picking_item == null) return; //crafterAnimator.SetBool("is_gather", true); if (CItemDataBase.items[picking_item.id].elementID < -20) { TeamHp.ChangeHp(true, 0.15f); healEffect.SetHealEffectAni(); picking_item.GetComponent <COutLine>().SetOutLine(false); picking_item.SetInFree(); ChangeSlot(true, -1); if (test) { tutorialRequest.DonePickUp(true); } } else { handle.enabled = true; if (!b_handling) { b_handling = true; craftA = items[picking_item.id]; handling_item = picking_item.gameObject; handling_item.transform.parent = transform.GetChild(0); handling_item.transform.position = this.transform.position; handling_item.GetComponent <COutLine>().SetOutLine(false); handling_item.SetActive(false); handle.sprite = CItemDataBase.spriteList[craftA.id]; handling_item.GetComponent <CPickItem>().SetLifeTime(0.0f); ChangeSlot(true, 0); ArrowEnable(true); if (test) { tutorialRequest.DonePickUp(true); } } else { OnCrafting(); } } can_pick = false; picking_item = null; } } }