public override void Init() { base.Init(); var uiCountryMapWindow = UIMainController.Instance.GetWindow <UICountryMapWindow>(UIConstants.WINDOW_COUNTRY_MAP); var uiRegions = uiCountryMapWindow.UIRegions; GoogleTableRequest request = new GoogleTableRequest(NetworkConstants.GOOGLE_TABLE_ID, "'SolarData'!A2:M64", MajorDimension.COLUMNS); Server.Instance.Post <GoogleTableRequest, GoogleTableResponce>(request, x => { if (x.status == Status.OK) { var keys = x.table.columns[0]; for (int i = 0; i < uiRegions.Count; i++) { var uiRegion = uiRegions[i]; var iS = keys.rows.IndexOf(uiRegion.name + ".s"); var iD = keys.rows.IndexOf(uiRegion.name + ".d"); var iSD = keys.rows.IndexOf(uiRegion.name + ".sd"); var regionStat = new SolarStats(); if (iS >= 0 && iD >= 0 && iSD >= 0) { for (int j = 1; j < x.table.columns.Count; j++) { var column = x.table.columns[j]; var sRow = column.rows[iS]; var dRow = column.rows[iD]; var sdRow = column.rows[iSD]; float s = 0.0f; float d = 0.0f; float sd = 0.0f; float.TryParse(sRow, out s); float.TryParse(dRow, out d); float.TryParse(sdRow, out sd); var stats = new SolarStatsData() { s = s, d = d, sd = sd }; regionStat.stats.Add(stats); } } regionStats.Add(regionStat); } } }); }
public override void Init() { base.Init(); var uiCountryMapWindow = UIMainController.Instance.GetWindow <UICountryMapWindow>(UIConstants.WINDOW_COUNTRY_MAP); var uiRegions = uiCountryMapWindow.UIRegions; GoogleTableRequest request = new GoogleTableRequest(NetworkConstants.GOOGLE_TABLE_ID, "'WindData'!A2:M26", MajorDimension.COLUMNS); Server.Instance.Post <GoogleTableRequest, GoogleTableResponce>(request, x => { if (x.status == Status.OK) { var keys = x.table.columns[0]; for (int i = 0; i < uiRegions.Count; i++) { var region = uiRegions[i]; var index = keys.rows.IndexOf(region.Origin.name); var regionStat = new WindStats(); if (index >= 0) { for (int j = 1; j < x.table.columns.Count; j++) { var column = x.table.columns[j]; var speedRow = column.rows[index]; float speed = 0.0f; float.TryParse(speedRow, out speed); var stats = new WindStatsData() { speed = speed }; regionStat.stats.Add(stats); } } regionStats.Add(regionStat); } } }); }