質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -51,3 +51,453 @@
|
|
51
51
|
|
52
52
|
|
53
53
|
開発環境 Unity2019.1.5f1 VisualStudio
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
<1/22追記> 実際の使用コードを載せさせて頂きます。
|
58
|
+
|
59
|
+
```C#
|
60
|
+
|
61
|
+
using System.Collections;
|
62
|
+
|
63
|
+
using System.Collections.Generic;
|
64
|
+
|
65
|
+
using UnityEngine;
|
66
|
+
|
67
|
+
using UnityEngine.UI;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
public class rejudge : MonoBehaviour
|
72
|
+
|
73
|
+
{
|
74
|
+
|
75
|
+
//曲をセット
|
76
|
+
|
77
|
+
public GameObject mus1;
|
78
|
+
|
79
|
+
public GameObject mus2;
|
80
|
+
|
81
|
+
public GameObject mus3;
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
GameObject sc;
|
86
|
+
|
87
|
+
GameObject co;
|
88
|
+
|
89
|
+
GameObject cm;
|
90
|
+
|
91
|
+
GameObject notesystem;
|
92
|
+
|
93
|
+
GameObject aud;
|
94
|
+
|
95
|
+
GameObject han;
|
96
|
+
|
97
|
+
renotego goscript;
|
98
|
+
|
99
|
+
AudioSource to;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
Animation hante;
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
int tes;
|
108
|
+
|
109
|
+
//ノーツ情報
|
110
|
+
|
111
|
+
float notetim;
|
112
|
+
|
113
|
+
int noterean;
|
114
|
+
|
115
|
+
int notetyp;
|
116
|
+
|
117
|
+
float timer;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
int a, b;
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
public AudioClip don;
|
126
|
+
|
127
|
+
private AudioSource dk;
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
public static int sa = 0; //スコア
|
132
|
+
|
133
|
+
public static int cx = 0; //コンボ
|
134
|
+
|
135
|
+
public static int max;
|
136
|
+
|
137
|
+
public static int mima = 0; //ミス有での最大コンボ
|
138
|
+
|
139
|
+
public static int keij;
|
140
|
+
|
141
|
+
public static int soumiss;
|
142
|
+
|
143
|
+
public static int sougre;
|
144
|
+
|
145
|
+
public static int resa()
|
146
|
+
|
147
|
+
{
|
148
|
+
|
149
|
+
return sa;
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
public static int recx()
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
return cx;
|
158
|
+
|
159
|
+
}
|
160
|
+
|
161
|
+
public static int remima()
|
162
|
+
|
163
|
+
{
|
164
|
+
|
165
|
+
return mima;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
public static int reju()
|
170
|
+
|
171
|
+
{
|
172
|
+
|
173
|
+
return keij;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
public static int resou()
|
178
|
+
|
179
|
+
{
|
180
|
+
|
181
|
+
return soumiss;
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
public static int regre()
|
186
|
+
|
187
|
+
{
|
188
|
+
|
189
|
+
return sougre;
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
void Start()
|
196
|
+
|
197
|
+
{
|
198
|
+
|
199
|
+
tes = Selectmode.mode;
|
200
|
+
|
201
|
+
sa = 0;
|
202
|
+
|
203
|
+
cx = 0;
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
timer = 0;
|
208
|
+
|
209
|
+
soumiss = 0;
|
210
|
+
|
211
|
+
keij = 0;
|
212
|
+
|
213
|
+
sougre = 0;
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
//判定表示
|
218
|
+
|
219
|
+
han = GameObject.Find("判定A");
|
220
|
+
|
221
|
+
hante = han.GetComponent<Animation>();
|
222
|
+
|
223
|
+
han.GetComponent<Text>().text = "";
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
//選択された曲の番号
|
228
|
+
|
229
|
+
b = Trackscrolle.selectedtracknumber;
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
notesystem = GameObject.Find("5Rmanager");
|
236
|
+
|
237
|
+
goscript = notesystem.GetComponent<renotego>();
|
238
|
+
|
239
|
+
a = goscript.f;
|
240
|
+
|
241
|
+
switch (b)
|
242
|
+
|
243
|
+
{
|
244
|
+
|
245
|
+
case 3:
|
246
|
+
|
247
|
+
aud = mus1;
|
248
|
+
|
249
|
+
break;
|
250
|
+
|
251
|
+
case 4:
|
252
|
+
|
253
|
+
aud = mus2;
|
254
|
+
|
255
|
+
break;
|
256
|
+
|
257
|
+
case 5:
|
258
|
+
|
259
|
+
aud = mus3;
|
260
|
+
|
261
|
+
break;
|
262
|
+
|
263
|
+
default:
|
264
|
+
|
265
|
+
Debug.Log("存在しない曲情報です");
|
266
|
+
|
267
|
+
break;
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
to = aud.GetComponent<AudioSource>();
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
sc = GameObject.Find("Score");
|
276
|
+
|
277
|
+
GameObject sp = GameObject.Find("S");
|
278
|
+
|
279
|
+
co = GameObject.Find("chainsuu");
|
280
|
+
|
281
|
+
cm = GameObject.Find("conbo!");
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
if (tes == 1)
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
sc.GetComponent<Text>().text = "-";
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
co.SetActive(false);
|
296
|
+
|
297
|
+
cm.SetActive(false);
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
//効果音
|
302
|
+
|
303
|
+
dk = gameObject.GetComponent<AudioSource>();
|
304
|
+
|
305
|
+
dk.clip = don;
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
void Update()
|
312
|
+
|
313
|
+
{
|
314
|
+
|
315
|
+
timer = to.GetComponent<AudioSource>().time; //曲開始からの時刻
|
316
|
+
|
317
|
+
float perfectnumMin = -0.2f; //パーフェクト判定エリアの上限(タイミング+この数値)
|
318
|
+
|
319
|
+
float perfectnumMax = 0; //パーフェクト判定エリアの下限(タイミング+この数値)
|
320
|
+
|
321
|
+
float okMin = -0.1f; //グレートエリア上状限(タイミング-(パーフェクト上限+この数値))
|
322
|
+
|
323
|
+
float okMax = 0.1f; //グレートエリアの下限(タイミング+(パーフェクト下限+この数値))
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
if (tes == 0)
|
328
|
+
|
329
|
+
{
|
330
|
+
|
331
|
+
notetim = goscript.seikaku[a];//読み込まれた譜面データをこちらにも移動
|
332
|
+
|
333
|
+
noterean = goscript.rea[a];
|
334
|
+
|
335
|
+
notetyp = goscript.type[a];
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
if (notetim + perfectnumMin < timer && timer < notetim + perfectnumMax)
|
340
|
+
|
341
|
+
//パーフェクト判定
|
342
|
+
|
343
|
+
{
|
344
|
+
|
345
|
+
if (Input.GetKey(KeyCode.G) && noterean == 0) //レーン番号と対応したキーの入力
|
346
|
+
|
347
|
+
{
|
348
|
+
|
349
|
+
sa += 130;
|
350
|
+
|
351
|
+
cx += 1;
|
352
|
+
|
353
|
+
dk.Play(); //clipの音を再生
|
354
|
+
|
355
|
+
keij += 1;
|
356
|
+
|
357
|
+
Destroy(goscript.noteGo[a]);
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
a += 1;
|
362
|
+
|
363
|
+
}
|
364
|
+
|
365
|
+
//以下H~Lキー全て同じ処理
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
if (cx > 4)
|
370
|
+
|
371
|
+
{
|
372
|
+
|
373
|
+
co.SetActive(true);
|
374
|
+
|
375
|
+
co.GetComponent<Text>().enabled = true;
|
376
|
+
|
377
|
+
cm.SetActive(true);
|
378
|
+
|
379
|
+
cm.GetComponent<Text>().enabled = true;
|
380
|
+
|
381
|
+
}
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
}
|
390
|
+
|
391
|
+
else if (notetim + perfectnumMin + okMin < timer && timer < notetim + perfectnumMax + okMax) //グレート判定
|
392
|
+
|
393
|
+
{
|
394
|
+
|
395
|
+
if (Input.GetKey(KeyCode.G) && noterean == 0) //レーン番号と対応したキーの入力
|
396
|
+
|
397
|
+
{
|
398
|
+
|
399
|
+
if (notetyp == 1)
|
400
|
+
|
401
|
+
{
|
402
|
+
|
403
|
+
sa += 70;
|
404
|
+
|
405
|
+
cx += 1;
|
406
|
+
|
407
|
+
dk.Play();
|
408
|
+
|
409
|
+
sougre += 1;
|
410
|
+
|
411
|
+
han.GetComponent<Text>().text = "Great!";
|
412
|
+
|
413
|
+
hante.Play();
|
414
|
+
|
415
|
+
Destroy(goscript.noteGo[a]);
|
416
|
+
|
417
|
+
a += 1;
|
418
|
+
|
419
|
+
}
|
420
|
+
|
421
|
+
if (notetyp == 2)
|
422
|
+
|
423
|
+
{
|
424
|
+
|
425
|
+
sa += 130;
|
426
|
+
|
427
|
+
cx += 1;
|
428
|
+
|
429
|
+
dk.Play();
|
430
|
+
|
431
|
+
keij += 1;
|
432
|
+
|
433
|
+
han.GetComponent<Text>().text = "Perfect!";
|
434
|
+
|
435
|
+
hante.Play();
|
436
|
+
|
437
|
+
Destroy(goscript.noteGo[a]);
|
438
|
+
|
439
|
+
a += 1;
|
440
|
+
|
441
|
+
}
|
442
|
+
|
443
|
+
}
|
444
|
+
|
445
|
+
//以下H~Lキーまで同一
|
446
|
+
|
447
|
+
if (cx > 4)
|
448
|
+
|
449
|
+
{
|
450
|
+
|
451
|
+
co.SetActive(true);
|
452
|
+
|
453
|
+
co.GetComponent<Text>().enabled = true;
|
454
|
+
|
455
|
+
cm.SetActive(true);
|
456
|
+
|
457
|
+
cm.GetComponent<Text>().enabled = true;
|
458
|
+
|
459
|
+
}
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
}
|
464
|
+
|
465
|
+
else if (notetim + perfectnumMax + okMax < timer) //ミス処理
|
466
|
+
|
467
|
+
{
|
468
|
+
|
469
|
+
mima = cx;
|
470
|
+
|
471
|
+
cx = 0;
|
472
|
+
|
473
|
+
han.GetComponent<Text>().text = "Miss";
|
474
|
+
|
475
|
+
hante.Play();
|
476
|
+
|
477
|
+
|
478
|
+
|
479
|
+
soumiss += 1;
|
480
|
+
|
481
|
+
a += 1;
|
482
|
+
|
483
|
+
|
484
|
+
|
485
|
+
}
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
sc.GetComponent<Text>().text = sa.ToString(); //スコア表示
|
490
|
+
|
491
|
+
co.GetComponent<Text>().text = cx.ToString(); //コンボ表示
|
492
|
+
|
493
|
+
|
494
|
+
|
495
|
+
}
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
}
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
```
|