Exemple #1
0
        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;
                }
            }
        }
Exemple #2
0
        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;
        }
Exemple #3
0
        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;
            });
        }
Exemple #4
0
        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;
        }