-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsMenu.cs
122 lines (93 loc) · 3.87 KB
/
SettingsMenu.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
using UnityEngine;
using UnityEngine.UI;
public class SettingsMenu : MonoBehaviour
{
public GameObject settingsMenu;
public Sprite circleBackgroundLight;
public Sprite circleBackgroundDark;
public Camera mainCamera;
public GameObject mainPanel;
Color lightGreenColor = new Color(0.1568f, .7725f, .0901f, 1);
Color lightGreyColor = new Color(0.9547f, 0.9547f, 0.9547f, 1f);
Color darkGreenColor = new Color(0.0980f, 0.4352f, 0.0549f, 1);
Color darkGreyColor = new Color(0.2641f, 0.2641f, 0.2641f, 1f);
public GameObject vehicles;
public GameObject circles;
public Text theCircleText;
public void PlayPauseMusic()
{
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
FindObjectOfType<AudioManager>().Play("ButtonSound");
}
if ( PlayerPrefs.GetInt("MusicEnabled" , 1) == 1)
{
FindObjectOfType<AudioManager>().Pause("GameMusic");
PlayerPrefs.SetInt("MusicEnabled", 0);
}
else
{
FindObjectOfType<AudioManager>().Play("GameMusic");
PlayerPrefs.SetInt("MusicEnabled", 1);
}
}
public void PlayPauseSound()
{
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
FindObjectOfType<AudioManager>().Play("ButtonSound");
}
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
PlayerPrefs.SetInt("SoundEnabled", 0);
}
else
{
PlayerPrefs.SetInt("SoundEnabled", 1);
}
}
public void LightMode()
{
Component[] circleTexts = circles.GetComponentsInChildren<Text>();
foreach (Text text in circleTexts)
text.color = darkGreyColor;
Component[] vehicleTexts = vehicles.GetComponentsInChildren<Text>();
foreach (Text text in vehicleTexts)
text.color = darkGreyColor;
theCircleText.color = new Color(.196f, .196f, .196f, 1f);
PlayerPrefs.SetString("selectedMode", "Light");
mainPanel.GetComponent<Image>().sprite = circleBackgroundLight;
Component[] mainPanelTexts = mainPanel.GetComponentsInChildren<Text>();
foreach (Text text in mainPanelTexts)
text.color = darkGreyColor;
mainCamera.backgroundColor = lightGreenColor;
GameObject.FindGameObjectWithTag("LightModeButton").GetComponent<Image>().color = new Color32(255, 255, 255, 255);
GameObject.FindGameObjectWithTag("DarkModeButton").GetComponent<Image>().color = new Color32(200, 200, 200, 128);
}
public void DarkMode()
{
Component[] circleTexts = circles.GetComponentsInChildren<Text>();
foreach (Text text in circleTexts)
text.color = lightGreyColor;
Component[] vehicleTexts = vehicles.GetComponentsInChildren<Text>();
foreach (Text text in vehicleTexts)
text.color = lightGreyColor;
theCircleText.color = new Color(1f, 1f, 1f, 1f);
PlayerPrefs.SetString("selectedMode", "Dark");
mainPanel.GetComponent<Image>().sprite = circleBackgroundDark;
Component[] mainPanelTexts = mainPanel.GetComponentsInChildren<Text>();
foreach (Text text in mainPanelTexts)
text.color = lightGreyColor;
mainCamera.backgroundColor = darkGreenColor;
GameObject.FindGameObjectWithTag("LightModeButton").GetComponent<Image>().color = new Color32(200, 200, 200, 128);
GameObject.FindGameObjectWithTag("DarkModeButton").GetComponent<Image>().color = new Color32(255, 255, 255, 255);
}
public void BackToMainMenu()
{
if (PlayerPrefs.GetInt("SoundEnabled", 1) == 1)
{
FindObjectOfType<AudioManager>().Play("ButtonSound");
}
settingsMenu.SetActive(false);
}
}