-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager.cs
More file actions
60 lines (44 loc) · 1.39 KB
/
Copy pathGameManager.cs
File metadata and controls
60 lines (44 loc) · 1.39 KB
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//ゲーム起動からゲームスタートまでを管理するスクリプト
public class GameManager : MonoBehaviour
{
[SerializeField]
private Canvas startCanvas;
[SerializeField]
private Canvas gameCanvas;
public enum GameState
{
Pause,
Start,
}
public GameState state { get; private set; } = GameState.Pause;
void Awake()
{
Time.timeScale = 0;
startCanvas.gameObject.SetActive(true);
gameCanvas.gameObject.SetActive(false);
}
void Update()
{
if (state == GameState.Start) return;
//初めて画面がクリックされた場合ゲームを開始させる
//このスクリプトのstateがGamestate.Pauseの間はInputControllerでInputを受け付けさせない
if (Input.GetMouseButtonUp(0))
{
StartCoroutine(StartGame());
}
}
//他のInputControllerのGetMouseButtonUpと同時に作動させないためにGetMouseButtonUp後、1フレームおく
private IEnumerator StartGame()
{
yield return null;
Time.timeScale = 1;
state = GameState.Start;
startCanvas.gameObject.SetActive(false);
gameCanvas.gameObject.SetActive(true);
SoundManager.i.PlayOneShot(5);
SoundManager.i.PlayOneShot(4);
}
}