Example #1
0
        private void navalBattlePanelPlayer1_OnSelectedCell(object sender, CellSelectedEventArgs e)
        {
            int         x          = e.Coordinates.X;
            int         y          = e.Coordinates.Y;
            Orientation?orientacao = null;

            try
            {
                orientacao = GetOrientation();
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }


            List <Point> coordinates = new List <Point>();

            for (int i = 0; i < _shipId; i++)
            {
                Point nextPosition;
                if (orientacao.Value == Orientation.Horizontal)
                {
                    nextPosition = new Point(x, y++);
                }
                else
                {
                    nextPosition = new Point(x++, y);
                }

                coordinates.Add(nextPosition);
            }

            try
            {
                Proxy.PutShip(_playerName, _shipId, coordinates.ToArray());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }



            this.navalBattlePanelPlayer1.PutShip(_shipId, e.Coordinates, orientacao.Value, _shipId);

            if (_shipId < 7)
            {
                _shipId++;
            }
            else
            {
                FinishPutShips();
            }
        }
Example #2
0
        void navalBattlePanel1_OnSelectedCell(object sender, CellSelectedEventArgs e)
        {
            /*if (((TextBox)navalBattlePanel1.GetChildAtPoint(e.Coordinates)).Text == "X")
             *  throw new ApplicationException("Você já atacou esta posição");*/

            if (OnSelectedCell != null)
            {
                OnSelectedCell(sender, new CellSelectedEventArgs()
                {
                    Coordinates = e.Coordinates
                });
            }
            this.Hide();
        }
Example #3
0
 void _attackDialog_OnSelectedCell(object sender, CellSelectedEventArgs e)
 {
     Proxy.Play(_playerName, e.Coordinates);
 }