Skip to content

Commit cd40847

Browse files
committed
Code cleanup and formatting changes
1 parent 05c3e42 commit cd40847

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

Assets/Scripts/GameManager.cs

+21-16
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,35 @@ public class GameManager : MonoBehaviour
1212
[SerializeField] private GameObject playButton;
1313
[SerializeField] private GameObject gameOver;
1414

15-
private int score;
16-
public int Score => score;
15+
public int score { get; private set; }
1716

1817
private void Awake()
1918
{
20-
if (Instance != null)
21-
{
19+
if (Instance != null) {
2220
DestroyImmediate(gameObject);
23-
}
24-
else
25-
{
21+
} else {
2622
Instance = this;
27-
Application.targetFrameRate = 60;
28-
DontDestroyOnLoad(gameObject);
29-
Pause();
3023
}
3124
}
3225

26+
private void OnDestroy()
27+
{
28+
if (Instance == this) {
29+
Instance = null;
30+
}
31+
}
32+
33+
private void Start()
34+
{
35+
Pause();
36+
}
37+
38+
public void Pause()
39+
{
40+
Time.timeScale = 0f;
41+
player.enabled = false;
42+
}
43+
3344
public void Play()
3445
{
3546
score = 0;
@@ -56,12 +67,6 @@ public void GameOver()
5667
Pause();
5768
}
5869

59-
public void Pause()
60-
{
61-
Time.timeScale = 0f;
62-
player.enabled = false;
63-
}
64-
6570
public void IncreaseScore()
6671
{
6772
score++;

0 commit comments

Comments
 (0)