public void GenerateField(int horzCellsCount, int vertCellsCount) { if (horzCellsCount > 0 && vertCellsCount > 0) { int vertOffset, horzOffset = 0; for (int i = 0; i < horzCellsCount; i++) { vertOffset = 0; for (int j = 0; j < vertCellsCount; j++) { var newCell = new GameFieldCell() { Width = _rectSize, Height = _rectSize }; newCell.PreviewMouseRightButtonUp += OnCellSelected; GameFieldCells.Add(newCell); Children.Add(newCell); SetTop(newCell, vertOffset); SetLeft(newCell, horzOffset); vertOffset += _rectSize; } horzOffset += _rectSize; } } }
public UnitStack(UnitType unitType, int numberOfUnits, GameFieldCell cell) { UnitType = unitType; Units = new Stack <Unit>(numberOfUnits); for (int i = 0; i < numberOfUnits; i++) { Units.Push(SimpleUnitFactory.CreateUnit(unitType)); } UnitsCapacity = numberOfUnits; Cell = cell; }
public void SelectCell(GameFieldCell selCell) { Dispatcher.Invoke(() => { foreach (var c in Children) { var cell = c as GameFieldCell; cell.IsSelected = false; } selCell.IsSelected = true; SelectedCell = selCell; }); }
public void SelectCellToAction(GameFieldCell cellToAttack) { Dispatcher.Invoke(() => { foreach (var c in Children) { var cell = c as GameFieldCell; if (cell != SelectedCell) { cell.IsSelected = false; } } }); cellToAttack.IsSelected = true; CellToAttack = cellToAttack; }