public Foothold findBelow(Point p) { int num; Foothold foothold; List <Foothold> footholds = new List <Foothold>(); foreach (Foothold foothold1 in this.footholds) { footholds.Add(foothold1); } List <Foothold> footholds1 = new List <Foothold>(); foreach (Foothold foothold2 in footholds) { if (foothold2.getX1() > p.X || foothold2.getX2() < p.X) { continue; } footholds1.Add(foothold2); } footholds1.Sort(); List <Foothold> .Enumerator enumerator = footholds1.GetEnumerator(); try { while (enumerator.MoveNext()) { Foothold current = enumerator.Current; if (current.isWall() || current.getY1() == current.getY2()) { if (current.isWall() || current.getY1() < p.Y) { continue; } foothold = current; return(foothold); } else { double num1 = (double)Math.Abs(current.getY2() - current.getY1()); double num2 = (double)Math.Abs(current.getX2() - current.getX1()); double num3 = (double)Math.Abs(p.X - current.getX1()); double num4 = Math.Atan(num2 / num1); double num5 = Math.Atan(num1 / num2); double num6 = Math.Cos(num4) * num3 / Math.Cos(num5); num = (current.getY2() >= current.getY1() ? current.getY1() + (int)num6 : current.getY1() - (int)num6); if (num < p.Y) { continue; } foothold = current; return(foothold); } } return(null); } finally { ((IDisposable)enumerator).Dispose(); } }
public int CompareTo(object othera) { Foothold foothold = (Foothold)othera; if (this.p2.Y >= foothold.getY1()) { if (this.p1.Y <= foothold.getY2()) { return(0); } else { return(1); } } else { return(-1); } }