using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ödev_1
{
public partial class Form1 : Form
{
int i, n, m, a, b, c = 0;
int[] zarrr = new int[6] { 1, 2, 3, 4, 5, 6 };
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//Rastgele Bir Zar Görüntülemek İçin
Random zar = new Random();
int zarr=zar.Next(6);
//zarın koşulları
if (zarrr[zarr] == 1)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible=true;
pictureBox4.Visible=false;
pictureBox6.Visible=false;
pictureBox7.Visible=false;
pictureBox8.Visible=false;
pictureBox9.Visible=false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "1";
// ilerlenilen toplam kare sayısı
a = a + 1;
}
else if (zarrr[zarr] == 2)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = true;
pictureBox6.Visible=false;
pictureBox7.Visible=false;
pictureBox8.Visible=false;
pictureBox9.Visible=false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "2";
// ilerlenilen toplam kare sayısı
a = a + 2;
}
else if (zarrr[zarr] == 3)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible=false;
pictureBox6.Visible = false;
pictureBox7.Visible=false;
pictureBox8.Visible=false;
pictureBox9.Visible=true;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "3";
// ilerlenilen toplam kare sayısı
a = a + 3;
}
else if (zarrr[zarr] == 4)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible=false;
pictureBox6.Visible=false;
pictureBox7.Visible =false ;
pictureBox8.Visible=true;
pictureBox9.Visible=false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "4";
// ilerlenilen toplam kare sayısı
a = a + 4;
}
else if (zarrr[zarr] == 5)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible=false;
pictureBox6.Visible=false;
pictureBox7.Visible=true;
pictureBox8.Visible = false;
pictureBox9.Visible=false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "5";
// ilerlenilen toplam kare sayısı
a = a + 5;
}
else if (zarrr[zarr] == 6)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = false;
pictureBox6.Visible = true;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "6";
// ilerlenilen toplam kare sayısı
a = a + 6;
}
//sponge bob'ın kaç kare gittiğini göstermek için
//skorbord
label6.Text = a.ToString();
//piyonun ilerlemesini sağlayan koşul
i = a;
//oyunun kazanıldığının uyarılması
if (a >= 80)
{
MessageBox.Show("Sponge Bob Kazandı! " + label7.Text + " / " + label6.Text);
//piyonların ortaya gelmesi
pictureBox5.Location = new Point(375, 290);
pictureBox11.Location = new Point(375, 270);
//zar atma butonlarının kapatılması
button1.Enabled = false;
button2.Enabled = false;
//oyuna başlama butonunun tekrar aktif olması
button3.Enabled = true;
// skorboardun sıfırlanması
a = 0;
c = 0;
label6.Text = a.ToString();
label7.Text = c.ToString();
}
else if (i >74)
{
n = 30;
m = 355;
b = i - 74;
pictureBox5.Location = new Point(n, m - (b * 50));
}
else if (i >61)
{
n = 680;
m = 355;
b = i - 61;
pictureBox5.Location = new Point(n - (b * 50), m);
}
else if (i >55)
{
n = 730;
m = 55;
b = i - 55;
pictureBox5.Location = new Point(n, m + (b * 50));
}
else if (i > 40)
{
n = 30;
m = 55;
b = i - 40;
pictureBox5.Location = new Point(n + (b * 50), m);
}
else if (i>34)
{
n = 30;
m = 355;
b = i - 34;
pictureBox5.Location = new Point(n, m - (b * 50));
}
else if (i >20)
{
n = 680;
m = 355;
b = i - 21;
pictureBox5.Location = new Point(n - (b * 50), m);
}
else if(i >14)
{
n = 730;
m = 55;
b = i - 14;
pictureBox5.Location = new Point(n, m + (b * 50));
}
else
{
n = 30;
m = 55;
pictureBox5.Location = new Point(n + (i * 50), m);
}
//zar atma sırası öbür oyuncuda mı?
if (a == 6 | a == 18 | a == 23 | a == 46 | a == 59 | a == 63)
{
MessageBox.Show("dadadada bir kere daha zar at");
}
else
{
button1.Enabled = false;
button2.Enabled = true;
}
}
private void button3_Click(object sender, EventArgs e)
{
pictureBox5.Location = new Point(30, 55);
pictureBox11.Location = new Point(30, 35);
//oyuna sponge bob başlar
button1.Enabled = true;
//oyuna başla düğmesi deaktif olur
button3.Enabled = false;
}
private void button2_Click(object sender, EventArgs e)
{
//Rastgele Bir Zar Görüntülemek İçin
Random zar = new Random();
int zarr = zar.Next(6);
//zarın koşulları
if (zarrr[zarr] == 1)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = true;
pictureBox4.Visible = false;
pictureBox6.Visible = false;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "1";
// ilerlenilen toplam kare sayısı
c = c + 1;
}
if (zarrr[zarr] == 2)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = true;
pictureBox6.Visible = false;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "2";
// ilerlenilen toplam kare sayısı
c = c+ 2;
}
if (zarrr[zarr] == 3)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = false;
pictureBox6.Visible = false;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = true;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "3";
// ilerlenilen toplam kare sayısı
c = c + 3;
}
if (zarrr[zarr] == 4)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = false;
pictureBox6.Visible = false;
pictureBox7.Visible = false;
pictureBox8.Visible = true;
pictureBox9.Visible = false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "4";
// ilerlenilen toplam kare sayısı
c = c + 4;
}
if (zarrr[zarr] == 5)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = false;
pictureBox6.Visible = false;
pictureBox7.Visible = true;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "5";
// ilerlenilen toplam kare sayısı
c = c + 5;
}
if (zarrr[zarr] == 6)
{
// zar sonucunun resmini görüntülemek için
pictureBox1.Visible = false;
pictureBox4.Visible = false;
pictureBox6.Visible = true;
pictureBox7.Visible = false;
pictureBox8.Visible = false;
pictureBox9.Visible = false;
// zar resminin altındaki sayıyı yazmak için
label2.Text = "6";
// ilerlenilen toplam kare sayısı
c = c + 6;
}
//patrik'in kaç kare gittiğini göstermek için
//skorbord
label7.Text = c.ToString();
//piyonun ilerlemesini sağlayan koşul
i = c;
//oyunun kazanıldığının uyarılması
if (c >= 80)
{
MessageBox.Show("Patrik Kazandı! " + label7.Text + " / " + label6.Text);
//piyonların ortaya gelmesi
pictureBox5.Location = new Point(375, 290);
pictureBox11.Location = new Point(375, 270);
//zar atma butonlarının kapatılması
button1.Enabled = false;
button2.Enabled = false;
//oyuna başlama butonunun tekrar aktif olması
button3.Enabled = true;
// skorboardun sıfırlanması
a = 0;
c = 0;
label6.Text = a.ToString();
label7.Text = c.ToString();
}
else if (i > 74)
{
n = 30;
m = 335;
b = i - 74;
pictureBox11.Location = new Point(n, m - (b * 50));
}
else if (i > 61)
{
n = 680;
m = 335;
b = i - 61;
pictureBox11.Location = new Point(n - (b * 50), m);
}
else if (i > 55)
{
n = 730;
m = 35;
b = i - 55;
pictureBox11.Location = new Point(n, m + (b * 50));
}
else if (i > 40)
{
n = 30;
m = 35;
b = i - 40;
pictureBox11.Location = new Point(n + (b * 50), m);
}
else if (i > 34)
{
n = 30;
m = 335;
b = i - 34;
pictureBox11.Location = new Point(n, m - (b * 50));
}
else if (i > 20)
{
n = 680;
m = 335;
b = i - 21;
pictureBox11.Location = new Point(n - (b * 50), m);
}
else if (i > 14)
{
n = 730;
m = 35;
b = i - 14;
pictureBox11.Location = new Point(n, m + (b * 50));
}
else
{
n = 30;
m = 35;
pictureBox11.Location = new Point(n + (i * 50), m);
}
//zar atma sırası öbür oyuncuda
if (c == 6 | c == 18 | c == 23 | c == 46 | c == 59 | c == 63)
{
MessageBox.Show("dadadada bir kere daha zar at");
}
else
{
button1.Enabled = true;
button2.Enabled = false;
}
}
}
}
|