Пример #1
0
    private PickableObject getFirstPickableObject()
    {
        float          nearestDistSqr = float.MaxValue;
        PickableObject nearestObj     = null;

        foreach (PickableObject pickable in pickables)
        {
            if (!pickable.isAccessible)
            {
                continue;
            }

            float distSqr = (pickable.pickHandle.transform.position - transform.position).sqrMagnitude;
            if (distSqr < nearestDistSqr)
            {
                if (pickable.objectLayer != PickableObject.LayerObject.Mid || levController.isInFront(pickable.pickHandle.transform.position))
                {
                    nearestDistSqr = distSqr;
                    nearestObj     = pickable;
                }
            }
        }
        return(nearestObj);
    }