Example #1
0
    // Check if this transmitter provides data to another transmitter.
    private bool IsParentOf(Transmitter other)
    {
        if (!other || other == this || connectedParents.Exists((tup) => tup.Item2 == other))
        {
            return(false);
        }
        // Check collide with wall.
        Vector2 delta = other.transform.position - transform.position;

        if (Physics2D.Raycast(transform.position, delta, delta.magnitude, LayerMask.GetMask("Wall")))
        {
            return(false);
        }
        // Special logic for ckecking goal transmitter.
        GoalTransmitter goalTransmitter = other.GetComponent <GoalTransmitter>();

        if (goalTransmitter && delta.magnitude > goalTransmitter.recieveRadius)
        {
            return(false);
        }
        return(minDistFromHome <= other.minDistFromHome || !other.isConnected);
    }