質問編集履歴
1
GameManagerのスクリプトを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -137,3 +137,187 @@
|
|
137
137
|
}
|
138
138
|
|
139
139
|
```
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
```c#
|
144
|
+
|
145
|
+
using System.Collections;
|
146
|
+
|
147
|
+
using System.Collections.Generic;
|
148
|
+
|
149
|
+
using UnityEngine;
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
public class GManager : MonoBehaviour
|
154
|
+
|
155
|
+
{
|
156
|
+
|
157
|
+
public static GManager instance = null;
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
[Header("スコア")]public int score;
|
162
|
+
|
163
|
+
[Header("現在のスコア")]public int stageNum;
|
164
|
+
|
165
|
+
[Header("現在の復帰位置")]public int continueNum;
|
166
|
+
|
167
|
+
[Header("現在の残機")]public int heartNum;
|
168
|
+
|
169
|
+
[Header("デフォルトの残機")]public int defaultHeartNum;
|
170
|
+
|
171
|
+
[HideInInspector]public bool isGameOver = false;
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
private AudioSource audioSource = null;
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
private void Awake()
|
180
|
+
|
181
|
+
{
|
182
|
+
|
183
|
+
if(instance == null)
|
184
|
+
|
185
|
+
{
|
186
|
+
|
187
|
+
instance = this;
|
188
|
+
|
189
|
+
DontDestroyOnLoad(this.gameObject);
|
190
|
+
|
191
|
+
}
|
192
|
+
|
193
|
+
else
|
194
|
+
|
195
|
+
{
|
196
|
+
|
197
|
+
Destroy(this.gameObject);
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
private void Start()
|
206
|
+
|
207
|
+
{
|
208
|
+
|
209
|
+
audioSource = GetComponent<AudioSource>();
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
///<summary>
|
216
|
+
|
217
|
+
///残機を1つ増やす
|
218
|
+
|
219
|
+
///</summary>
|
220
|
+
|
221
|
+
public void AddHeartNum()
|
222
|
+
|
223
|
+
{
|
224
|
+
|
225
|
+
if(heartNum < 99)
|
226
|
+
|
227
|
+
{
|
228
|
+
|
229
|
+
++heartNum;
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
///<summary>
|
238
|
+
|
239
|
+
///残機を1つ減らす
|
240
|
+
|
241
|
+
///</summary>
|
242
|
+
|
243
|
+
public void SubHeartNum()
|
244
|
+
|
245
|
+
{
|
246
|
+
|
247
|
+
if(heartNum > 0)
|
248
|
+
|
249
|
+
{
|
250
|
+
|
251
|
+
--heartNum;
|
252
|
+
|
253
|
+
}
|
254
|
+
|
255
|
+
else
|
256
|
+
|
257
|
+
{
|
258
|
+
|
259
|
+
isGameOver = true;
|
260
|
+
|
261
|
+
}
|
262
|
+
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
///<summary>
|
268
|
+
|
269
|
+
///最初から始める時の処理
|
270
|
+
|
271
|
+
///</summary>
|
272
|
+
|
273
|
+
public void RetryGame()
|
274
|
+
|
275
|
+
{
|
276
|
+
|
277
|
+
isGameOver = false;
|
278
|
+
|
279
|
+
heartNum = defaultHeartNum;
|
280
|
+
|
281
|
+
score = 0;
|
282
|
+
|
283
|
+
stageNum = 1;
|
284
|
+
|
285
|
+
continueNum = 0;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
///<summary>
|
292
|
+
|
293
|
+
///SEを鳴らす
|
294
|
+
|
295
|
+
///</summary>
|
296
|
+
|
297
|
+
public void PlaySE(AudioClip clip)
|
298
|
+
|
299
|
+
{
|
300
|
+
|
301
|
+
if(audioSource != null)
|
302
|
+
|
303
|
+
{
|
304
|
+
|
305
|
+
audioSource.PlayOneShot(clip);
|
306
|
+
|
307
|
+
}
|
308
|
+
|
309
|
+
else
|
310
|
+
|
311
|
+
{
|
312
|
+
|
313
|
+
Debug.Log("オーディオソースが設定されていません");
|
314
|
+
|
315
|
+
}
|
316
|
+
|
317
|
+
}
|
318
|
+
|
319
|
+
}
|
320
|
+
|
321
|
+
コード
|
322
|
+
|
323
|
+
```
|