Пример #1
0
    private RaycastHit2D[] GetCollisions()
    {
        Vector2 validDirection = GetValidDirection();
        float   validSpeed     = GetValidSpeed(validDirection);

        List <RaycastHit2D[]> raycasts = new List <RaycastHit2D[]>();

        for (int i = 0; i < rayPrecision; i++)
        {
            if (ignoreBorders && (i == 0 || i == rayPrecision - 1))
            {
                continue;
            }
            raycasts.Add(Physics2D.RaycastAll(this.GetOrigin() + new Vector3(direction.y, direction.x) * size / (rayPrecision - 1) * i, validDirection, validSpeed));
        }

        return(raycasts.SelectMany(h => h).Where(h => FrostyTag.AnyFromComponent(tags, h.collider)).ToArray());
    }
Пример #2
0
    public static bool AnyFromComponent(FrostyTag tag, Component comp)
    {
        FrostyTag compTag = comp.GetComponent <FrostyTag>();

        return((compTag != null && tag != null) ? tag.Any(compTag) : false);
    }
Пример #3
0
 public bool Any(FrostyTag tag)
 {
     return(tags.Any(t => tag.tags.Any(tg => (t & tg) == t)));
 }