-
Notifications
You must be signed in to change notification settings - Fork 46
/
Score.cs
63 lines (57 loc) · 1.78 KB
/
Score.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ched.Core
{
/// <summary>
/// 譜面データを表すクラスです。
/// </summary>
[Newtonsoft.Json.JsonObject(Newtonsoft.Json.MemberSerialization.OptIn)]
public class Score
{
[Newtonsoft.Json.JsonProperty]
private int ticksPerBeat = 480;
[Newtonsoft.Json.JsonProperty]
private NoteCollection notes = new NoteCollection();
[Newtonsoft.Json.JsonProperty]
private EventCollection events = new EventCollection();
/// <summary>
/// 1拍あたりの分解能を設定します。
/// </summary>
public int TicksPerBeat
{
get { return ticksPerBeat; }
set { ticksPerBeat = value; }
}
/// <summary>
/// ノーツを格納するコレクションです。
/// </summary>
public NoteCollection Notes
{
get { return notes; }
set { notes = value; }
}
/// <summary>
/// イベントを格納するコレクションです。
/// </summary>
public EventCollection Events
{
get { return events; }
set { events = value; }
}
public void UpdateTicksPerBeat(int value)
{
double factor = value / TicksPerBeat;
Notes.UpdateTicksPerBeat(factor);
Events.UpdateTicksPerBeat(factor);
TicksPerBeat = value;
}
public Score Clone()
{
var score = Newtonsoft.Json.JsonConvert.DeserializeObject<Score>(Newtonsoft.Json.JsonConvert.SerializeObject(this, ScoreBook.SerializerSettings));
return score;
}
}
}