static D_Chart DeserializeManual(string json) { D_Chart ch = new D_Chart(); Dictionary <string, object> dictionary = json.dictionaryFromJson(); foreach (var kp in dictionary) { if (kp.Key == "speed") { ch.speed = Convert.ToDouble(kp.Value); } else if (kp.Key == "notes") { List <D_Note> lnotes = new List <D_Note> (); List <object> notes = (kp.Value.ToString()).listFromJson(); foreach (var n in notes) { Dictionary <string, object> main_props = n.ToString().dictionaryFromJson(); D_Note n_ = new D_Note(); foreach (var props in main_props) { if (props.Key == "$id") { n_.id_ = props.Value.ToString(); } else if (main_props.ContainsKey("type") && props.Key == "type") { n_.type = Convert.ToInt32(props.Value); } else if (main_props.ContainsKey("sounds") && props.Key == "sounds") { List <D_Sound> s = new List <D_Sound> (); List <object> soundss = props.Value.ToString().listFromJson(); foreach (var sound in soundss) { D_Sound ss = new D_Sound(); Dictionary <string, object> so = sound.ToString().dictionaryFromJson(); foreach (var s_va in so) { if (s_va.Key == "w") { ss.w = Convert.ToDouble(s_va.Value); } else if (s_va.Key == "d") { ss.d = Convert.ToDouble(s_va.Value); } else if (s_va.Key == "p") { ss.p = Convert.ToInt32(s_va.Value); } else if (s_va.Key == "v") { ss.v = Convert.ToInt32(s_va.Value); } } s.Add(ss); } n_.sounds = s; } else if (props.Key == "pos") { n_.pos = Convert.ToDouble(props.Value); } else if (props.Key == "size") { n_.size = Convert.ToDouble(props.Value); } else if (props.Key == "_time") { n_._time = Convert.ToDouble(props.Value); } else if (props.Key == "shift") { n_.shift = Convert.ToDouble(props.Value); } else if (props.Key == "time") { n_.time = Convert.ToDouble(props.Value); } } lnotes.Add(n_); } ch.notes = lnotes; } else if (kp.Key == "links") { List <D_Link> llinks = new List <D_Link> (); List <object> l1 = kp.Value.ToString().listFromJson(); foreach (var sama in l1) { D_Link lll = new D_Link(); Dictionary <string, object> dl = sama.ToString().dictionaryFromJson(); List <object> ref_d = dl ["notes"].ToString().listFromJson(); List <D_Note2> l2 = new List <D_Note2> (); foreach (var ref_dd in ref_d) { D_Note2 note2 = new D_Note2(); Dictionary <string, object> only1ref = ref_dd.ToString().dictionaryFromJson(); note2.ref_ = only1ref ["$ref"].ToString(); l2.Add(note2); } lll.notes = l2; llinks.Add(lll); } ch.links = llinks; } } if (ch != null) { Debug.Log("Success"); //Debug.Log (JsonConvert.SerializeObject (ch)); } return(ch); }
//now we'll read it and deSerialize it and get the D_Chart. Using IEnumerator Chart_ing() { //yield return new WaitUntil(desfinished); float Begin = 0.0f; float StartTime = Time.realtimeSinceStartup; yield return(new WaitForSeconds(Begin)); // to get the time it took to load //declare the text of the chart (or you can skip this) string text = ndresult; //now we can get the D_Chart D_Chart _Chart = ChartLoader.DeserializeChart(Chart.text); //now we got all things we need //In case the chart is invalid or havesome problem, may be we could but this in a try-catch block (but this's a "totally valid" chart from the game //now let's build the notes //So we need to build click note (no sound and have sound) and the slide note. //First, Know a note is a slidenote, in the bottom of the chart, we have "links" and some "$ref" (guess it's reference). So "$ref": "13" mean the note has id: 13 is a slide note //Second, Remove piano note (black wave note in the background), they'll have position > 2 or < -2 List <D_Note> ClickNotes = new List <D_Note>(); //Include NoSound note List <D_Note> SlideNotes = new List <D_Note> (); foreach (D_Note note in _Chart.notes) { bool isSlide = false; //Debug.Log ("ID" + note.id_); //determine which is slide or click foreach (D_Link links in _Chart.links) { if (isSlide) //if it's already is slide note { continue; } else { foreach (D_Note2 note2 in links.notes) { if (isSlide) { continue; } else { if (note.id_.ToString() == note2.ref_) { SlideNotes.Add(note); // add to slide note collection isSlide = true; } } } } } if (isSlide) { continue; } else { //if it's not slide -> click note ClickNotes.Add(note); } } //after this, we'll have all notes we need, now for spawning object. foreach (D_Note note in ClickNotes) { if (note.sounds == null) //if it's no Sound Note { if (note.pos <= 2) { GameObject note_ = Object.Instantiate(ClickNote_NoSound_prefab, new Vector3((float)note.pos, (float)(note._time * SPEED), -3.556f), Quaternion.Euler(0, 0, 0)); //for knowing note_.name = "Note ID: " + note.id_; //set size note_.transform.localScale = new Vector3((float)note.size / 2, 0.6275f, 0.2f); note_.transform.SetParent(transform); //GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo += 1; } } else { if (note.pos <= 2) { GameObject note_ = Object.Instantiate(ClickNote_Sound_prefab, new Vector3((float)note.pos, (float)(note._time * SPEED), -3.556f), Quaternion.Euler(0, 0, 0)); //for knowing note_.name = "Note ID: " + note.id_; //set size note_.transform.localScale = new Vector3((float)note.size / 2, 0.6275f, 0.2f); note_.transform.SetParent(transform); //GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo += 1; } } } foreach (D_Note note in SlideNotes) { if (note.pos <= 2) { GameObject note_ = Object.Instantiate(SlideNote_prefab, new Vector3((float)note.pos, (float)(note._time * SPEED), -3.556f), Quaternion.Euler(0, 0, 0)); note_.name = "Slide Note ID: " + note.id_; note_.transform.localScale = new Vector3((float)note.size / 2, 0.6275f, 0.2f); note_.transform.SetParent(transform); //GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo += 1; } } Debug.Log("DONE"); Debug.Log(string.Format("Load took : {0}s", (Time.realtimeSinceStartup - StartTime))); counterr = 1; //print (100.0f / GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo); //notecontrol.charmingint += 100/GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo; //notecontrol.normint += notecontrol.charmingint/2 ; //print (notecontrol.charmingint); //print (notecontrol.normint); //GameObject.FindGameObjectWithTag ("title").GetComponent<Pause> ().MusicSource.Play (); //GameObject.FindWithTag("title").GetComponent<Pause> ().StartCoroutine ("StartChart"); //rb.velocity=new Vector2(0,-Note1.speed); }
public void Initialize() { D_QueryEntity = new VO_WF_SLTJ_CX(); D_Chart.UpdateLayout(); CMD_YXTJ.Execute(null); }