Develop and Download Open Source Software

Browse Subversion Repository

Contents of /SchoolIdolFestivalSimulator.Components/Song.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (show annotations) (download)
Wed Jun 4 12:23:45 2014 UTC (9 years, 11 months ago) by kayochin_3141
File size: 7996 byte(s)


1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace SchoolIdolFestivalSimulator.Components {
7 /// <summary>
8 /// 曲の難易度
9 /// </summary>
10 public enum SongDifficulty:int{
11 Easy = 1
12 ,Normal = 2
13 ,Hard = 3
14 ,Ex = 4
15 ,SuperEx = 5
16 }
17 public enum SongColumn {
18 Name = 0
19 ,
20 Difficulty = 1
21 ,
22 TotalIconCount = 2
23 ,
24 LongIconCount = 3
25 ,
26 Seconds = 4
27 ,
28 SongType = 5
29 }
30 public class Song {
31 private string _name = "名称未設定";
32 private SongDifficulty _difficulty = SongDifficulty.Easy;
33 private int _totalIconCount = 120;
34 private int _longIconCount = 20;
35 private int _seconds = 120;
36 private decimal _perfectRatio = 1.0m;
37 private StatusType _songType = StatusType.Smile;
38
39 private int[] _shortIcon = new int[] { 0, 0, 0, 0, 0 };
40 private int[] _longIcon = new int[] { 0, 0, 0, 0, 0 };
41 private decimal[] _comboRatio = new decimal[] { 1m, 1.1m, 1.15m, 1.2m, 1.25m };
42 public string DifficultyText {
43 get {
44 switch(_difficulty) {
45 case SongDifficulty.Easy:
46 return "イージー";
47 case SongDifficulty.Normal:
48 return "ノーマル";
49 case SongDifficulty.Hard:
50 return "ハード";
51 case SongDifficulty.Ex:
52 return "エキスパート";
53 case SongDifficulty.SuperEx:
54 return "超難関";
55 default:
56 return string.Empty;
57 }
58 }
59 }
60 public override string ToString() {
61 StringBuilder sb = new StringBuilder();
62 sb.Append(_name);
63 sb.Append('\t').Append(ConvUtil.GetDifficultyString(_difficulty));
64 sb.Append('\t').Append(_totalIconCount.ToString());
65 sb.Append('\t').Append(_longIconCount.ToString());
66 sb.Append('\t').Append(_seconds.ToString());
67 sb.Append('\t').Append(ConvUtil.GetStatusTypeText(_songType));
68 return sb.ToString();
69 }
70 internal static Song CreateFromText(string[] s) {
71 Song song = new Song();
72 song.Name = s[(int)SongColumn.Name];
73 song.Difficulty = ConvUtil.GetDifficultyFromText(s[(int)SongColumn.Difficulty]);
74 song.TotalIconCount = ConvUtil.StrToIntDef(s[(int)SongColumn.TotalIconCount], 0);
75 song.LongIconCount = ConvUtil.StrToIntDef(s[(int)SongColumn.LongIconCount], 0);
76 song.Seconds = ConvUtil.StrToIntDef(s[(int)SongColumn.Seconds], 0);
77 song.SongType = ConvUtil.GetStatusTypeFromText(s[(int)SongColumn.SongType]);
78 return song;
79 }
80 public int ShortIconCountByIndex(int index) {
81 return _shortIcon[index];
82 }
83 public int LongIconCountByIndex(int index) {
84 return _longIcon[index];
85 }
86 public decimal ComboRatio(int index) {
87 return _comboRatio[index];
88 }
89 /// <summary>
90 /// アイコンの分布の初期化を行います。
91 /// ロングノーツは均等に分布しているものと仮定します。
92 /// </summary>
93 public void InitIconDistribution() {
94 decimal longRatio = 0m;
95 if(_longIconCount > 0) {
96 longRatio = (decimal)_longIconCount / (decimal)_totalIconCount;
97 } else {
98 longRatio = 0;
99 }
100 int nCount = _totalIconCount;
101
102 //1~50
103 if(_totalIconCount >= 50) {
104 _longIcon[0] = Convert.ToInt32(Math.Floor(50m * longRatio));
105 _shortIcon[0] = 50 - _longIcon[0];
106 } else {
107 _longIcon[0] = Convert.ToInt32(Math.Floor(_totalIconCount * longRatio));
108 _shortIcon[0] = _totalIconCount - _longIcon[0];
109 return;
110 }
111 //51~100
112 if(_totalIconCount >= 100) {
113 _longIcon[1] = Convert.ToInt32(Math.Floor(100m * longRatio)) - _longIcon[0];
114 _shortIcon[1] = 50 - _longIcon[1];
115 } else {
116 _longIcon[1] = _longIconCount - _longIcon[0];
117 _shortIcon[1] = _totalIconCount - 50 - _longIcon[1];
118 return;
119 }
120 //101~200
121 if(_totalIconCount >= 200) {
122 _longIcon[2] = Convert.ToInt32(Math.Floor(200m * longRatio)) - _longIcon[0] - _longIcon[1];
123 _shortIcon[2] = 100 - _longIcon[2];
124 } else {
125 _longIcon[2] = _longIconCount - _longIcon[0] - _longIcon[1];
126 _shortIcon[2] = _totalIconCount - 100 - _longIcon[2];
127 return;
128 }
129 //201~400
130 if(_totalIconCount >= 400) {
131 _longIcon[3] = Convert.ToInt32(Math.Floor(200m * longRatio)) - _longIcon[0] - _longIcon[1] - _longIcon[2];
132 _shortIcon[3] = 200 - _longIcon[3];
133 } else {
134 _longIcon[3] = _longIconCount - _longIcon[0] - _longIcon[1] - _longIcon[2];
135 _shortIcon[3] = _totalIconCount - 200 - _longIcon[3];
136 return;
137 }
138 if(_totalIconCount >= 401) {
139 _longIcon[4] = _longIconCount - _longIcon[0] - _longIcon[1] - _longIcon[2] - _longIcon[3];
140 _shortIcon[4] = _totalIconCount - 400 - _longIcon[4];
141 }
142 }
143
144
145 /// <summary>
146 /// PERFECT率を取得または設定します。
147 /// </summary>
148 public decimal PerfectRatio {
149 get {
150 return _perfectRatio;
151 }
152 set {
153 _perfectRatio = value;
154 }
155 }
156 /// <summary>
157 /// 曲名を取得または設定します。
158 /// </summary>
159 public string Name {
160 get {
161 return _name;
162 }
163 set {
164 _name = value;
165 }
166 }
167 /// <summary>
168 /// 曲の難易度を取得または設定します。
169 /// </summary>
170 public SongDifficulty Difficulty {
171 get {
172 return _difficulty;
173 }
174 set {
175 _difficulty = value;
176 }
177 }
178 /// <summary>
179 /// アイコン(単発・長押し合計)の個数を取得または設定します。
180 /// </summary>
181 public int TotalIconCount {
182 get {
183 return _totalIconCount;
184 }
185 set {
186 _totalIconCount = value;
187 }
188 }
189 /// <summary>
190 /// アイコン(長押し)の個数を取得または設定します。
191 /// </summary>
192 public int LongIconCount {
193 get {
194 return _longIconCount;
195 }
196 set {
197 _longIconCount = value;
198 }
199 }
200 /// <summary>
201 /// 曲の秒数を取得または設定します。
202 /// </summary>
203 public int Seconds {
204 get {
205 return _seconds;
206 }
207 set {
208 _seconds = value;
209 }
210 }
211 /// <summary>
212 /// 曲の属性を取得または設定します。
213 /// </summary>
214 public StatusType SongType {
215 get {
216 return _songType;
217 }
218 set {
219 _songType = value;
220 }
221 }
222 }
223 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26