-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameVariables.cs
90 lines (76 loc) · 2.67 KB
/
GameVariables.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
using UnityEngine;
using UnityEngine.UI;
public class GameVariables : MonoBehaviour
{
public Text levelText;
public Text coinText;
public Text timeText;
public Text scoreText;
public RectTransform joystick;
Color lightGreyTextColor = new Color(0.9547f, 0.9547f, 0.9547f, 1);
Color darkGreyTextColor = new Color(0.1960f, 0.1960f, 0.1960f, 1);
private void Start()
{
if( PlayerPrefs.GetInt("isChallange" , 0) == 1)
{
if (PlayerPrefs.GetInt("level", 1) < 10)
levelText.text = "Level : 0" + PlayerPrefs.GetInt("level", 1);
else
levelText.text = "Level : " + PlayerPrefs.GetInt("level", 1);
}
else
{
scoreText.text = "0";
}
joystick = GameObject.FindGameObjectWithTag("Joystick").GetComponent<RectTransform>();
if (PlayerPrefs.GetString("selectedJoystick", "Left") == "Left")
{
joystick.anchorMin = Vector2.zero;
joystick.anchorMax = Vector2.zero;
joystick.anchoredPosition = new Vector2(0 , 0);
}
else
{
joystick.anchorMin = Vector2.zero;
joystick.anchorMax = Vector2.zero;
joystick.anchoredPosition = new Vector2(0, 0);
}
if (PlayerPrefs.GetString("selectedMode", "Light") == "Dark")
{
if (PlayerPrefs.GetInt("isChallange", 0) == 0)
{
scoreText.color = lightGreyTextColor;
coinText.color = lightGreyTextColor;
}
else
{
timeText.color = lightGreyTextColor;
coinText.color = lightGreyTextColor;
levelText.color = lightGreyTextColor;
}
}
else
{
if (PlayerPrefs.GetInt("isChallange", 0) == 0)
{
scoreText.color = darkGreyTextColor;
coinText.color = darkGreyTextColor;
}
else
{
timeText.color = darkGreyTextColor;
coinText.color = darkGreyTextColor;
levelText.color = darkGreyTextColor;
}
}
}
// Update is called once per frame
void Update()
{
coinText.text = PlayerPrefs.GetInt("coin", 0).ToString();
if (timeText != null && MyTime.timeLeft >= 0)
timeText.text = Mathf.Round(MyTime.timeLeft).ToString();
else if (PlayerPrefs.GetInt("isChallange", 0) == 0)
scoreText.text = EnemyWaveController.highScore.ToString();
}
}