IEnumerator WaitForRequest(WWW www) { yield return www; if (www.error == null){ //Debug.Log("WWW Ok!: " + www.text); //Empty list points.RemoveAll(isExplorationPoint); //Create and store nearby explorations points var data = JSONNode.Parse(www.text); for(int i=0; i<data.Count; i++){ //Debug.Log (data[i]["id"].GetType()); ExplorationPoint newExpP = new ExplorationPoint((uint)data[i]["id"].AsInt, (string)data[i]["type"], (string)data[i]["name"], (uint)data[i]["source"]["srcId"].AsInt, (uint)data[i]["source"]["systemId"].AsInt, (string) data[i]["position"]["type"], data[i]["position"]["coordinates"][1].AsDouble, data[i]["position"]["coordinates"][0].AsDouble, (string)data[i]["status"]); points.Add(newExpP); Debug.Log (newExpP.distance); } //Sort points by distance points.Sort(CompareListBy); //Record in GameMaster GameMaster.instance.pointsObjetives = points; //Generate UI GameObject.Find("Objective").GetComponent<ScrollBarInterface>().GenerateButtons(); } else { Debug.Log("WWW Error: "+ www.error); } }
private static bool isExplorationPoint(ExplorationPoint exp) { return true; }
private static int CompareListBy(ExplorationPoint expP1, ExplorationPoint expP2) { return expP1.distance.CompareTo(expP2.distance); }