[RESOLVIDO] Rectangle.IntersectsWith - C#

Olá!

Estou tentando checar se qualquer (any) Objeto Rectangle dentro da lista HeightMap, colide com (IntersectsWith) com o jogador:

foreach (Rectangle rec in HeightMap) { bool intersects = HeightMap.Any(rec.IntersectsWith(PlayerRectangle)); if(intersects) Console.Write("Algum retângulo da lista HeightMap está colidindo com o jogador!"); }

O problema é que recebo o seguinte erro:

P.S: RESUMIDO

Se alguém puder me ajduar, ficarei muito grato.

Olá,
rec.IntersectsWith(PlayerRectangle) retorna boolean… acho que só ele no if já verifica se houve intersecção.

Att.

Eu acho que deveria ser assim:

bool intersects = HeightMap.Any(rec => rec.IntersectsWith(PlayerRectangle));
if(intersects) Console.Write("Algum retângulo da lista HeightMap está colidindo com o jogador!");

Pode remover o Loop neste caso, o próprio .Any vai fazer o loop e retornar se algum “rec” colide com PlayerRectangle.