public void ShotChange(int turn, double fromX, double fromY, ref double toX, ref double toY) { var enumerator = getEnumerator(shotObstacles, fromX, fromY, toX, toY).GetEnumerator(); while (enumerator.MoveNext()) { IShotInfluence obstacle = enumerator.Current; if (obstacle == null) { continue; } if (obstacle.Change(turn, fromX, fromY, ref toX, ref toY)) { enumerator.Dispose(); Segment leadSegment = new Segment(fromX, fromY, toX, toY); Point nearestIntersect = EuclideanSpaceUtils.GetNearestIntersect(leadSegment, obstacle.Segments()); fromX = nearestIntersect.X; fromY = nearestIntersect.Y; enumerator = getEnumerator(shotObstacles, fromX, fromY, toX, toY).GetEnumerator(); } } }
public void AddShotObstacle(IShotInfluence obstacle) { this.shotObstacles.Add(new Point(obstacle.X, obstacle.Y), obstacle); }