public bool Collide(AttackableUnit target) { var unitCoords = target.Position; var targetDistance = Vector2.Distance(Begin, unitCoords); float targetAngle = Geo.GetAngleDegrees(Begin, unitCoords); bool result = targetDistance <= Radius && targetAngle >= BeginAngle && targetAngle <= EndAngle; return(result); }
public Cone(Vector2 begin, Vector2 end, float angleDeg) { Radius = Vector2.Distance(begin, end); float middlePointAngle = Geo.GetAngleDegrees(begin, end); Begin = begin; End = end; BeginAngle = middlePointAngle - angleDeg; EndAngle = middlePointAngle + angleDeg; }