Example #1
0
        //Voir si ça va écraser un bateau
        private bool CheckIfStomping(Ships ship, ShipOrientation orientation, int rowStart, int colStart)
        {
            bool Stomping = false;

            if (orientation == ShipOrientation.Vertical)
            {
                for (int i = rowStart; i < rowStart + ship.GetLength() && !Stomping; i++)
                {
                    string val = DGV_Demo.Rows[i].Cells[colStart].Value.ToString();
                    if (val != "" && val != ship.GetCode())
                    {
                        Stomping = true;
                    }
                }
            }
            else if (orientation == ShipOrientation.Horizontal)
            {
                for (int i = colStart; i < colStart + ship.GetLength() && !Stomping; i++)
                {
                    string val = DGV_Demo.Rows[rowStart].Cells[i].Value.ToString();
                    if (val != "" && val != ship.GetCode())
                    {
                        Stomping = true;
                    }
                }
            }
            return(Stomping);
        }
Example #2
0
        //Vider le board d'un bateau en particulier
        private void ClearSeaFromShip(Ships ship)
        {
            string c = ship.GetCode();

            for (int i = 0; i < DGV_Demo.Rows.Count; i++)
            {
                for (int j = 0; j < DGV_Demo.ColumnCount; j++)
                {
                    if (DGV_Demo.Rows[i].Cells[j].Value.ToString() == c)
                    {
                        DGV_Demo.Rows[i].Cells[j].Value = "";
                    }
                }
            }
        }
Example #3
0
        //Placer un bateau selon les données entrées
        private void PlaceShip(Ships ship, ShipOrientation orientation, int rowStart, int colStart)
        {
            ClearSeaFromShip(ship);

            if (orientation == ShipOrientation.Vertical)
            {
                for (int i = rowStart; i < rowStart + ship.GetLength(); i++)
                {
                    DGV_Demo.Rows[i].Cells[colStart].Value = ship.GetCode();
                }
            }
            else if (orientation == ShipOrientation.Horizontal)
            {
                for (int i = colStart; i < colStart + ship.GetLength(); i++)
                {
                    DGV_Demo.Rows[rowStart].Cells[i].Value = ship.GetCode();
                }
            }
        }
Example #4
0
        //Placer un bateau selon les données entrées
        private void PlaceShip(Ships ship, ShipOrientation orientation, int rowStart, int colStart)
        {
            ClearSeaFromShip(ship);

            if (orientation == ShipOrientation.Vertical)
            {
                for (int i = rowStart; i < rowStart + ship.GetLength(); i++)
                {
                    DGV_Demo.Rows[i].Cells[colStart].Value = ship.GetCode();
                }
            }
            else if (orientation == ShipOrientation.Horizontal)
            {
                for (int i = colStart; i < colStart + ship.GetLength(); i++)
                {
                    DGV_Demo.Rows[rowStart].Cells[i].Value = ship.GetCode();
                }
            }
        }
Example #5
0
 //Vider le board d'un bateau en particulier
 private void ClearSeaFromShip(Ships ship)
 {
     string c = ship.GetCode();
     for(int i = 0; i < DGV_Demo.Rows.Count; i++)
     {
         for(int j = 0; j < DGV_Demo.ColumnCount; j++)
         {
             if(DGV_Demo.Rows[i].Cells[j].Value.ToString() == c)
             {
                 DGV_Demo.Rows[i].Cells[j].Value = "";
             }
         }
     }
 }
Example #6
0
        //Voir si ça va écraser un bateau
        private bool CheckIfStomping(Ships ship, ShipOrientation orientation, int rowStart, int colStart)
        {
            bool Stomping = false;

            if (orientation == ShipOrientation.Vertical)
            {
                for (int i = rowStart; i < rowStart + ship.GetLength() && !Stomping; i++)
                {
                    string val = DGV_Demo.Rows[i].Cells[colStart].Value.ToString();
                    if (val != "" &&  val != ship.GetCode())
                    {
                        Stomping = true;
                    }
                }
            }
            else if (orientation == ShipOrientation.Horizontal)
            {
                for (int i = colStart; i < colStart + ship.GetLength() && !Stomping; i++)
                {
                    string val = DGV_Demo.Rows[rowStart].Cells[i].Value.ToString();
                    if (val != "" && val != ship.GetCode())
                    {
                        Stomping = true;
                    }
                }
            }
            return Stomping;
        }