Skip to content

Commit 986cec2

Browse files
committed
Keypad is somewhat working now.
1 parent a0e0cec commit 986cec2

4 files changed

Lines changed: 24 additions & 7 deletions

File tree

Assets/Prefabs/BombGenerator.prefab

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ MonoBehaviour:
4242
- {fileID: 100010, guid: 4a2e12d27541e604d865357ebf3bc7cf, type: 2}
4343
solvableComponentPrefabs:
4444
- {fileID: 100002, guid: 134f1b9aa2193184c8609255ec19cec6, type: 2}
45+
- {fileID: 100002, guid: 857b932e96426ad48a7fadaae993e27e, type: 2}
4546
unsolvableComponentPrefabs:
4647
- {fileID: 100002, guid: a9a82478bcaaca048a7f3fff0d92c583, type: 2}
4748
requiredComponentPrefabs:
4849
- {fileID: 100008, guid: c98734093ef494a4f91bfce77be8df50, type: 2}
49-
requiredComponentPrefabs: []
5050
SerialNumberPrefab: {fileID: 100000, guid: b46e625f1f5a9e34fa743323f9caccad, type: 2}
5151
SerialNumberChance: 1
5252
--- !u!1001 &100100000

Assets/Scripts/KeypadButton.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ public class KeypadButton : MonoBehaviour {
55
public TextMesh text;
66
public KeypadComponent parentComponent;
77
public int buttonIndex;
8+
public bool isPressed;
89

910
// Use this for initialization
1011
void Start () {
11-
12+
isPressed = false;
1213
}
1314

1415
// Update is called once per frame
@@ -25,6 +26,10 @@ public string GetText() {
2526
}
2627

2728
public void SetHighlight(bool highlighted) {
29+
if (isPressed) {
30+
return;
31+
}
32+
2833
if(highlighted) {
2934
renderer.material.color = Color.gray;
3035
} else {
@@ -33,6 +38,9 @@ public void SetHighlight(bool highlighted) {
3338
}
3439

3540
public void Push() {
36-
parentComponent.ButtonPushed (buttonIndex);
41+
if (parentComponent.ButtonPushed (buttonIndex)) {
42+
isPressed = true;
43+
renderer.material.color = Color.green;
44+
}
3745
}
3846
}

Assets/Scripts/KeypadComponent.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,26 @@ void Update () {
2727
}
2828

2929
public bool ButtonPushed(int index) {
30+
KeypadButton pressedButton = buttons [index];
31+
int solutionValue = solutionOrder.IndexOf (pressedButton.GetText ());
32+
foreach(KeypadButton button in buttons) {
33+
int otherSolVal = solutionOrder.IndexOf (button.GetText ());
34+
if(!button.isPressed && otherSolVal < solutionValue) {
35+
return false;
36+
}
37+
}
38+
3039
return true;
3140
}
3241

3342
List<string> GetSolutionOrder() {
3443
List<string> solutionOrder = new List<string>(new string[]{"©","★","☆","ئ","ټ","Җ","Ω","Ѭ","Ѽ"});
3544
SerialNumber sn = SceneManager.Instance.Bomb.Serial;
3645
//Serial number starts with number
37-
if (!char.IsLetter(sn.GetSerialString()[0]))
46+
/*if (!char.IsLetter(sn.GetSerialString()[0]))
3847
{
3948
return new List<string>(new string[]{"Җ","Ѽ","★","©","ئ","☆","ټ","Ω","Ѭ"});
40-
}
49+
}*/
4150

4251
foreach (KeypadButton button in buttons) {
4352
if(button.GetText() == "Ѭ") {

Assets/briantest.unity

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,8 +2447,8 @@ MonoBehaviour:
24472447
m_Name:
24482448
m_EditorClassIdentifier:
24492449
BombGenerator: {fileID: 11400000, guid: 9b4083d146dcfca4181c9b4986300e84, type: 2}
2450-
NumStrikesToLose: 0
2451-
SecondsToSolve: 0
2450+
NumStrikesToLose: 5
2451+
SecondsToSolve: 120
24522452
Bomb: {fileID: 0}
24532453
--- !u!4 &1893693180
24542454
Transform:

0 commit comments

Comments
 (0)