public float GetWall(short curId, bool left, float fy) { var shortY = (short)fy; var vertical = new Range((short)(shortY - 50), (short)(shortY - 1)); var cur = GetFh(curId); if (left) { var prev = GetFh(cur.Prev); if (prev.IsBlocking(vertical)) { return(cur.L); } var prev2 = GetFh(prev.Prev); return(prev2.IsBlocking(vertical) ? prev.L : Walls.First); } else { var next = GetFh(cur.Next); if (next.IsBlocking(vertical)) { return(cur.R); } var next2 = GetFh(next.Next); return(next2.IsBlocking(vertical) ? next.R : Walls.Second); } }
public FootholdTree(WzObject source) { short leftW = 30000; short rightW = -30000; short botB = -30000; short topB = 30000; foreach (var baseF0 in ((WzSubProperty)source).WzProperties) { short layer; var baseF = (WzSubProperty)baseF0.GetByUol(); try { short.TryParse(baseF.Name, out layer); } catch (Exception) { continue; } foreach (var midF0 in baseF.WzProperties) { var midF = (WzSubProperty)midF0.GetByUol(); foreach (var lastF0 in midF.WzProperties) { var lastF = (WzSubProperty)lastF0.GetByUol(); short id; try { short.TryParse(lastF.Name, out id); } catch (Exception) { continue; } var foothold = new Foothold(lastF0, id, layer); _footholds[id] = foothold; var start = foothold.L; var end = foothold.R; if (start > leftW) { leftW = start; } if (end > rightW) { rightW = end; } if (foothold.B > botB) { botB = foothold.B; } if (foothold.T < topB) { topB = foothold.T; } if (foothold.IsWall) { continue; } for (var i = start; i <= end; i++) { _footholdSbYx[new Short(i)] = id; } } } } Walls = new Range((short)(leftW + 25), (short)(rightW - 25)); Borders = new Range((short)(topB - 300), (short)(botB + 100)); }