protected IEnumerator remoteCall() { changinglevels = true; WWW content = new WWW(@"http://wiki-412.appspot.com/json/alpha2.json"); while(!content.isDone) { Debug.Log("fetching"); yield return null; } string hold = content.text; currentlevel = JsonMapper.ToObject<Level>(hold); currentlevel.fixLimits(); currentlevel.constructMatrix(3); generateLevel(); changinglevels = false; }
//Use stream reader and external json library to read in a saved level //after loading in make sure to fix limits to the maximums so that padding will be consistent when added //then make the matrix of right size, including padding protected void read(int padding) { Debug.Log ("reading level"); if(!Application.isWebPlayer) { using(StreamReader file = new StreamReader(Application.dataPath+"/Levels/"+currentlevel.name+".json")) { string hold = file.ReadToEnd(); currentlevel = JsonMapper.ToObject<Level>(hold); } currentlevel.fixLimits(); currentlevel.constructMatrix(padding); generateLevel(); } else if(Application.isWebPlayer) { StartCoroutine(remoteCall()); } }