Adam Asmaca Oyunu

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 WindowsFormsApp12
{
public partial class Form1 : Form
{
String RastgeleKelime;
int uzuv = 0;
int TahminSayisi = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
RastgeleKelime = "Borusan";
RastgeleKelime = RastgeleKelime.ToUpper();
for (int i = 0; i < RastgeleKelime.Length; i++)
{
Label MetinKutusu = new Label();
MetinKutusu.Name = "Kutu" + i;
MetinKutusu.Size = new Size(30, 30);
MetinKutusu.Text = "_";
//MetinKutusu.MaxLength = 1; //tek karakter girebilsin diye
//int EkranOrtasi = this.Width/2 - (RastgeleKelime.Length * 30 / 2);
//MetinKutusu.Location = new Point(EkranOrtasi + i*30 , 300);
MetinKutusu.Location = new Point(100 + (i * 30), 100);
//MetinKutusu.Leave += HarfKontrol;
this.Controls.Add(MetinKutusu);
}
}
private void HarfKontrol(object sender, EventArgs e)
{
TahminSayisi++;
TextBox GelenHarf = (TextBox)sender; //MessageBox.Show(GelenHarf.Text.ToUpper());
char GirilenHarfBuyuk = Convert.ToChar(GelenHarf.Text.ToUpper());
bool Bildi = false;
/*foreach(var Harf in RastgeleKelime)
{*/
for(int HarfNo=0; HarfNo <RastgeleKelime.Length; HarfNo++) {
//MessageBox.Show(RastgeleKelime[HarfNo] + "==" + GirilenHarfBuyuk);
if (RastgeleKelime[HarfNo] == GirilenHarfBuyuk)
{
MessageBox.Show("bravo");
GelenHarf.BackColor = Color.Yellow;
Bildi = true;
break;
}
}
textBox1.Text = "";
if (!Bildi)
{
switch(uzuv)
{
case 0:
pictureBox1.Visible = true;
break;
case 1: pictureBox2.Visible = true;
break;
case 2:
pictureBox4.Visible = true;
break;
case 3:
pictureBox3.Visible = true;
break;
}
++uzuv;
if(uzuv >3)
{
MessageBox.Show("Youn bitti");
Application.Exit();
}
Label TahminHarfi = new Label();
TahminHarfi.Location = new Point(100 + (TahminSayisi * 30), 300);
TahminHarfi.Text = GelenHarf.Text;
this.Controls.Add(TahminHarfi);
//textBox1.Clear(); //
textBox1.Text = "";
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if(textBox1.Text.Length!=1) //boş geçilmesin diye
{
return;
}
HarfKontrol(sender, e);
}
}
}
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 WindowsFormsApp12
{
public partial class Form1 : Form
{
String RastgeleKelime;
int uzuv = 0;
int TahminSayisi = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
RastgeleKelime = "Borusan";
RastgeleKelime = RastgeleKelime.ToUpper();
for (int i = 0; i < RastgeleKelime.Length; i++)
{
Label MetinKutusu = new Label();
MetinKutusu.Name = "Kutu" + i;
MetinKutusu.Size = new Size(30, 30);
MetinKutusu.Text = "_";
//MetinKutusu.MaxLength = 1; //tek karakter girebilsin diye
//int EkranOrtasi = this.Width/2 - (RastgeleKelime.Length * 30 / 2);
//MetinKutusu.Location = new Point(EkranOrtasi + i*30 , 300);
MetinKutusu.Location = new Point(100 + (i * 30), 100);
//MetinKutusu.Leave += HarfKontrol;
this.Controls.Add(MetinKutusu);
}
}
private void HarfKontrol(object sender, EventArgs e)
{
TahminSayisi++;
TextBox GelenHarf = (TextBox)sender; //MessageBox.Show(GelenHarf.Text.ToUpper());
char GirilenHarfBuyuk = Convert.ToChar(GelenHarf.Text.ToUpper());
bool Bildi = false;
/*foreach(var Harf in RastgeleKelime)
{*/
for(int HarfNo=0; HarfNo <RastgeleKelime.Length; HarfNo++) {
//MessageBox.Show(RastgeleKelime[HarfNo] + "==" + GirilenHarfBuyuk);
if (RastgeleKelime[HarfNo] == GirilenHarfBuyuk)
{
MessageBox.Show("bravo");
GelenHarf.BackColor = Color.Yellow;
Bildi = true;
break;
}
}
textBox1.Text = "";
if (!Bildi)
{
switch(uzuv)
{
case 0:
pictureBox1.Visible = true;
break;
case 1: pictureBox2.Visible = true;
break;
case 2:
pictureBox4.Visible = true;
break;
case 3:
pictureBox3.Visible = true;
break;
}
++uzuv;
if(uzuv >3)
{
MessageBox.Show("Youn bitti");
Application.Exit();
}
Label TahminHarfi = new Label();
TahminHarfi.Location = new Point(100 + (TahminSayisi * 30), 300);
TahminHarfi.Text = GelenHarf.Text;
this.Controls.Add(TahminHarfi);
//textBox1.Clear(); //
textBox1.Text = "";
}
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if(textBox1.Text.Length!=1) //boş geçilmesin diye
{
return;
}
HarfKontrol(sender, e);
}
}
}