private void takeItem(DropBase drop) { IItem item = drop.TakeItem(); item.OnPickUp(hero); SoundManager.Instance.PlayPickup(); }
private void OnTriggerExit2D(Collider2D other) { if (other.tag == "Item") { GameObject go = other.gameObject; DropBase drop = go.GetComponent <DropBase>(); lootInRange.Remove(drop); Debug.Log("Item out of Range"); } }
void Update() { if (Input.GetKeyDown(KeyCode.Z)) { if (lootInRange.Count > 0) { DropBase drop = lootInRange[0]; lootInRange.RemoveAt(0); takeItem(drop); Debug.Log("Item Looted"); } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Item") { GameObject go = other.gameObject; DropBase drop = go.GetComponent <DropBase>(); if (drop == null) { Debug.Log("Collided with another Item"); return; } else if (drop.itemDrop.PickUpWhenInRange()) { takeItem(drop); } else { lootInRange.Add(drop); } Debug.Log("Item in Range"); } }