public Location getRandomLocation(int teamId) { bool checking = true; Random rand = new Random(); int id = 0; LocationService locationService = new LocationService(context); List <Location> locations = locationService.getLocations(); Team team = GetTeam(teamId); List <PreviousLocation> previousLocations = team.PreviousLocations; id = rand.Next(locations.Count()); while (checking) { if (previousLocations.Count != locations.Count) { if (previousLocations != null && previousLocations.Count > 0) { foreach (PreviousLocation prevLoc in previousLocations) { if (prevLoc.Location == locations[id]) { checking = true; id = rand.Next(locations.Count()); break; } else { checking = false; } } } else { checking = false; } } else { return(null); } } PreviousLocation currentLocation = new PreviousLocation(); currentLocation.LocationId = locations[id].Id; currentLocation.Location = locations[id]; currentLocation.Team = team; currentLocation.TeamId = teamId; team.PreviousLocations.Add(currentLocation); context.SaveChanges(); return(currentLocation.Location); }
OnWalkingOffLedge != null?OnWalkingOffLedge(PreviousFloorImpactNormal, PreviousFloorContactNormal, PreviousLocation, TimeDelta) : (PreviousFloorImpactNormal, PreviousFloorContactNormal, PreviousLocation);