コード例 #1
0
 public MusicBar(MusicScore parentScore, int count = 4, double span = 1.0, IEnumerable<MusicLane> lanes = null)
 {
     ParentScore = parentScore;
     Count = count;
     Span = span;
     Lanes = lanes?.ToList() ?? new List<MusicLane>();
 }
コード例 #2
0
 public ScoreStatus(double beatLocation, MusicScore targetScore)
 {
     BeatLocation = beatLocation;
     TargetScore = targetScore;
 }
コード例 #3
0
 public void SetTargetScore(MusicScore value)
 {
     TargetScore = value;
 }
コード例 #4
0
		/// <summary>
		/// 譜面情報をデシリアライズします
		/// </summary>
		/// <param name="scoreFilePath">譜面のファイルパス</param>
		/// <returns></returns>
		public static async Task<MusicScore> DeserializeAsync(string scoreFilePath)
		{
			MusicScore score;

			string jStr = "";

			if (!File.Exists(scoreFilePath))
				throw new ArgumentException($"score file not found (filePath: {scoreFilePath})");

			using (var sr = new StreamReader(scoreFilePath))
				jStr = await sr.ReadToEndAsync();

			var json = DynamicJson.Parse(jStr);

			var scoreVersion = json.meta.score_version;

			if (scoreVersion == 1.0)
			{
				string title = json.meta.title;
				double bpm = json.meta.bmp;
				string songUrl = json.meta.song_url;
				double offset = json.meta.offset;

				score = new MusicScore(title, (int)bpm, new Uri(songUrl), 4, offset);

				foreach (var tags in json.meta.tags)
				{
					score.Tags.Add((string)tags);
				}

				foreach (var bar in json.bars)
				{
					var size = ((string)bar.size).Split(':').ToList();

					var count = int.Parse(size[0]);
					var span = size.Count == 2 ? double.Parse(size[1]) : 1.0;

					var musicBar = new MusicBar(score, count, span);

					foreach (var lane in bar.notes)
					{
						var musicLane = new MusicLane(musicBar);

						foreach (string noteInfo in lane)
						{
							var noteInfoList = noteInfo.Split(':');
							var countLocation = int.Parse(noteInfoList[0]);
							var noteType = (MusicNoteType)int.Parse(noteInfoList[1]);

							var musicNote = new MusicNote(countLocation, musicLane, noteType);

							musicLane.Notes.Add(musicNote);
						}

						musicBar.Lanes.Add(musicLane);
					}

					score.Bars.Add(musicBar);
				}
			}
			else
			{
				throw new ArgumentException($"Unknown score version (value: {scoreVersion})");
			}

			return score;
		}