// Update is called once per frame void Update() { if ((DateTime.Now - time).Milliseconds > 1000) { return; } time = DateTime.Now; try { //requestWriter.Write(DATA); //requestWriter.Close(); WebResponse webResponse = request.GetResponse(); Stream webStream = webResponse.GetResponseStream(); StreamReader responseReader = new StreamReader(webStream); string response = responseReader.ReadToEnd(); SmokeySingleton.Response objResponse = JsonUtility.FromJson <SmokeySingleton.Response>(response); SmokeySingleton.getInstance().fireData = objResponse; transform.Translate(new Vector3(transform.position.x, transform.position.y)); Console.Out.WriteLine(objResponse); responseReader.Close(); } catch (Exception e) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(e.Message); } }
// Update is called once per frame void Update() { if ((DateTime.Now - time).Milliseconds > 1000) { return; } time = DateTime.Now; int factor = 2; transform.Translate(new Vector3(0.2f - random.Next(1, factor + 1) / 10, random.Next(-1 * factor * 2, factor * 2) / 3, random.Next(-1 * factor, factor) / 10)); return; SmokeySingleton.Response fireData = SmokeySingleton.getInstance().fireData; try { float xtransform = (float)(transform.position.x - fireData.clusters[index][0]); float ytransform = (float)(transform.position.y - fireData.clusters[index][1]); ((TextMesh)GetComponent(typeof(TextMesh))).text = fireData.clusters[index][2].ToString(); transform.Translate(new Vector3(xtransform, ytransform)); } catch (Exception e) { Console.Out.WriteLine("-----------------"); Console.Out.WriteLine(e.Message); } }