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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Jesus_Says
{
    public partial class Form1 : Form
    {
        MyColor c = new Color(Color.Gray);
        const byte START_LEVEL = 1;
        byte currentSublevel = 0;
        byte GameLevel = START_LEVEL;  //Level increases each time the pattern goes on properly
        byte playingLavel = 0;  //The current level being played.
        byte tsTickCount = 0;  // The byte used for the timer

        public Form1()
        {
            InitializeComponent();
            c = new MyColor();
        }

        private void Gamestart_Click(object sender, EventArgs e)
        {
            currentSublevel = 0;
            TimerStarts.Enabled = true;
            Gamestart.Visible = false;
        }

        private void TimerStarts_Tick(object sender, EventArgs e)
        {
            pbgreen.Visible = pbblue.Visible = pbyellow.Visible = pbred.Visible = false;
            switch (c.GetColor(currentSublevel))
            {
                case 1:
                    pbgreen.Visible = true;
                    break;
                case 2:
                    pbblue.Visible = true;
                    break;
                case 3:
                    pbyellow.Visible = true;
                    break;
                case 4:
                    pbred.Visible = true;
                    break;
            }
            if (currentSublevel < GameLevel - 1)
            {
                currentSublevel++;
            }
            else
            {
                TimerStarts.Enabled = false;
            }
            TimerStops.Enabled = true;
        }

        private void TimerStops_Tick(object sender, EventArgs e)
        {
            tsTickCount++;
            if (tsTickCount == 7)
            {
                pbgreen.Visible = pbblue.Visible = pbyellow.Visible = pbred.Visible = false;
                TimerStops.Enabled = false;
                tsTickCount = 0;
            }
        }

        private void greentop_Click(object sender, EventArgs e)
        {
            if (c.isTrueColor(playingLavel, 1))
            {
                playingLavel++;
                if (playingLavel == GameLevel)
                {
                    MessageBox.Show("Keep going.");
                    if (GameLevel < c.MaxLevel - 1)
                    {
                        GameLevel++;
                        scoretracker.Text = GameLevel.ToString();
                    }
                    playingLavel = 0;
                    Gamestart_Click(null, null);
                }
            }
            else
            {
                MessageBox.Show("Wrong pattern, try again please.");
                c = new MyColor();
                currentSublevel = 0;
                GameLevel = START_LEVEL;
                playingLavel = 0;
                scoretracker.Text = "0";
                Gamestart.Visible = true;
            }
        }

        private void bluetop_Click(object sender, EventArgs e)
        {
            if (c.isTrueColor(playingLavel, 2))
            {
                playingLavel++;
                if (playingLavel == GameLevel)
                {
                    MessageBox.Show("Well done");
                    if (GameLevel < c.MaxLevel - 1)
                    {
                        GameLevel++;
                        scoretracker.Text = GameLevel.ToString();
                    }
                    playingLavel = 0;
                    Gamestart_Click(null, null);
                }
            }
            else
            {
                MessageBox.Show("Wrong pattern, try again please.");
                c = new MyColor();
                currentSublevel = 0;
                GameLevel = START_LEVEL;
                playingLavel = 0;
                scoretracker.Text = "0";
                Gamestart.Visible = true;
            }
        }

        private void yellowtop_Click(object sender, EventArgs e)
        {
            if (c.isTrueColor(playingLavel, 3))
            {
                playingLavel++;
                if (playingLavel == GameLevel)
                {
                    MessageBox.Show("Well done!");
                    if (GameLevel < c.MaxLevel - 1)
                    {
                        GameLevel++;
                        scoretracker.Text = GameLevel.ToString();
                    }
                    playingLavel = 0;
                    Gamestart_Click(null, null);
                }
            }
            else
            {
                MessageBox.Show("Keep going");
                c = new MyColor();
                currentSublevel = 0;
                GameLevel = START_LEVEL;
                playingLavel = 0;
                scoretracker.Text = "0";
                Gamestart.Visible = true;
            }
        }

        private void redtop_Click(object sender, EventArgs e)
        {
            if (c.isTrueColor(playingLavel, 4))
            {
                playingLavel++;
                if (playingLavel == GameLevel)
                {
                    MessageBox.Show("Well done");
                    if (GameLevel < c.MaxLevel - 1)
                    {
                        GameLevel++;
                        scoretracker.Text = GameLevel.ToString();
                    }
                    playingLavel = 0;
                    Gamestart_Click(null, null);
                }
            }
            else
            {
                MessageBox.Show("Wrong pattern, try again please.");
                c = new MyColor();
                currentSublevel = 0;
                GameLevel = START_LEVEL;
                playingLavel = 0;
                scoretracker.Text = "0";
                Gamestart.Visible = true;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

    }
}