private void CheckDetector(World world) { if (detectorLocation != null) { Rectangle detector = new Rectangle(detectorLocation.position.x, detectorLocation.position.y, detectorLocation.wh.x, detectorLocation.wh.y); if (Raylib.CheckCollisionPointRec(new System.Numerics.Vector2(position.x, position.y), detector)) { return; } } for (int i = 0; i < world.detectors.Count; i++) { Rectangle detector2 = new Rectangle(world.detectors[i].position.x, world.detectors[i].position.y, world.detectors[i].wh.x, world.detectors[i].wh.y); if (Raylib.CheckCollisionPointRec(new System.Numerics.Vector2(position.x, position.y), detector2)) { if (!world.detectors[i].creations.Contains(this)) { world.detectors[i].creations.Add(this); } detectorLocation = world.detectors[i]; } else if (world.detectors[i].creations.Contains(this)) { world.detectors[i].creations.Remove(this); } } }
public List <Creation> searchCreations(World world) { List <Creation> creations = new List <Creation>(); /*for (int i = position.x - 5; i < position.x + 5; i++) { * for (int j = position.y - 5; j < position.y + 5; j++) { * for (int a = 0; a < world.map[i][j].creations.Count; a++) { * creations.Add(world.map[i][j].creations[a]); * } * } * }*/ for (int i = 0; i < world.detectors.Count; i++) { Rectangle detector = new Rectangle(world.detectors[i].position.x, world.detectors[i].position.y, world.detectors[i].wh.x, world.detectors[i].wh.y); if (Raylib.CheckCollisionPointRec(new System.Numerics.Vector2(position.x, position.y), detector)) { detectorLocation = world.detectors[i]; if (!world.detectors[i].creations.Contains(this)) { world.detectors[i].creations.Add(this); } foreach (Creation creation in world.detectors[i].creations) { if (creation != this) { creations.Add(creation); } } } else if (world.detectors[i].creations.Contains(this)) { world.detectors[i].creations.Remove(this); } } return(creations); }