-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinOkButton.cs
More file actions
63 lines (54 loc) · 1.89 KB
/
Copy pathWinOkButton.cs
File metadata and controls
63 lines (54 loc) · 1.89 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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WinOkButton : MonoBehaviour {
private Button button;
private MenuButton menuB;
private PlayerController pScript;
private bool okPerm;
// Use this for initialization
void Start () {
button = GetComponent<Button>();
if (button == null)
Debug.Log("Win Ok button couldnt get a reference to its button component");
else
button.onClick.AddListener(OkButton);
menuB = GameObject.FindGameObjectWithTag("MenuButton").GetComponent<MenuButton>();
if (menuB == null)
Debug.Log("Win Ok Button couldnt get reference to the menu button");
pScript = GameObject.FindGameObjectWithTag("PlayerController").GetComponent<PlayerController>();
if (pScript == null)
Debug.Log("Win OK Button script could not get a reference to the player controller.");
okPerm = false;
}
// 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;
// make sure to allow enough time for the coin counting to be done
if (okPerm == false && pScript.IsCoinCountingDone() == true)
{
okPerm = true;
button.enabled = true;
}
if (okPerm == true && pScript.IsCoinCountingDone() == false)
{
okPerm = false;
button.enabled = false;
}
}
public void OkButton()
{
if(okPerm == true)
{
menuB.enabled = true;
okPerm = false;
menuB.RoundOverMenu();
}
}
}