Esempio n. 1
0
        private void SetCellValue(int rowIndex, int columnIndex, SpreadsheetCell <T> sourceCell)
        {
            var cell = Cells[rowIndex * ColumnsCount + columnIndex];

            cell.ColumnIndex = sourceCell.ColumnIndex;
            cell.CellValue   = sourceCell.CellValue.GetCopy();
            cell.RowIndex    = sourceCell.RowIndex;
        }
        private void SetCellInactive(int rowIndex, int columnIndex)
        {
            SpreadsheetCell <SpaceFinderSpreadSheetCellValue> temp = GetCell(rowIndex, columnIndex);

            var tempCellValue = temp.CellValue;

            if (tempCellValue.IsActive)
            {
                tempCellValue.IsActive = false;
                ActiveCellsCount--;
            }
        }
        /*public List<SpreadsheetCell<SpaceFinderSpreadSheetCellValue>> GetCellsOfRadiusFromCell(
         *  SpreadsheetCell<SpaceFinderSpreadSheetCellValue> cell, float radius, float cellSize)
         * {
         *  int indexOffset = Mathf.CeilToInt(radius / cellSize);
         *  int rowStart = cell.RowIndex - indexOffset;
         *
         *  if (rowStart < 0)
         *  {
         *      rowStart = 0;
         *  }
         *
         *  int columnStart = cell.ColumnIndex - indexOffset;
         *
         *  if (columnStart < 0)
         *  {
         *      columnStart = 0;
         *  }
         *
         *  int rowEnd = cell.RowIndex + indexOffset;
         *
         *  if (rowEnd > RowsCount - 1)
         *  {
         *      rowEnd = RowsCount - 1;
         *  }
         *
         *  int columnEnd = cell.ColumnIndex + indexOffset;
         *
         *  if (columnEnd > ColumnsCount - 1)
         *  {
         *      columnEnd = ColumnsCount - 1;
         *  }
         *
         *  int count = (rowEnd - rowStart + 1) * (columnEnd - columnStart + 1);
         *
         *  List<SpreadsheetCell<SpaceFinderSpreadSheetCellValue>>
         *      cells = new List<SpreadsheetCell<SpaceFinderSpreadSheetCellValue>>(count);
         *  float extendedRadius = radius + cellSize / 2;
         *  float sqrExtendedRadius = extendedRadius * extendedRadius;
         *
         *  for (int i = rowStart; i <= rowEnd; i++)
         *  {
         *      for (int j = columnStart; j <= columnEnd; j++)
         *      {
         *          var checkingCell = GetCell(i, j);
         *
         *          if ((((SpaceFinderSpreadSheetCellValue) cell.CellValue).Position -
         *               ((SpaceFinderSpreadSheetCellValue) checkingCell.CellValue).Position).sqrMagnitude <
         *              sqrExtendedRadius)
         *          {
         *              cells.Add(checkingCell);
         *          }
         *      }
         *  }
         *
         *  return cells;
         * }*/

        public void SetCellsInactiveInRect(SpreadsheetCell <SpaceFinderSpreadSheetCellValue> cell, Vector2 size)
        {
            int indexXOffset = Mathf.CeilToInt(size.x / 2 / _cellSize);
            int indexYOffset = Mathf.CeilToInt(size.y / 2 / _cellSize);
            int rowStart     = cell.RowIndex - indexYOffset;

            if (rowStart < 0)
            {
                rowStart = 0;
            }

            int columnStart = cell.ColumnIndex - indexXOffset;

            if (columnStart < 0)
            {
                columnStart = 0;
            }

            int rowEnd = cell.RowIndex + indexYOffset;

            if (rowEnd > RowsCount - 1)
            {
                rowEnd = RowsCount - 1;
            }

            int columnEnd = cell.ColumnIndex + indexXOffset;

            if (columnEnd > ColumnsCount - 1)
            {
                columnEnd = ColumnsCount - 1;
            }

            var cellPos = cell.CellValue.Position;

            float minXPos = cellPos.x - size.x / 2;
            float maxXPos = cellPos.x + size.x / 2;
            float minYPos = cellPos.y - size.y / 2;
            float maxYPos = cellPos.y + size.y / 2;

            for (int i = rowStart; i <= rowEnd; i++)
            {
                for (int j = columnStart; j <= columnEnd; j++)
                {
                    var checkingCell = GetCell(i, j);
                    var pos          = checkingCell.CellValue.Position;

                    if (pos.x >= minXPos && pos.x <= maxXPos && pos.y <= maxYPos && pos.y >= minYPos)
                    {
                        SetCellInactive(checkingCell);
                    }
                }
            }
        }
 public void SetCellInactive(SpreadsheetCell <SpaceFinderSpreadSheetCellValue> cell)
 {
     SetCellInactive(cell.RowIndex, cell.ColumnIndex);
 }
Esempio n. 5
0
 protected void SetCellReference(int rowIndex, int columnIndex, SpreadsheetCell <T> cell)
 {
     Cells[rowIndex * ColumnsCount + columnIndex] = cell;
 }