質問編集履歴
1
コードの追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -24,4 +24,229 @@
|
|
24
24
|
//以下別のレーン番号とキー全て同様の処理
|
25
25
|
```
|
26
26
|
|
27
|
-
開発環境 Unity2019.1.5f1 VisualStudio
|
27
|
+
開発環境 Unity2019.1.5f1 VisualStudio
|
28
|
+
|
29
|
+
<1/22追記> 実際の使用コードを載せさせて頂きます。
|
30
|
+
```C#
|
31
|
+
using System.Collections;
|
32
|
+
using System.Collections.Generic;
|
33
|
+
using UnityEngine;
|
34
|
+
using UnityEngine.UI;
|
35
|
+
|
36
|
+
public class rejudge : MonoBehaviour
|
37
|
+
{
|
38
|
+
//曲をセット
|
39
|
+
public GameObject mus1;
|
40
|
+
public GameObject mus2;
|
41
|
+
public GameObject mus3;
|
42
|
+
|
43
|
+
GameObject sc;
|
44
|
+
GameObject co;
|
45
|
+
GameObject cm;
|
46
|
+
GameObject notesystem;
|
47
|
+
GameObject aud;
|
48
|
+
GameObject han;
|
49
|
+
renotego goscript;
|
50
|
+
AudioSource to;
|
51
|
+
|
52
|
+
Animation hante;
|
53
|
+
|
54
|
+
int tes;
|
55
|
+
//ノーツ情報
|
56
|
+
float notetim;
|
57
|
+
int noterean;
|
58
|
+
int notetyp;
|
59
|
+
float timer;
|
60
|
+
|
61
|
+
int a, b;
|
62
|
+
|
63
|
+
public AudioClip don;
|
64
|
+
private AudioSource dk;
|
65
|
+
|
66
|
+
public static int sa = 0; //スコア
|
67
|
+
public static int cx = 0; //コンボ
|
68
|
+
public static int max;
|
69
|
+
public static int mima = 0; //ミス有での最大コンボ
|
70
|
+
public static int keij;
|
71
|
+
public static int soumiss;
|
72
|
+
public static int sougre;
|
73
|
+
public static int resa()
|
74
|
+
{
|
75
|
+
return sa;
|
76
|
+
}
|
77
|
+
public static int recx()
|
78
|
+
{
|
79
|
+
return cx;
|
80
|
+
}
|
81
|
+
public static int remima()
|
82
|
+
{
|
83
|
+
return mima;
|
84
|
+
}
|
85
|
+
public static int reju()
|
86
|
+
{
|
87
|
+
return keij;
|
88
|
+
}
|
89
|
+
public static int resou()
|
90
|
+
{
|
91
|
+
return soumiss;
|
92
|
+
}
|
93
|
+
public static int regre()
|
94
|
+
{
|
95
|
+
return sougre;
|
96
|
+
}
|
97
|
+
|
98
|
+
void Start()
|
99
|
+
{
|
100
|
+
tes = Selectmode.mode;
|
101
|
+
sa = 0;
|
102
|
+
cx = 0;
|
103
|
+
|
104
|
+
timer = 0;
|
105
|
+
soumiss = 0;
|
106
|
+
keij = 0;
|
107
|
+
sougre = 0;
|
108
|
+
|
109
|
+
//判定表示
|
110
|
+
han = GameObject.Find("判定A");
|
111
|
+
hante = han.GetComponent<Animation>();
|
112
|
+
han.GetComponent<Text>().text = "";
|
113
|
+
|
114
|
+
//選択された曲の番号
|
115
|
+
b = Trackscrolle.selectedtracknumber;
|
116
|
+
|
117
|
+
|
118
|
+
notesystem = GameObject.Find("5Rmanager");
|
119
|
+
goscript = notesystem.GetComponent<renotego>();
|
120
|
+
a = goscript.f;
|
121
|
+
switch (b)
|
122
|
+
{
|
123
|
+
case 3:
|
124
|
+
aud = mus1;
|
125
|
+
break;
|
126
|
+
case 4:
|
127
|
+
aud = mus2;
|
128
|
+
break;
|
129
|
+
case 5:
|
130
|
+
aud = mus3;
|
131
|
+
break;
|
132
|
+
default:
|
133
|
+
Debug.Log("存在しない曲情報です");
|
134
|
+
break;
|
135
|
+
}
|
136
|
+
to = aud.GetComponent<AudioSource>();
|
137
|
+
|
138
|
+
sc = GameObject.Find("Score");
|
139
|
+
GameObject sp = GameObject.Find("S");
|
140
|
+
co = GameObject.Find("chainsuu");
|
141
|
+
cm = GameObject.Find("conbo!");
|
142
|
+
|
143
|
+
if (tes == 1)
|
144
|
+
{
|
145
|
+
sc.GetComponent<Text>().text = "-";
|
146
|
+
}
|
147
|
+
|
148
|
+
co.SetActive(false);
|
149
|
+
cm.SetActive(false);
|
150
|
+
|
151
|
+
//効果音
|
152
|
+
dk = gameObject.GetComponent<AudioSource>();
|
153
|
+
dk.clip = don;
|
154
|
+
}
|
155
|
+
|
156
|
+
void Update()
|
157
|
+
{
|
158
|
+
timer = to.GetComponent<AudioSource>().time; //曲開始からの時刻
|
159
|
+
float perfectnumMin = -0.2f; //パーフェクト判定エリアの上限(タイミング+この数値)
|
160
|
+
float perfectnumMax = 0; //パーフェクト判定エリアの下限(タイミング+この数値)
|
161
|
+
float okMin = -0.1f; //グレートエリア上状限(タイミング-(パーフェクト上限+この数値))
|
162
|
+
float okMax = 0.1f; //グレートエリアの下限(タイミング+(パーフェクト下限+この数値))
|
163
|
+
|
164
|
+
if (tes == 0)
|
165
|
+
{
|
166
|
+
notetim = goscript.seikaku[a];//読み込まれた譜面データをこちらにも移動
|
167
|
+
noterean = goscript.rea[a];
|
168
|
+
notetyp = goscript.type[a];
|
169
|
+
|
170
|
+
if (notetim + perfectnumMin < timer && timer < notetim + perfectnumMax)
|
171
|
+
//パーフェクト判定
|
172
|
+
{
|
173
|
+
if (Input.GetKey(KeyCode.G) && noterean == 0) //レーン番号と対応したキーの入力
|
174
|
+
{
|
175
|
+
sa += 130;
|
176
|
+
cx += 1;
|
177
|
+
dk.Play(); //clipの音を再生
|
178
|
+
keij += 1;
|
179
|
+
Destroy(goscript.noteGo[a]);
|
180
|
+
|
181
|
+
a += 1;
|
182
|
+
}
|
183
|
+
//以下H~Lキー全て同じ処理
|
184
|
+
|
185
|
+
if (cx > 4)
|
186
|
+
{
|
187
|
+
co.SetActive(true);
|
188
|
+
co.GetComponent<Text>().enabled = true;
|
189
|
+
cm.SetActive(true);
|
190
|
+
cm.GetComponent<Text>().enabled = true;
|
191
|
+
}
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
}
|
196
|
+
else if (notetim + perfectnumMin + okMin < timer && timer < notetim + perfectnumMax + okMax) //グレート判定
|
197
|
+
{
|
198
|
+
if (Input.GetKey(KeyCode.G) && noterean == 0) //レーン番号と対応したキーの入力
|
199
|
+
{
|
200
|
+
if (notetyp == 1)
|
201
|
+
{
|
202
|
+
sa += 70;
|
203
|
+
cx += 1;
|
204
|
+
dk.Play();
|
205
|
+
sougre += 1;
|
206
|
+
han.GetComponent<Text>().text = "Great!";
|
207
|
+
hante.Play();
|
208
|
+
Destroy(goscript.noteGo[a]);
|
209
|
+
a += 1;
|
210
|
+
}
|
211
|
+
if (notetyp == 2)
|
212
|
+
{
|
213
|
+
sa += 130;
|
214
|
+
cx += 1;
|
215
|
+
dk.Play();
|
216
|
+
keij += 1;
|
217
|
+
han.GetComponent<Text>().text = "Perfect!";
|
218
|
+
hante.Play();
|
219
|
+
Destroy(goscript.noteGo[a]);
|
220
|
+
a += 1;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
//以下H~Lキーまで同一
|
224
|
+
if (cx > 4)
|
225
|
+
{
|
226
|
+
co.SetActive(true);
|
227
|
+
co.GetComponent<Text>().enabled = true;
|
228
|
+
cm.SetActive(true);
|
229
|
+
cm.GetComponent<Text>().enabled = true;
|
230
|
+
}
|
231
|
+
|
232
|
+
}
|
233
|
+
else if (notetim + perfectnumMax + okMax < timer) //ミス処理
|
234
|
+
{
|
235
|
+
mima = cx;
|
236
|
+
cx = 0;
|
237
|
+
han.GetComponent<Text>().text = "Miss";
|
238
|
+
hante.Play();
|
239
|
+
|
240
|
+
soumiss += 1;
|
241
|
+
a += 1;
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
sc.GetComponent<Text>().text = sa.ToString(); //スコア表示
|
246
|
+
co.GetComponent<Text>().text = cx.ToString(); //コンボ表示
|
247
|
+
|
248
|
+
}
|
249
|
+
|
250
|
+
}
|
251
|
+
|
252
|
+
```
|