Ejemplo n.º 1
0
        private void ChessButton_MouseDown(object sender, MouseEventArgs e)  //Tahtadaki Karelerin MouseDown eventi ..
        {
            ChessButton castedbutton = (ChessButton)sender;

            this.txt_tahta_x.Text = castedbutton.X.ToString();
            this.txt_tahta_y.Text = castedbutton.Y.ToString();
            if (castedbutton.Tas != null)
            {
                castedbutton.Tas.MakeCangoList();
                Holded = castedbutton.Tas;

                foreach (Kordinat VARIABLE in castedbutton.Tas.KordinatsCanGo)
                {
                    Squares[VARIABLE.Y, VARIABLE.X].BackColor = Color.Blue;
                }

                tasima = true;
            }

            else if (tasima)
            {
                PaintBoard();
                Holded.Move(castedbutton.X, castedbutton.Y);
                tasima = false;
            }
        }
Ejemplo n.º 2
0
 private void Button2_Click(object sender, EventArgs e)
 {
     foreach (Tas VARIABLE in MevcutTaslar)
     {
         Tas kale = VARIABLE;
         kale.RandomGit();
     }
 }
Ejemplo n.º 3
0
        private void ChessButton_MouseDown(object sender, MouseEventArgs e)  //Tahtadaki Karelerin MouseDown eventi ..
        {
            PaintBoard();
            ChessButton castedbutton = (ChessButton)sender;

            this.txt_tahta_x.Text = castedbutton.X.ToString();
            this.txt_tahta_y.Text = castedbutton.Y.ToString();


            if (castedbutton.Tas != null && !tasima)
            {
                Oldx = castedbutton.X;
                Oldy = castedbutton.Y;
                castedbutton.Tas.MakeCangoList();
                Holded = castedbutton.Tas;

                foreach (Kordinat VARIABLE in castedbutton.Tas.KordinatsCanGo)
                {
                    Squares[VARIABLE.Y, VARIABLE.X].BackColor = Color.Blue;
                }

                tasima = true;
            }

            else if (tasima)
            {
                if (castedbutton.X == Oldx && castedbutton.Y == Oldy)
                {
                    tasima = false;
                }

                else
                {
                    if ((!TurnOfBlack && Holded.İsBlack) || (TurnOfBlack && !Holded.İsBlack)) // oyun sırası siyahta ama oynanan tas beyazsa ve tersi durum için hata fırlatma kısmı
                    {
                        MessageBox.Show("Oynama Sırası Karşı Tarafın ..");
                        tasima = false;
                    }
                    else
                    {
                        Holded.Move(castedbutton.X, castedbutton.Y);
                        tasima      = false;
                        TurnOfBlack = !TurnOfBlack;
                        EndGameCheck();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public void NewGame()
        {
            MevcutTaslar.Clear();
            Holded = null;
            WhiteAttacks.Clear();
            BlackAttacks.Clear();
            TurnOfBlack = false;
            tasima      = false;
            foreach (ChessButton VARIABLE in Squares)
            {
                VARIABLE.Tas    = null;
                VARIABLE.Dolumu = false;
                VARIABLE.GetBackgroundİmage();
            }
            CreateTas(Squares[7, 0], TasTipi.Kale, true);
            CreateTas(Squares[7, 1], TasTipi.At, true);
            CreateTas(Squares[7, 2], TasTipi.Fil, true);
            CreateTas(Squares[7, 3], TasTipi.Sah, true);
            CreateTas(Squares[7, 4], TasTipi.Vezir, true);
            CreateTas(Squares[7, 5], TasTipi.Fil, true);
            CreateTas(Squares[7, 6], TasTipi.At, true);
            CreateTas(Squares[7, 7], TasTipi.Kale, true);
            CreateTas(Squares[6, 0], TasTipi.Piyon, true);
            CreateTas(Squares[6, 1], TasTipi.Piyon, true);
            CreateTas(Squares[6, 2], TasTipi.Piyon, true);
            CreateTas(Squares[6, 3], TasTipi.Piyon, true);
            CreateTas(Squares[6, 4], TasTipi.Piyon, true);
            CreateTas(Squares[6, 5], TasTipi.Piyon, true);
            CreateTas(Squares[6, 6], TasTipi.Piyon, true);
            CreateTas(Squares[6, 7], TasTipi.Piyon, true);

            CreateTas(Squares[0, 0], TasTipi.Kale, false);
            CreateTas(Squares[0, 1], TasTipi.At, false);
            CreateTas(Squares[0, 2], TasTipi.Fil, false);
            CreateTas(Squares[0, 3], TasTipi.Sah, false);
            CreateTas(Squares[0, 4], TasTipi.Vezir, false);
            CreateTas(Squares[0, 5], TasTipi.Fil, false);
            CreateTas(Squares[0, 6], TasTipi.At, false);
            CreateTas(Squares[0, 7], TasTipi.Kale, false);
            CreateTas(Squares[1, 0], TasTipi.Piyon, false);
            CreateTas(Squares[1, 1], TasTipi.Piyon, false);
            CreateTas(Squares[1, 2], TasTipi.Piyon, false);
            CreateTas(Squares[1, 3], TasTipi.Piyon, false);
            CreateTas(Squares[1, 4], TasTipi.Piyon, false);
            CreateTas(Squares[1, 5], TasTipi.Piyon, false);
            CreateTas(Squares[1, 6], TasTipi.Piyon, false);
            CreateTas(Squares[1, 7], TasTipi.Piyon, false);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Taşı verilen Konuma Deneme Olarak Götürür .. Şah tehdit altında kalıyormu diye kontrol eder .. Gerçek bir Hamle İşlemi Gerçekleştirme ..
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public virtual bool FakeMove(int x, int y)
        {
            bool EverythingİsOk = true;

            FillAllCanGoList();
            FillAttackList();

            int OldX = TasKordinat.X, OldY = TasKordinat.Y;



            foreach (Kordinat VARIABLE in KordinatsCanGo)
            {
                if (VARIABLE.X == x && VARIABLE.Y == y)
                {
                    if (ChessBoard.Squares[y, x].Tas != null)
                    {
                        Tas CopyTarget = ChessBoard.Squares[y, x].Tas;
                        CopyTarget.TasKordinat.X           = 10;
                        CopyTarget.TasKordinat.Y           = 10;
                        ChessBoard.Squares[OldY, OldX].Tas = null;
                        ChessBoard.Squares[OldY, OldX].GetBackgroundİmage();
                        ChessBoard.Squares[OldY, OldX].Dolumu = false;
                        TasKordinat.X = x;
                        TasKordinat.Y = y;
                        ChessBoard.Squares[y, x].Tas = this;
                        ChessBoard.Squares[y, x].GetBackgroundİmage();
                        ChessBoard.Squares[y, x].Dolumu = true;
                        FillAllCanGoList();
                        FillAttackList();
                        if (İsKingDanger())
                        {
                            EverythingİsOk = false;
                        }

                        ChessBoard.Squares[OldY, OldX].Tas = this;
                        ChessBoard.Squares[OldY, OldX].GetBackgroundİmage();
                        ChessBoard.Squares[OldY, OldX].Dolumu = true;
                        TasKordinat.X                = OldX;
                        TasKordinat.Y                = OldY;
                        CopyTarget.TasKordinat.X     = x;
                        CopyTarget.TasKordinat.Y     = y;
                        ChessBoard.Squares[y, x].Tas = CopyTarget;
                        ChessBoard.Squares[y, x].GetBackgroundİmage();
                        ChessBoard.Squares[y, x].Dolumu = true;
                        break;
                    }
                    else
                    {
                        ChessBoard.Squares[OldY, OldX].Tas = null;
                        ChessBoard.Squares[OldY, OldX].GetBackgroundİmage();
                        ChessBoard.Squares[OldY, OldX].Dolumu = false;
                        TasKordinat.X = x;
                        TasKordinat.Y = y;
                        ChessBoard.Squares[y, x].Tas = this;
                        ChessBoard.Squares[y, x].GetBackgroundİmage();
                        ChessBoard.Squares[y, x].Dolumu = true;
                        FillAllCanGoList();
                        FillAttackList();
                        if (İsKingDanger())
                        {
                            EverythingİsOk = false;
                        }


                        ChessBoard.Squares[OldY, OldX].Tas = this;
                        ChessBoard.Squares[OldY, OldX].GetBackgroundİmage();
                        ChessBoard.Squares[OldY, OldX].Dolumu = true;
                        TasKordinat.X = OldX;
                        TasKordinat.Y = OldY;
                        ChessBoard.Squares[y, x].Tas = null;
                        ChessBoard.Squares[y, x].GetBackgroundİmage();
                        ChessBoard.Squares[y, x].Dolumu = false;
                        break;
                    }
                }
            }
            FillAllCanGoList();
            FillAttackList();

            return(EverythingİsOk);
        }
Ejemplo n.º 6
0
        public abstract void MakeCangoList(); // taşın gidebileceği Karelerin Listesini yeniler ..

        public virtual bool FakeMove(int x, int y)
        {
            bool EverythingİsOk = true;

            FillAllCanGoList();
            FillAttackList();

            int OldX = this.TasKordinat.X, OldY = this.TasKordinat.Y;



            foreach (Kordinat VARIABLE in this.KordinatsCanGo)
            {
                if (VARIABLE.X == x && VARIABLE.Y == y)
                {
                    if (Form1.Squares[y, x].Tas != null)
                    {
                        Tas CopyTarget = Form1.Squares[y, x].Tas;
                        CopyTarget.TasKordinat.X      = 10;
                        CopyTarget.TasKordinat.Y      = 10;
                        Form1.Squares[OldY, OldX].Tas = null;
                        Form1.Squares[OldY, OldX].GetBackgroundİmage();
                        Form1.Squares[OldY, OldX].Dolumu = false;
                        this.TasKordinat.X      = x;
                        this.TasKordinat.Y      = y;
                        Form1.Squares[y, x].Tas = this;
                        Form1.Squares[y, x].GetBackgroundİmage();
                        Form1.Squares[y, x].Dolumu = true;
                        FillAllCanGoList();
                        FillAttackList();
                        if (İsKingDanger())
                        {
                            EverythingİsOk = false;
                        }

                        Form1.Squares[OldY, OldX].Tas = this;
                        Form1.Squares[OldY, OldX].GetBackgroundİmage();
                        Form1.Squares[OldY, OldX].Dolumu = true;
                        this.TasKordinat.X       = OldX;
                        this.TasKordinat.Y       = OldY;
                        CopyTarget.TasKordinat.X = x;
                        CopyTarget.TasKordinat.Y = y;
                        Form1.Squares[y, x].Tas  = CopyTarget;
                        Form1.Squares[y, x].GetBackgroundİmage();
                        Form1.Squares[y, x].Dolumu = true;
                        break;
                    }
                    else
                    {
                        Form1.Squares[OldY, OldX].Tas = null;
                        Form1.Squares[OldY, OldX].GetBackgroundİmage();
                        Form1.Squares[OldY, OldX].Dolumu = false;
                        this.TasKordinat.X      = x;
                        this.TasKordinat.Y      = y;
                        Form1.Squares[y, x].Tas = this;
                        Form1.Squares[y, x].GetBackgroundİmage();
                        Form1.Squares[y, x].Dolumu = true;
                        FillAllCanGoList();
                        FillAttackList();
                        if (İsKingDanger())
                        {
                            EverythingİsOk = false;
                        }


                        Form1.Squares[OldY, OldX].Tas = this;
                        Form1.Squares[OldY, OldX].GetBackgroundİmage();
                        Form1.Squares[OldY, OldX].Dolumu = true;
                        this.TasKordinat.X      = OldX;
                        this.TasKordinat.Y      = OldY;
                        Form1.Squares[y, x].Tas = null;
                        Form1.Squares[y, x].GetBackgroundİmage();
                        Form1.Squares[y, x].Dolumu = false;
                        break;
                    }
                }
            }


            return(EverythingİsOk);
        } // taşı verilen konuma deneme olarak götürür ve şah tehdit altına giriyormu kontrol eder .!!
Ejemplo n.º 7
0
        private void ChessButton_MouseDown(object sender, MouseEventArgs e)  //Tahtadaki Karelerin MouseDown eventi ..
        {
            PaintBoard();
            ChessButton castedbutton = (ChessButton)sender;


            this.txt_tahta_x.Text = castedbutton.X.ToString();
            this.txt_tahta_y.Text = castedbutton.Y.ToString();


            if (castedbutton.Tas != null && !tasima)
            {
                Oldx = castedbutton.X;
                Oldy = castedbutton.Y;
                castedbutton.Tas.MakeCangoList();
                Holded = castedbutton.Tas;


                foreach (Kordinat VARIABLE in castedbutton.Tas.KordinatsCanGo)
                {
                    if (VARIABLE.KordinatType == KordinatType.Attack && castedbutton.Tas.TasTipi == TasTipi.Piyon)
                    {
                        Piyon asd = (Piyon)castedbutton.Tas;
                        if (Squares[VARIABLE.Y, VARIABLE.X].Tas == null)
                        {
                            continue;
                        }
                        if (Squares[VARIABLE.Y, VARIABLE.X].Tas.ÝsBlack != asd.ÝsBlack)
                        {
                            Squares[VARIABLE.Y, VARIABLE.X].BackColor = Color.Yellow;
                        }
                    }
                    Squares[VARIABLE.Y, VARIABLE.X].BackColor = Color.Yellow;
                }

                //tasima = true;
                ChessButton asdf = (ChessButton)sender;
                asdf.DoDragDrop(asdf, DragDropEffects.Copy); // drag drop baþlangýcý
            }

            //else if (tasima)
            //{
            //    if (castedbutton.X == Oldx && castedbutton.Y == Oldy)
            //    {
            //        tasima = false;
            //    }

            //    else
            //    {
            //        if ((!TurnOfBlack && Holded.ÝsBlack) || (TurnOfBlack && !Holded.ÝsBlack)) // oyun sýrasý siyahta ama oynanan tas beyazsa ve tersi durum için hata fýrlatma kýsmý
            //        {
            //            MessageBox.Show("Oynama Sýrasý Karþý Tarafýn ..");
            //            tasima = false;
            //        }
            //        else
            //        {
            //            Holded.Move(castedbutton.X, castedbutton.Y);
            //            tasima = false;

            //        }

            //    }

            //}
        }