public bool isOnExplosionPath(Coords coord) { //check all live bombs and bomb radius //if coord is on the explosion path, return true //otherwise false foreach (Coords bomb in this.liveBombs) { LocationData datum = GetLocationData (bomb); int radius = datum.ExplosionRadius; bool test = (coord.Equals(bomb) || coord.isCardinalEastOf (bomb, radius) || coord.isCardinalNorthOf (bomb, radius) || coord.isCardinalSouthOf (bomb, radius) || coord.isCardinalWestOf (bomb, radius)); if (test) { return true; } } return false; }
public Coords getBombOnExplosionPath(Coords coord) { //check all live bombs and bomb radius //if coord is on the explosion path, return the bomb that's going to explode //otherwise return null foreach (Coords bomb in this.liveBombs) { LocationData datum = GetLocationData(bomb); int radius = datum.ExplosionRadius; bool test = (coord.Equals(bomb) || coord.isCardinalEastOf(bomb, radius) || coord.isCardinalNorthOf(bomb, radius) || coord.isCardinalSouthOf(bomb, radius) || coord.isCardinalWestOf(bomb, radius)); if (test) { return bomb; } } return null; }