示例#1
0
 public void SetShipOnField(Ship ship, bool isVertical, GameFieldElement gameField, StatedButton.State state)
 {
     if (ship != null)
     {
         int index = 0;
         foreach (StatedButton btn in buttons)
         {
             btn.ButtonState        = state;
             btn.LinkedShip         = ship;
             ship.Position[index++] = btn;
         }
         ship.IsVertical = isVertical;
         ChangeNearState(ship, gameField.PlayerField, false);
         buttons.Clear();
     }
 }
示例#2
0
        public void SetRandomShips(GameFieldElement gameField, StatedButton.State state)
        {
            Ship  thisShip;
            bool  isVertical;
            Point point;

            for (int j = 3; j >= 0; j--)
            {
                for (int i = 0; i < 4 - j; i++)
                {
                    isVertical = rnd.Next(0, 2) == 1;
                    thisShip   = shipToSet.GetShip(j + 1);
                    point      = new Point(rnd.Next(0, 10), rnd.Next(0, 10));
                    while (SetShipState(isVertical, j + 1, point, gameField.PlayerField))
                    {
                        point = new Point(rnd.Next(0, 10), rnd.Next(0, 10));
                    }
                    SetShipOnField(thisShip, isVertical, gameField, state);
                }
            }
        }
示例#3
0
 public StatedButtonControl(GameFieldElement field)
 {
     InitializeComponent();
     ThisField = field;
 }
示例#4
0
        public void SetShipOnField(GameFieldElement gameField)
        {
            Ship ship = shipToSet.GetShip(buttons.Count);

            SetShipOnField(ship, isVertical, gameField, StatedButton.State.Ship);
        }