예제 #1
0
    static public void TestParseChart()
    {
        string path = "";

        try {
            path = UnityEditor.EditorUtility.OpenFilePanel("Open Chart File...", System.IO.Directory.GetCurrentDirectory(), "*");
            ChartLoader.DeserializeChart(System.IO.File.ReadAllText(path, System.Text.Encoding.ASCII));
        } catch (Exception e) {
            Debug.Log(e.ToString());
        }
        Debug.Log("Done");
    }
예제 #2
0
    //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);
    }