Exemplo n.º 1
0
        public void StartGame()
        {
            Score = 0;
            UpdateScore();
            var generatedCells = GenerateCells();

            FillCells(generatedCells);
            _switchedCellPair = null;

            _cameraController.FitCameraSize(Rows, Columns);
        }
Exemplo n.º 2
0
 public CellPair[] GetCellPairs()
 {
     CellPair[] matrix = new CellPair[Size * Size];
     ForEachCell((i, j, cell1) => {
         ForEachCell((x, y, cell2) => {
             int idx     = cell1.ID * Size + cell2.ID;
             matrix[idx] = new CellPair()
             {
                 PickupCell  = cell1,
                 DropoffCell = cell2,
             };
         });
     });
     return(matrix);
 }
Exemplo n.º 3
0
        private void OnSwitchEnd(CellPair switchedCells)
        {
            var matchedCells = _cellManager.CheckCellsOnMatch(switchedCells.FirstCell, switchedCells.SecondCell);

            if (matchedCells.Length == 0)
            {
                switchedCells.Switch();
            }
            else
            {
                CollectMatchedCells(matchedCells);
            }

            switchedCells.OnSwitchEnd -= OnSwitchEnd;
            _switchedCellPair          = null;
        }
Exemplo n.º 4
0
 public void SetFreezePanes(int row, int col)
 {
     if (_headWriter.CurrentSection > StreamsheetParser.StreamSheetSection.SheetViews)
     {
         throw new FatalException();
     }
     if (_stagedSheetView == null)
     {
         _stagedSheetView = new CT_SheetView();
     }
     _stagedSheetView.Pane                  = new CT_Pane();
     _stagedSheetView.Pane                  = new CT_Pane();
     _stagedSheetView.Pane.State_Attr       = ST_PaneState.frozen;
     _stagedSheetView.Pane.XSplit_Attr      = col;
     _stagedSheetView.Pane.YSplit_Attr      = row;
     _stagedSheetView.Pane.TopLeftCell_Attr = CellPair.Name(row, col);
 }
Exemplo n.º 5
0
 public ICellModel getCell(int col)
 {
     if (col >= 0 && col <= 16383)
     {
         ICellModel cellModel = default(ICellModel);
         if (this.CellsMap.TryGetValue(col, out cellModel))
         {
             return(cellModel);
         }
         CT_Cell cT_Cell = new CT_Cell();
         cT_Cell.R_Attr = CellPair.Name(this.RowNumber, col);
         cellModel      = new XMLCellModel(this._worksheetModel, this._manager, cT_Cell);
         this.CellsMap.Add(col, cellModel);
         return(cellModel);
     }
     throw new FatalException();
 }
Exemplo n.º 6
0
        public ICellModel getCell(int col)
        {
            if (col < 0 || col > 16383)
            {
                throw new FatalException();
            }
            if (CellsMap.TryGetValue(col, out ICellModel value))
            {
                return(value);
            }
            CT_Cell cT_Cell = new CT_Cell();

            cT_Cell.R_Attr = CellPair.Name(RowNumber, col);
            value          = new XMLCellModel(_worksheetModel, _manager, cT_Cell);
            CellsMap.Add(col, value);
            return(value);
        }
Exemplo n.º 7
0
    public static FreeShape createCorrShape(IXShape roomA, IXShape roomB, int corrWidth)
    {
        CellPair    pair     = roomA.shortestCellPair(roomB);
        List <Cell> line     = GetLine(pair.cell1, pair.cell2);
        FreeShape   corrAtoB = new FreeShape();

        foreach (Cell each in line)
        {
            List <Cell> vCells = DrawCircle(each, corrWidth);
            //To avoid cell overlapping between rooms with corridor
            foreach (Cell vEach in vCells)
            {
                if (!roomA.hasCellAbsValue(vEach, XTile.FLOOR) &&
                    !roomB.hasCellAbsValue(vEach, XTile.FLOOR))
                {
                    corrAtoB.add(vEach);
                }
            }
        }
        return(corrAtoB);
    }
Exemplo n.º 8
0
        private void SwitchCells(Cell firstCell, Cell secondCell)
        {
            if (_switchedCellPair != null)
            {
                return;
            }
            CellPair switchedCells = new CellPair(firstCell, secondCell);

            if (switchedCells.IsNeighbors == false)
            {
                return;
            }

            switchedCells.OnSwitchEnd += OnSwitchEnd;

            bool isSwitchPass = switchedCells.Switch();

            if (isSwitchPass)
            {
                _switchedCellPair = switchedCells;
            }
        }
Exemplo n.º 9
0
        public void MergeCells(int firstRow, int firstCol, int rowCount, int colCount)
        {
            AdvanceStreamsheetTo(StreamsheetParser.StreamSheetSection.MergeCells, head: false);
            CT_MergeCell cT_MergeCell = new CT_MergeCell();

            cT_MergeCell._ref_Attr = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", CellPair.Name(firstRow, firstCol), CellPair.Name(firstRow + rowCount - 1, firstCol + colCount - 1));
            _tailWriter.WriteMergedCell(cT_MergeCell);
        }