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"); }
//音ゲーモードの譜面を読み込む private void LoadSong() { //色々初期化 playInterval = 0; background.sprite = null; //楽曲のパス取得 string path = PlayerPrefs.GetString(Consts.SONG_KEY, ""); if (path == "") { return; } //動画を優先してセット //動画が無ければ曲読み込み string moviePath = path + "\\" + ExtendSongs.MOVIE_FILE; if (File.Exists(moviePath)) { contentsPlayer = VideoContentsPlayer.Instance; } else { contentsPlayer = AudioContentsPlayer.Instance; } contentsPlayer.Load(path); //譜面読み込み List <float> timingList = ChartLoader.Load(path + "\\chart.txt"); if (timingList.Count > 0 && timingList[0] < 2.0f) { playInterval = 2.0f; for (int i = 0; i < timingList.Count; i++) { timingList[i] += 2.0f; } } (chart as OtogeChart).SetTimingList(timingList); //背景設定 if (!File.Exists(moviePath) && File.Exists(path + "\\" + ExtendSongs.BACK_FILE)) { background.sprite = ExtendSongs.SpriteFromFile(path + "\\" + ExtendSongs.BACK_FILE); } }
public ActionResult GetChart() { var date = DateTime.Now.Date; date = date.AddDays(-1 * date.Day); var data = new[] { new { Date = date.AddMonths(-2), Count = 30 }, new { Date = date.AddMonths(-1), Count = 25 }, new { Date = date, Count = 15 } }; Response.Clear(); Response.ContentType = "image/png"; ChartLoader.SaveChartImage( "PriceEnquiriesPerMonth.ascx", data, Response.OutputStream); Response.End(); return(null); // have to return something }
//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); }
// Start is called before the first frame update void Awake() { song = this.GetComponent <AudioSource>(); song.clip = Resources.Load($"Songs/{CurrentStats.fileName}") as AudioClip; SettingsManager.laneWidth = laneWidth; rawChartData = ChartLoader.LoadChart(); chartData = ChartLoader.LoadChart(); //chartData = new List<string[]>(rawChartData); bpm = CurrentStats.bpm; time = -CurrentStats.offset; Debug.Log($"BPM: {bpm}"); Debug.Log($"Offset: {CurrentStats.offset}"); speedConstant = 240000 / bpm; int _bar = 0; float _position = 0; int index = 0; int indexWithRest = 0; while (index < rawChartData.Count) { if (_bar < int.Parse(rawChartData[index][0]) - 1) { chartData[indexWithRest][1] = ((float.Parse(rawChartData[index][0]) - 1) * speedConstant).ToString(); //Debug.Log(chartData[i][1]); _bar = int.Parse(rawChartData[index][0]) - 1; if (rawChartData[index][1] == "0") { _position = 0f; } else { _position = 1f / float.Parse(rawChartData[index][1]); } } else { chartData[indexWithRest][1] = ((_bar + _position) * speedConstant).ToString(); //Debug.Log(int.Parse(rawChartData[i][1])); if (rawChartData[index][1] != "0") { _position += 1f / float.Parse(rawChartData[index][1]); } } if (chartData[indexWithRest][3] == "0") { chartData.RemoveAt(indexWithRest); } else { indexWithRest++; } index++; } CurrentStats.currentChart = new List <string[]>(chartData); CurrentStats.perfect = 0; CurrentStats.good = 0; CurrentStats.miss = 0; CurrentStats.combo = 0; Invoke("PlaySong", 5); }