using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MindGame.Forms { public partial class GameForm : Form { public GameForm() { InitializeComponent(); } static int _MArr = 4; int[] _arrX = new int[_MArr]; int[] _arrY = new int[_MArr]; int[] _arrZ = new int[_MArr]; int[] _arrT = new int[_MArr]; int[] _arrA = new int[_MArr * _MArr]; int _wrongCounter; int _trueCounter; int _seconds = 10; int _iqPoint = 90; int _displayRight = 3; int _increaseMultiple = 3; int _dropMultiple = 3; int _second = 6; int _level = 1; bool IsTrue; bool IsPassed; Random Randomized = new Random(); private void EncryptionService(string MindGameAction) { Action func = null; func = (controls) => { foreach (Control control in controls) if (control is TextBox) { if (MindGameAction == "Encrypt") (control as TextBox).UseSystemPasswordChar = true; else if (MindGameAction == "Decrypt") (control as TextBox).UseSystemPasswordChar = false; } else func(control.Controls); }; func(Controls); } void LevelUpChecker() { if ((IX1.Text == _arrX[0].ToString() && IX2.Text == _arrX[1].ToString() && IX3.Text == _arrX[2].ToString() && IX4.Text == _arrX[3].ToString()) && (IY1.Text == _arrY[0].ToString() && IY2.Text == _arrY[1].ToString() && IY3.Text == _arrY[2].ToString() && IY4.Text == _arrY[3].ToString()) && (IZ1.Text == _arrZ[0].ToString() && IZ2.Text == _arrZ[1].ToString() && IZ3.Text == _arrZ[2].ToString() && IZ4.Text == _arrZ[3].ToString())) IsPassed = true; else IsPassed = false; if (IsPassed == true) { _level++; NextLevel(); } } /// /// Doğru, Yanlış, Streak, Level ve IQ Seviyesinin Hesaplandığı Aritmetik Kodlardır. /// void StatsService() { if (IsTrue == true) { _trueCounter += 1; _iqPoint += _trueCounter * _increaseMultiple; } if (IsTrue == false) { _wrongCounter += 1; _iqPoint -= _wrongCounter * _dropMultiple; } lblTrueCount.Text = $"True Counter : {_trueCounter}"; lblWrongCount.Text = $"Wrong Counter : {_wrongCounter}"; lblLevel.Text = $"Level : {_level}"; lblIQPoints.Text = $"IQ : {_iqPoint}"; } /// /// Rastgele Sayıları Üretip Bir Diziye Aktarma /// void NumberGeneratorService() { for (int ArrRoaming = 0; ArrRoaming < _MArr; ArrRoaming++) { _arrX[ArrRoaming] = Randomized.Next(1, 50); _arrY[ArrRoaming] = Randomized.Next(1, 50); _arrZ[ArrRoaming] = Randomized.Next(1, 50); _arrT[ArrRoaming] = Randomized.Next(1, 50); } FillingService(); } /// /// Dizilerde ki verileri /// void FillingService() { X1.Text = _arrX[0].ToString(); X2.Text = _arrX[1].ToString(); X3.Text = _arrX[2].ToString(); X4.Text = _arrX[3].ToString(); Y1.Text = _arrY[0].ToString(); Y2.Text = _arrY[1].ToString(); Y3.Text = _arrY[2].ToString(); Y4.Text = _arrY[3].ToString(); Z1.Text = _arrZ[0].ToString(); Z2.Text = _arrZ[1].ToString(); Z3.Text = _arrZ[2].ToString(); Z4.Text = _arrZ[3].ToString(); } private void GameForm_Load(object sender, EventArgs e) { ArrayController.Start(); } private void RandomizeServiceStarter_Tick(object sender, EventArgs e) { _seconds = _seconds - 1; if (_seconds < 11 && _seconds > 5) { RandomizeServiceStarter.Interval = 500; NumberGeneratorService(); } if (_seconds <= 6 && _seconds != 0) { RandomizeServiceStarter.Interval = 500; if (_seconds % 2 == 1) EncryptionService("Encrypt"); else if (_seconds % 2 == 0) EncryptionService("Decrypt"); } if (_seconds is 0) { RandomizeServiceStarter.Stop(); ArrayController.Start(); InputUnlocker(); } } void Stats() { foreach (var collector in _arrA) { } } private void btnCheck_Click(object sender, EventArgs e) { if (IX1.Text == _arrX[0].ToString()) { IX1.Enabled = false; IsTrue = true; StatsService(); } else { IX1.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IX2.Text == _arrX[1].ToString()) { IX2.Enabled = false; IsTrue = true; StatsService(); } else { IX2.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IX3.Text == _arrX[2].ToString()) { IX3.Enabled = false; IsTrue = true; StatsService(); } else { IX3.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IX4.Text == _arrX[3].ToString()) { IX4.Enabled = false; IsTrue = true; StatsService(); } else { IX4.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IY1.Text == _arrY[0].ToString()) { IY1.Enabled = false; IsTrue = true; StatsService(); } else { IY1.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IY2.Text == _arrY[1].ToString()) { IY2.Enabled = false; IsTrue = true; StatsService(); } else { IY2.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IY3.Text == _arrY[2].ToString()) { IY3.Enabled = false; IsTrue = true; StatsService(); } else { IY3.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IY4.Text == _arrY[3].ToString()) { IY4.Enabled = false; IsTrue = true; StatsService(); } else { IY4.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IZ1.Text == _arrZ[0].ToString()) { IZ1.Enabled = false; IsTrue = true; StatsService(); } else { IZ1.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IZ2.Text == _arrZ[1].ToString()) { IZ2.Enabled = false; IsTrue = true; StatsService(); } else { IZ2.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IZ3.Text == _arrZ[2].ToString()) { IZ3.Enabled = false; IsTrue = true; StatsService(); } else { IZ3.ForeColor = Color.Red; IsTrue = false; StatsService(); } if (IZ4.Text == _arrZ[3].ToString()) { IZ4.Enabled = false; IsTrue = true; StatsService(); } else { IZ4.ForeColor = Color.Red; IsTrue = false; StatsService(); } LevelUpChecker(); } void ClearInputComponents() { IX1.Clear(); IX2.Clear(); IX3.Clear(); IX4.Clear(); IY1.Clear(); IY2.Clear(); IY3.Clear(); IY4.Clear(); IZ1.Clear(); IZ2.Clear(); IZ3.Clear(); IZ4.Clear(); } private void btnStart_Click(object sender, EventArgs e) { ArrayController.Stop(); EncryptionService("Decrypt"); _seconds = 10; RandomizeServiceStarter.Start(); } private void DisplayEncryptorService_Tick(object sender, EventArgs e) { _second--; if (!(_displayRight == 0)) { if (_second % 2 == 0) EncryptionService("Encrypt"); else if (_second % 2 == 1) EncryptionService("Decrypt"); else if (_second == 0) { DisplayEncryptorService.Stop(); ArrayController.Start(); } } } private void btnShow_Click(object sender, EventArgs e) { _second = 6; if (_displayRight != 0) { _displayRight--; DisplayEncryptorService.Start(); ArrayController.Stop(); InputLocker(); } else MessageBox.Show("Gösterme Hakkınız Bulunmamaktadır.!"); lblShowRights.Text = $"Right to Display : {_displayRight}"; } private void InputDecryptService_Tick_1(object sender, EventArgs e) { IX1.UseSystemPasswordChar = false; IX2.UseSystemPasswordChar = false; IX3.UseSystemPasswordChar = false; IX4.UseSystemPasswordChar = false; IY1.UseSystemPasswordChar = false; IY2.UseSystemPasswordChar = false; IY3.UseSystemPasswordChar = false; IY4.UseSystemPasswordChar = false; IZ1.UseSystemPasswordChar = false; IZ2.UseSystemPasswordChar = false; IZ3.UseSystemPasswordChar = false; IZ4.UseSystemPasswordChar = false; } private void btnClear_Click(object sender, EventArgs e) { ClearInputComponents(); } private void btnReplay_Click(object sender, EventArgs e) { Application.Exit(); } void InputLocker() { IX1.Enabled = false; IX2.Enabled = false; IX3.Enabled = false; IX4.Enabled = false; IY1.Enabled = false; IY2.Enabled = false; IY3.Enabled = false; IY4.Enabled = false; IZ1.Enabled = false; IZ2.Enabled = false; IZ3.Enabled = false; IZ4.Enabled = false; } void InputUnlocker() { IX1.Enabled = true; IX2.Enabled = true; IX3.Enabled = true; IX4.Enabled = true; IY1.Enabled = true; IY2.Enabled = true; IY3.Enabled = true; IY4.Enabled = true; IZ1.Enabled = true; IZ2.Enabled = true; IZ3.Enabled = true; IZ4.Enabled = true; } void emptyArrayCollectorService() { foreach (var arrXhWnd in _arrX) _arrX[arrXhWnd] = 0; foreach (var arrYhWnd in _arrY) _arrY[arrYhWnd] = 0; foreach (var arrZhWnd in _arrZ) _arrZ[arrZhWnd] = 0; } void NextLevel() { if (IsPassed == true) { emptyArrayCollectorService(); FillingService(); EncryptionService("Decrypt"); ClearInputComponents(); ArrayController.Start(); } } private void ArrayController_Tick(object sender, EventArgs e) { bool ArrIsNull = ((_arrX[0] == 0 && _arrX[1] == 0 && _arrX[2] == 0 && _arrX[3] == 0 && _arrY[0] == 0 && _arrY[1] == 0 && _arrY[2] == 0 && _arrY[3] == 0 && _arrZ[0] == 0 && _arrZ[1] == 0 && _arrZ[2] == 0 && _arrZ[3] == 0)); if (ArrIsNull) InputLocker(); else if (!ArrIsNull) InputUnlocker(); } } }