public void BeforeAll() { var container = Platform.Setup.CreateContainer(); Assert.True(container.TryResolve(out _persistenceService), "PersistenceService not found"); Assert.True(container.TryResolve(out _networkService), "SafeNetworkService not found"); _persistenceService.Init(); _loader = new LocationsLoader(_persistenceService, _networkService); }
private void Awake() { // There can be only ONE! if (_instance == null) { _instance = this; } else if (_instance != this) { Destroy(this.gameObject); } /************* Load Locations Start *************/ // Loads the entire csv as a single, long string TextAsset locationsData = Resources.Load <TextAsset>("LocationsData_proto"); // Splits the csv by new line character, making each new line an element in the 'data' array string[] data = locationsData.text.Split(new char[] { '\n' }); // Don't include the first line (headings), be careful that there isn't a blank last line in the csv file for (int i = 1; i < data.Length; i++) { // Split each line by the comma to store each value individually as an element in 'line' array string[] line = data[i].Split(new char[] { ',' }); // Save the values in the csv into a new Location class Location l = new Location(); // This will try to convert the value into an int, otherwise just return the string (as well as empty strings) int.TryParse(line[0], out l.locationID); l.locationName = line[1]; bool.TryParse(line[2], out l.unlocked); int.TryParse(line[3], out l.cost); int.TryParse(line[4], out l.xFactor); l.description = line[5]; locationList.Add(l); } }