private void ColourShip(GridEntry[,] buttons, ShipInstance inst) { Position pos = inst.pos; for (int i = 0; i < shipTypes[inst.shipId].length; i++) { buttons[pos.x, pos.y].Ship = inst; //on the client side, the mathy helpers no-longer exist in Position :( if (inst.rotation == BShipService.Rotation.RIGHT) { pos.x++; } else { pos.y++; } } }
private GridEntry[,] buttoniseGrid(Grid grid, RoutedEventHandler handler) { GridEntry[,] buttons = new GridEntry[10, 10]; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { GridEntry button = new GridEntry(x, y); button.Click += handler; Grid.SetColumn(button, x+1); Grid.SetRow(button, y+1); grid.Children.Add(button); buttons[x, y] = button; } } return buttons; }
private void buttonState(GridEntry[,] grid, bool state) { state = true; //temporary foreach (GridEntry entry in grid) { entry.IsEnabled = state; } }