-
Notifications
You must be signed in to change notification settings - Fork 1
/
MenuUI.cs
109 lines (98 loc) · 3.3 KB
/
MenuUI.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
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Runtime.InteropServices;
public class MenuUI : MonoBehaviour
{
[DllImport("__Internal")]
private static extern void ConnectWallet();
[DllImport("__Internal")]
private static extern void DisconnectWallet();
[DllImport("__Internal")]
private static extern void SignTransactionAndSendMoney();
[SerializeField] private Button ConnectWalletButton;
[SerializeField] private GameObject ConnectPetraWalletText;
[SerializeField] private GameObject ConnectingText;
[SerializeField] private Button PlayButton;
[SerializeField] private GameObject PayText;
[SerializeField] private GameObject PayingText;
[SerializeField] private Button DisconnectButton;
// Called when the connect wallet button is pressed
public void ConnectPetra()
{
// Deactivate button
ConnectWalletButton.interactable = false;
// Change text
ConnectPetraWalletText.SetActive(false);
ConnectingText.SetActive(true);
// Open Petra Wallet
ConnectWallet();
}
// Called when the ConnectWallet() function terminates with an error
public void ConnectPetraError()
{
// Change text
ConnectingText.SetActive(false);
ConnectPetraWalletText.SetActive(true);
// Activate button
ConnectWalletButton.interactable = true;
}
// Called when the ConnectWallet() function terminates successfully
public void ConnectPetraSuccess()
{
// Hide connect wallet button
ConnectWalletButton.gameObject.SetActive(false);
// Activate button
ConnectWalletButton.interactable = true;
// Change text
ConnectingText.SetActive(false);
ConnectPetraWalletText.SetActive(true);
// Show play button
PlayButton.gameObject.SetActive(true);
// Show disconnect button
DisconnectButton.gameObject.SetActive(true);
}
// Called when the disconnect button is pressed
public void DisconnectPetra()
{
DisconnectWallet();
}
// Called when the ConnectWallet() function terminates successfully
public void DisconnectPetraSuccess()
{
// Hide play button
PlayButton.gameObject.SetActive(false);
// Hide disconnect button
DisconnectButton.gameObject.SetActive(false);
// Show connect wallet button
ConnectWalletButton.gameObject.SetActive(true);
}
// Called when the pay and play button is pressed
public void PayAndPlay()
{
// Deactivate button
PlayButton.interactable = false;
DisconnectButton.interactable = false;
// Change text
PayText.SetActive(false);
PayingText.SetActive(true);
// Sign and Pay
SignTransactionAndSendMoney();
}
// Called when the SignTransactionAndSendMoney() function terminates with an error
public void PayAndPlayError()
{
// Change text
PayingText.SetActive(false);
PayText.SetActive(true);
// Activate button
PlayButton.interactable = true;
DisconnectButton.interactable = true;
}
// Called when the SignTransactionAndSendMoney() function terminates successfully
public void PayAndPlaySuccess()
{
// Load 'Game' scene
Application.LoadLevel(1);
}
}