private void AdvanceOption(HalfplanePredicate ap) { int x0 = _targets[_option].X; int y0 = _targets[_option].Y; // length (squared) of the screen's diagonal (largest fathomable distance) int min = BattleState.Seven.Configuration.WindowHeight * BattleState.Seven.Configuration.WindowHeight + BattleState.Seven.Configuration.WindowWidth * BattleState.Seven.Configuration.WindowWidth; int pick = -1; for (int i = 0; i < _targets.Count; i++) { if (i == _option) { // skip current option continue; } if (ap(i)) { // skip options not in the desired half-plane continue; } // calculate distance int dx = _targets[i].X - x0; int dy = _targets[i].Y - y0; int ds_sq = dx * dx + dy * dy; if (ds_sq < min) { pick = i; min = ds_sq; } } if (pick >= 0) { _option = pick; } }
private void AdvanceOption(HalfplanePredicate ap) { int x0 = _targets[_option].X; int y0 = _targets[_option].Y; // length (squared) of the screen's diagonal (largest fathomable distance) int min = Globals.HEIGHT * Globals.HEIGHT + Globals.WIDTH * Globals.WIDTH; int pick = -1; for (int i = 0; i < _targets.Count; i++) { if (i == _option) // skip current option { continue; } if (ap(i)) // skip options not in the desired half-plane { continue; } // calculate distance int dx = _targets[i].X - x0; int dy = _targets[i].Y - y0; int ds_sq = dx * dx + dy * dy; if (ds_sq < min) { pick = i; min = ds_sq; } } if (pick >= 0) { _option = pick; } }
private void AdvanceOption(HalfplanePredicate ap) { int x0 = _targets[_option].X; int y0 = _targets[_option].Y; // length (squared) of the screen's diagonal (largest fathomable distance) int min = Globals.HEIGHT * Globals.HEIGHT + Globals.WIDTH * Globals.WIDTH; int pick = -1; for (int i = 0; i < _targets.Count; i++) { if (i == _option) // skip current option continue; if (ap(i)) // skip options not in the desired half-plane continue; // calculate distance int dx = _targets[i].X - x0; int dy = _targets[i].Y - y0; int ds_sq = dx * dx + dy * dy; if (ds_sq < min) { pick = i; min = ds_sq; } } if (pick >= 0) _option = pick; }