コード例 #1
0
    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();
        }
    }
コード例 #2
0
    /// <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"
    }