Beispiel #1
0
        static public void CreateTas(ChessButton button, TasTipi tipi, bool renk) // Tahta Üzerinde Combobox dan seçilen taşı Oluşturur  !!
        {
            TasTipi tip = tipi;                                                   //(TasTipi)cmb_tastipi.SelectedItem


            switch (tip)
            {
            case TasTipi.Kale:
                Kale Kale = new Kale(renk)
                {
                    TasKordinat = new Kordinat {
                        X = Convert.ToInt32(button.X), Y = Convert.ToInt32(button.Y)
                    }
                };
                button.Tas    = Kale;
                button.Dolumu = true;
                MevcutTaslar.Add(Kale);
                break;

            case TasTipi.Sah:
                Sah sah = new Sah(renk)
                {
                    TasKordinat = new Kordinat {
                        X = Convert.ToInt32(button.X), Y = Convert.ToInt32(button.Y)
                    }
                };
                button.Tas = sah;
                MevcutTaslar.Add(sah);
                button.Dolumu = true;
                break;

            case TasTipi.Piyon:
                Piyon piyon = new Piyon(renk)
                {
                    TasKordinat = new Kordinat {
                        X = Convert.ToInt32(button.X), Y = Convert.ToInt32(button.Y)
                    }
                };
                button.Tas = piyon;
                MevcutTaslar.Add(piyon);
                button.Dolumu = true;
                break;

            case TasTipi.Fil:
                Fil fil = new Fil(renk)
                {
                    TasKordinat = new Kordinat {
                        X = Convert.ToInt32(button.X), Y = Convert.ToInt32(button.Y)
                    }
                };
                button.Tas = fil;
                MevcutTaslar.Add(fil);
                button.Dolumu = true;
                break;

            case TasTipi.At:
                At at = new At(renk)
                {
                    TasKordinat = new Kordinat {
                        X = Convert.ToInt32(button.X), Y = Convert.ToInt32(button.Y)
                    }
                };
                button.Tas = at;
                MevcutTaslar.Add(at);
                button.Dolumu = true;
                break;

            case TasTipi.Vezir:
                Vezir vezir = new Vezir(renk)
                {
                    TasKordinat = new Kordinat {
                        X = Convert.ToInt32(button.X), Y = Convert.ToInt32(button.Y)
                    }
                };
                button.Tas = vezir;
                MevcutTaslar.Add(vezir);
                button.Dolumu = true;
                break;
            }



            button.GetBackgroundİmage();
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            switch (TasTipi)
            {
            case TasTipi.Kale:
                asd.ChessBoard.MevcutTaslar.Remove(asd);
                Kale kale = new Kale(isblack)
                {
                    TasKordinat = new Kordinat {
                        X = this.X, Y = this.Y
                    }
                };
                asd.ChessBoard.MevcutTaslar.Add(kale);
                asd.ChessBoard.Squares[Y, X].Dolumu = true;
                asd.ChessBoard.Squares[Y, X].Tas    = kale;
                asd.ChessBoard.Squares[Y, X].GetBackgroundİmage();
                kale.Move(X, Y);
                break;

            case TasTipi.Fil:
                asd.ChessBoard.MevcutTaslar.Remove(asd);
                Fil fil = new Fil(isblack)
                {
                    TasKordinat = new Kordinat {
                        X = this.X, Y = this.Y
                    }
                };
                asd.ChessBoard.MevcutTaslar.Add(fil);
                asd.ChessBoard.Squares[Y, X].Dolumu = true;
                asd.ChessBoard.Squares[Y, X].Tas    = fil;
                asd.ChessBoard.Squares[Y, X].GetBackgroundİmage();
                fil.Move(X, Y);

                break;

            case TasTipi.At:
                asd.ChessBoard.MevcutTaslar.Remove(asd);
                At at = new At(isblack)
                {
                    TasKordinat = new Kordinat {
                        X = this.X, Y = this.Y
                    }
                };
                asd.ChessBoard.Squares[Y, X].Dolumu = true;
                asd.ChessBoard.Squares[Y, X].Tas    = at;
                asd.ChessBoard.Squares[Y, X].GetBackgroundİmage();
                at.Move(X, Y);
                //at.MakeCangoList();
                break;

            case TasTipi.Vezir:
                asd.ChessBoard.MevcutTaslar.Remove(asd);
                Vezir vezir = new Vezir(isblack)
                {
                    TasKordinat = new Kordinat {
                        X = this.X, Y = this.Y
                    }
                };
                asd.ChessBoard.MevcutTaslar.Add(vezir);
                asd.ChessBoard.Squares[Y, X].Dolumu = true;
                asd.ChessBoard.Squares[Y, X].Tas    = vezir;
                asd.ChessBoard.Squares[Y, X].GetBackgroundİmage();
                vezir.Move(X, Y);
                break;
            }
            this.Hide();
        }