-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRightPanel.cs
More file actions
132 lines (103 loc) · 2.88 KB
/
RightPanel.cs
File metadata and controls
132 lines (103 loc) · 2.88 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
122
123
124
125
126
127
128
129
130
131
132
using Godot;
using System;
using System.Collections;
using System.Collections.Generic;
public partial class RightPanel : TextureRect
{
const int NumberOfButtons = 3;
const int IndexThreeKind = 0;
const int IndexFourKind = 1;
const int IndexChance = 2;
private IList<Button> _buttons = new List<Button>(NumberOfButtons);
private bool[] _buttonDisabled = new bool[NumberOfButtons];
private Main _mainScene;
public Main MainScene
{
get { return _mainScene; }
set
{
_mainScene = value;
_buttons.Add(GetNode<Button>("ThreeKindButton"));
_buttons.Add(GetNode<Button>("FourKindButton"));
_buttons.Add(GetNode<Button>("ChanceButton"));
value.MustRoll += MainScene_MustRoll;
value.FirstRoll += MainScene_FirstRoll;
}
}
public void MainScene_MustRoll(object sender, EventArgs e)
{
foreach(Button button in _buttons)
{
button.Disabled = true;
}
}
public void MainScene_FirstRoll(object sender, EventArgs e)
{
for (int i = 0; i < _buttons.Count; i++)
{
_buttons[i].Disabled = _buttonDisabled[i];
}
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void OnChance()
{
(int[] instanceCounts, bool foundFive) = MainScene.GetInstanceCounts();
int total = 0;
foreach(Dice die in MainScene.DiceList)
{
total += (int) die.Value;
}
GetNode<Label>("ChanceLabel/Label").Text = total.ToString();
_buttonDisabled[IndexChance] = true;
MainScene.ResetForNextRoll(total, foundFive);
}
public void OnThreeKind()
{
(int[] instanceCounts, bool foundFive) = MainScene.GetInstanceCounts();
bool foundThree = false;
bool foundFour = false;
foreach(int count in instanceCounts)
{
if (count == 3) foundThree = true;
if (count == 4) foundFour = true;
}
int total = 0;
if (foundFive || foundThree || foundFour)
{
foreach(Dice die in MainScene.DiceList)
{
total += (int) die.Value;
}
}
GetNode<Label>("ThreeKindLabel/Label").Text = total.ToString();
_buttonDisabled[IndexThreeKind] = true;
MainScene.ResetForNextRoll(total, foundFive);
}
public void OnFourKind()
{
(int[] instanceCounts, bool foundFive) = MainScene.GetInstanceCounts();
bool foundFour = false;
foreach(int count in instanceCounts)
{
if (count == 4) foundFour = true;
}
int total = 0;
if (foundFive || foundFour)
{
foreach(Dice die in MainScene.DiceList)
{
total += (int) die.Value;
}
}
GetNode<Label>("FourKindLabel/Label").Text = total.ToString();
_buttonDisabled[IndexFourKind] = true;
MainScene.ResetForNextRoll(total, foundFive);
}
}