/// <summary>Getting distance from the surface directly under the lander, but we don't need to find the surface /// elements under the lander.</summary> public static int GetDistanceFromSurface(Lander lander, SurfaceZone leftZone, SurfaceZone rightZone) { if (rightZone == null || leftZone == null) { return(int.MaxValue); } var zoneAngle = Trigonometry .GetAngle(new Point(leftZone.LeftX, leftZone.LeftY), new Point(rightZone.LeftX, rightZone.LeftY)); var landerXInZone = lander.Situation.X - leftZone.LeftX; var surfaceYPosition = leftZone.LeftY + Math.Round(Trigonometry.GetNewYPosition(zoneAngle, landerXInZone)); return((int)Math.Round(lander.Situation.Y - surfaceYPosition)); }
private void SetLandingZone() { _landingZone = _surfaceZones.First(zone => zone.LeftY == zone.RightY); _centerLandingZoneX = (_landingZone.LeftX + _landingZone.RightX) / 2; }