boardManager.isBlocked C# (CSharp) Method

isBlocked() public method

public isBlocked ( Vector2 firePosition, Vector2 targetPosition ) : bool
firePosition Vector2
targetPosition Vector2
return bool
    public bool isBlocked(Vector2 firePosition, Vector2 targetPosition)
    {
        Vector3 firePos = SS.hexPositionTransform(firePosition);
        Vector3 targetPos = SS.hexPositionTransform(targetPosition);
        Vector3 pos;
        float dis;
        bool possibleBlock = false;
        foreach (blastShield b in blastShields) {
            if (b.isActivated()){
                foreach(Vector2 v in b.barrierPos){
                    pos = SS.hexPositionTransform(v);
                    if (isInBound(firePos.x,firePos.y,
                                  targetPos.x,targetPos.y,
                                  pos.x,pos.y)) { //make sure the barrier is inside the parallelogram
                        dis = DistancePointLine (pos, firePos, targetPos);
                        if (dis < tileSize / 2 - epsilon) {
                            return true; //the projectile cut through one
                        } else if (almostEqual(dis,tileSize / 2)) { // We need to be careful when the line is tangent to the circle
                            possibleBlock = true;
                        }
                    }
                }
            }
        }
        if (possibleBlock) {
            Vector2 tempTgt1,tempTgt2;
            tempTgt1 = targetPosition + Vector2.left * 0.6f;	// Nudge the target a little bit to the left
            tempTgt2 = targetPosition + Vector2.right * 0.6f;	// Nudge the target a little bit to the right
            // If both ways are blocked, it's blocked; If not, it's not blocked
            return isBlocked(firePosition,tempTgt1) && isBlocked(firePosition,tempTgt2);
        }
        return false;
    }