-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlevel2.cs
175 lines (174 loc) · 4.44 KB
/
level2.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class level2 : MonoBehaviour
{
int flag1 = 0;
int flag2 = 0;
int flag3 = 0;
int flag4 = 0;
int flag5 = 0;
public GameObject panel;//description panel
public GameObject panel1;//components panel
public GameObject image1;//xor
public GameObject image2;//xor
public GameObject image3;//and
public GameObject image4;//and
public GameObject image5;//or
public InputField input1;//A
public InputField input2;//B
public InputField input3;//C
public GameObject imagebulb1;//Sum
public GameObject imagebulb2;//carry
public GameObject playbutton;
public GameObject panel2;
public GameObject panel3;
public Text scorey;
int score = 100;
int buttonindex;
public void closePanel(int index)
{
if (index == 0)
panel3.SetActive(false);
if (index == 1)
panel.SetActive(false);
}
public void nextButton()
{
panel1.SetActive(false);
panel3.SetActive(true);
}
public void IUnderstoodButton()
{
if(flag1==1&&flag2==1&&flag3==1&&flag4==1&&flag5==1)
{
panel2.SetActive(true);
scorey.text = score + "";
}
}
public void selectLevelButton()
{
SceneManager.LoadScene(1);
}
public void Button1()
{
panel.SetActive(true);
buttonindex = 1;
flag1 = 1;
}
public void Button2()
{
panel.SetActive(true);
buttonindex = 1;
flag2 = 1;
}
public void Button3()
{
panel.SetActive(true);
buttonindex = 2;
flag3 = 1;
}
public void Button4()
{
panel.SetActive(true);
buttonindex = 2;
flag4 = 1;
}
public void Button5()
{
panel.SetActive(true);
buttonindex = 3;
flag5 = 1;
}
public void xorButton()
{
if(buttonindex==1&&flag1==1)
{
image1.SetActive(true);
}
if(buttonindex==1&&flag2==1)
{
image2.SetActive(true);
}
else
{
score -= 2;
}
}
public void andButton()
{
if (buttonindex == 2&&flag3==1)
{
image3.SetActive(true);
}
if(buttonindex==2&&flag4==1)
{
image4.SetActive(true);
}
else
{
score -= 2;
}
}
public void orButton()
{
if (buttonindex == 3)
{
image5.SetActive(true);
}
else
{
score -= 2;
}
}
public void DoneButton()
{
if (flag1 == 1 && flag2 == 1 && flag3==1 && flag4==1 && flag5==1)
playbutton.SetActive(true);
}
public void PlayButton()
{
if (input1.text == "0" && input2.text == "0" && input3.text=="0")
{
imagebulb1.SetActive(false);
imagebulb2.SetActive(false);
}
if (input1.text == "0" && input2.text == "0" && input3.text=="1")
{
imagebulb1.SetActive(true);
imagebulb2.SetActive(false);
}
if (input1.text == "0" && input2.text == "1" && input3.text == "0")
{
imagebulb1.SetActive(true);
imagebulb2.SetActive(false);
}
if (input1.text == "0" && input2.text == "1" && input3.text == "1")
{
imagebulb1.SetActive(false);
imagebulb2.SetActive(true);
}
if (input1.text == "1" && input2.text == "0" && input3.text == "0")
{
imagebulb1.SetActive(true);
imagebulb2.SetActive(false);
}
if (input1.text == "1" && input2.text == "0" && input3.text == "1")
{
imagebulb1.SetActive(false);
imagebulb2.SetActive(true);
}
if (input1.text == "1" && input2.text == "1" && input3.text == "0")
{
imagebulb1.SetActive(false);
imagebulb2.SetActive(true);
}
if (input1.text == "1" && input2.text == "1" && input3.text == "1")
{
imagebulb1.SetActive(true);
imagebulb2.SetActive(true);
}
}
}