private void OnTriggerEnter(Collider other) { // If the unit we've collided with is holding the crown jewels, end the level AAUnit unit = other.GetComponent <AAUnit>(); if (unit && unit.heldItem.GetComponent <HeldItem>().type.Equals(HeldItem.ItemType.CrownJewels)) { LM.PlayerWin(); } }
/// <summary> /// When a Unit enters this item's collision radius, if that unit can pick up this item, /// have them pick up this item. /// </summary> /// <param name="other"></param> private void OnTriggerEnter(Collider other) { AAUnit otherUnit = other.GetComponent <AAUnit>(); if (otherUnit && otherUnit.heldItem == null) { otherUnit.heldItem = this.gameObject; PickUp(other.gameObject); } //TODO HERE don't just automatically attach the item-- the unit should determine whether it wants the item or not. // something like if "otherUnit.WantsItem(), then attach it" }