public void FixRoad(CarController car) { // Get Nearest Road Tile nearestRoad = null; float nearestDist = float.MaxValue; for (int iRoad = 0; iRoad < BreakableRoads.Length; ++iRoad) { if (BreakableRoads[iRoad].IsBroken) { Vector3 target = BreakableRoads[iRoad].GetBarrierLocation(); if (target != Vector3.zero) { float dist = Vector3.Distance(car.transform.position, target); if (dist < nearestDist) { nearestDist = dist; nearestRoad = BreakableRoads[iRoad]; } } } } if (nearestRoad == null) { // No barriers up return; } else { nearestRoad.FixRoad(); car.DecrementPowerupCount(); } }