Ejemplo n.º 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);
        }
Ejemplo n.º 2
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();
                }
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 4
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;
        }