-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorialOkButton.cs
More file actions
121 lines (94 loc) · 3.77 KB
/
Copy pathTutorialOkButton.cs
File metadata and controls
121 lines (94 loc) · 3.77 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
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TutorialOkButton : MonoBehaviour {
public AudioClip acClickOn;
public string[] tutorials;
public Sprite[] tutImages;
public string[] buttonQuotes;
private Button button;
private AudioSource audioOut;
private PlayerController pScript;
private LerpGameController gScript;
private int progress;
private WinPanel tutPanel;
private BuyPanelScript bPanel;
private Image tutImage;
private Text tuts;
private Text bbText;
private void Awake()
{
progress = 0;
tutImage = GameObject.FindGameObjectWithTag("uiTutPic").GetComponent<Image>();
if (tutImage == null)
Debug.Log("Tutorial Ok button couldnt get a reference to the Tutorial Sprite Image");
tuts = GameObject.FindGameObjectWithTag("uiTutText").GetComponent<Text>();
if (tuts == null)
Debug.Log("Tutorial OK button couldnt get a reference to the Tutorial Text Element");
}
// Use this for initialization
void Start()
{
button = GetComponent<Button>();
if (button == null)
Debug.Log("Tutorial OK Button script could not get a reference to the button sript.");
else
{
button.onClick.AddListener(NextTut);
bbText = GetComponentInChildren<Text>();
if (bbText == null)
Debug.Log("Tutorial Ok button couldnt get reference to its own Text");
}
audioOut = GetComponent<AudioSource>();
if (audioOut == null)
Debug.Log("Tutorial OK Button couldnt get its Audio Source component.");
gScript = GameObject.FindGameObjectWithTag("GameController").GetComponent<LerpGameController>();
if (gScript == null)
Debug.Log("Tutorial Ok Button script could not get a reference to the game controller.");
pScript = GameObject.FindGameObjectWithTag("PlayerController").GetComponent<PlayerController>();
if (pScript == null)
Debug.Log("Tutorial OK Button script could not get a reference to the Player controller.");
tutPanel = GetComponentInParent<WinPanel>();
if (tutPanel == null)
Debug.Log("Tutorial Ok Button couldnt get a reference to its parent Win Panel Script");
bPanel = GameObject.FindGameObjectWithTag("uiPanel").GetComponent<BuyPanelScript>();
if (bPanel == null)
Debug.Log("Open tutorial Button Couldnt Get reference to the ui Buy Panel");
progress = 0;
tutImage.sprite = tutImages[progress];
tuts.text = tutorials[progress];
bbText.text = buttonQuotes[progress];
}
// Update is called once per frame
void Update()
{
Image img = GetComponent<Image>();
Color cA = pScript.GetCharColorA();
Color cB = pScript.GetCharColorB();
Color foo = Color.Lerp(cB, cA, pScript.GetLerpVal());
foo.a = 255f;
img.color = foo;
}
public void NextTut()
{
audioOut.PlayOneShot(acClickOn, 0.8f);
progress++;
if (progress == 8)
{
progress = 0;
tutPanel.SetMovePanelOut();
gScript.SetTutorialDone();
//reset the tutorial for the next time it is played
tutImage.sprite = tutImages[0];
tuts.text = tutorials[0];
bbText.text = buttonQuotes[0];
}
else
{
tutImage.sprite = tutImages[progress];
tuts.text = tutorials[progress];
bbText.text = buttonQuotes[progress];
}
}
}