public void AddLocations(Dictionary <LocationStatic, LocationDynamic> locations) { foreach (var location in locations) { LocationStatic sPrefab = (LocationStatic)location.Key.Clone(); LocationDynamic dPrefab = (LocationDynamic)location.Value.Clone(); currentStateOfLocations.Add(sPrefab, dPrefab); // Очистка sPrefab = null; dPrefab = null; GC.Collect(); } UpdateHashCode(); }
/// <summary> /// A method that creates a set of ready-made locations. /// </summary> public Dictionary <LocationStatic, LocationDynamic> CreateLocationSet(List <string> locationNames, List <bool> locationsEvidences) { // Create an empty set of locations. Dictionary <LocationStatic, LocationDynamic> locations = new Dictionary <LocationStatic, LocationDynamic>(); // We create a location the required number of times, using the constructors of its static and dynamic parts, and then add it to the set. for (int i = 0; i < locationNames.Count; i++) { LocationStatic newLocationStatic = new LocationStatic(locationNames[i]); LocationDynamic newLocationDynamic = new LocationDynamic(locationsEvidences[i], newLocationStatic); locations.Add(newLocationStatic, newLocationDynamic); } // Shuffle the locations in the set in random order. OrderLocationsRandom(ref locations); // We establish connections between locations. locations = LocationsConnection(locations); // We return the ready-made set of locations. return(locations); }