private void TryCarry() { if (ground.Count != 0 && !isCarrying) { carriedObject = (InanimateEntity)ground[0]; Carry(carriedObject); } }
public void Throw() { if (isCarrying) { if (carriedObject.tag == "Player" || carriedObject.tag == "enemy") { carriedObject.GetComponent <AnimateEntity>().stun = false; } carriedObject.GetComponent <Rigidbody2D>().AddForce(direction.normalized * 50, ForceMode2D.Impulse); //carriedObject.GetComponentInChildren<CircleCollider2D>().enabled = true; carriedObject.pickupCollider.enabled = true; carriedObject.transform.parent = null; //carriedObject.transform.localPosition = Vector3.zero; //carriedObject.GetComponent<Rigidbody2D>().velocity = Vector2.zero; carriedObject.GetComponent <CircleCollider2D>().enabled = true; if (carriedObject.GetComponent <Potions>() != null) { SoundManager.playSound("ThrowingPotion2"); carriedObject.GetComponent <Potions>().StartCoroutine("creationOfEffectZone"); } carriedObject = null; isCarrying = false; } }
public void Carry(InanimateEntity Ientity) { if (Ientity == inventory[0] && !isCarrying) { Ientity.Unequip(0); UI.emptySlotInventory(0); isCarrying = true; Ientity.GetComponentInChildren <CircleCollider2D>().enabled = false; Ientity.pickupCollider.enabled = false; foreach (SpriteRenderer sp in Ientity.GetComponentsInChildren <SpriteRenderer>()) { sp.enabled = true; } Ientity.transform.parent = this.transform; Ientity.transform.localPosition = Vector3.zero; Ientity.transform.rotation = Quaternion.Euler(0, 0, 0); Ientity.GetComponent <Rigidbody2D>().velocity = Vector2.zero; carriedObject = Ientity; UI.armorHealth(); // Armor Health } else if (Ientity == inventory[1] && !isCarrying) { Ientity.Unequip(1); UI.emptySlotInventory(1); isCarrying = true; Ientity.GetComponentInChildren <CircleCollider2D>().enabled = false; Ientity.pickupCollider.enabled = false; foreach (SpriteRenderer sp in Ientity.GetComponentsInChildren <SpriteRenderer>()) { sp.enabled = true; } Ientity.transform.parent = this.transform; Ientity.transform.localPosition = Vector3.zero; Ientity.transform.rotation = Quaternion.Euler(0, 0, 0); Ientity.GetComponent <Rigidbody2D>().velocity = Vector2.zero; carriedObject = Ientity; UI.armorHealth(); // Armor Health } else if ((Ientity.tag == "Player" || Ientity.tag == "enemy") && !isCarrying) { Ientity.GetComponent <AnimateEntity>().stun = true; isCarrying = true; Ientity.GetComponentInChildren <CircleCollider2D>().enabled = false; Ientity.pickupCollider.enabled = false; foreach (SpriteRenderer sp in Ientity.GetComponentsInChildren <SpriteRenderer>()) { sp.enabled = true; } Ientity.transform.parent = this.transform; Ientity.transform.localPosition = Vector3.zero; Ientity.transform.rotation = Quaternion.Euler(0, 0, 0); Ientity.GetComponent <Rigidbody2D>().velocity = Vector2.zero; carriedObject = Ientity; } else if (!isCarrying) { isCarrying = true; Ientity.GetComponentInChildren <CircleCollider2D>().enabled = false; Ientity.pickupCollider.enabled = false; foreach (SpriteRenderer sp in Ientity.GetComponentsInChildren <SpriteRenderer>()) { sp.enabled = true; } Ientity.transform.parent = this.transform; Ientity.transform.localPosition = Vector3.zero; Ientity.transform.rotation = Quaternion.Euler(0, 0, 0); Ientity.GetComponent <Rigidbody2D>().velocity = Vector2.zero; carriedObject = Ientity; } }