Exemple #1
0
 private void CreateCells(int packIndex)
 {
     for (int i = 0; i < DefineData.MAX_CELL_COUNT; i++)
     {
         _squareCells[i] = new SquareCell(packIndex, i);
     }
 }
Exemple #2
0
        private SquareCell FindCellByCoordinates(int column, int row)
        {
            SquareCell cell = null;

            int packColumn = column / DefineData.MAX_COLUMN_COUNT;
            int packRow    = row / DefineData.MAX_ROW_COUNT;

            int packOrderIndex = (packRow * DefineData.MAX_ROW_COUNT) + packColumn;

            int cellColumn = column % DefineData.MAX_COLUMN_COUNT;
            int cellRow    = row % DefineData.MAX_ROW_COUNT;

            int cellOrderIndex = (cellRow * DefineData.MAX_ROW_COUNT) + cellColumn;


            cell = _squarePacks[packOrderIndex].SquareCells[cellOrderIndex];

            Debug.Log(string.Format("parameter : [{0}, {1}] - Cell Coordinate : [{2}, {3}]",
                                    column, row, cell.BoardCoorinate.column, cell.BoardCoorinate.row));

            return(cell);
        }
Exemple #3
0
        private void UpdateDuplicateNumberOfColumn(int boardColumn)
        {
            List <model.SquareCell> duplicateCells = new List <SquareCell>();
            bool isDuplicate      = false;
            int  targetPackColumn = boardColumn / DefineData.MAX_COLUMN_COUNT;
            int  targetCellRow    = boardColumn % DefineData.MAX_COLUMN_COUNT;

            model.SquarePack[] packs = this.GetColumnPacks(targetPackColumn);
            model.SquareCell[] cells = new model.SquareCell[DefineData.MAX_CELL_COUNT];
            model.SquareCell[,] tempCells = new SquareCell[3, 3];
            model.SquareCell[] packCells = null;

            for (int i = 0; i < packs.Length; i++)
            {
                packCells = packs[i].GetColumnCells(targetPackColumn);
                for (int j = 0; j < packCells.Length; j++)
                {
                    tempCells[i, j] = packCells[j];
                }
            }

            for (int i = 0; i < DefineData.MAX_CELL_COUNT; i++)
            {
                cells[i] = tempCells[i / 3, i % 3];
            }

            for (int i = 0; i < cells.Length; i++)
            {
                if (cells[i].NumberValue == 0)
                {
                    continue;
                }
                for (int j = i; j < cells.Length; j++)
                {
                    if (i == j) // 인덱스가 같은경우
                    {
                        continue;
                    }

                    if (cells[i].NumberValue == cells[j].NumberValue)
                    {
                        if (!duplicateCells.Contains(cells[i]))
                        {
                            duplicateCells.Add(cells[i]);
                        }

                        if (!duplicateCells.Contains(cells[j]))
                        {
                            duplicateCells.Add(cells[j]);
                        }
                    }
                }
            }

            for (int i = 0; i < cells.Length; i++)
            {
                isDuplicate = false;
                for (int j = 0; j < duplicateCells.Count; j++)
                {
                    if (cells[i] == duplicateCells[j])
                    {
                        isDuplicate = true;
                        break;
                    }
                }
                cells[i].UpdateDuplicateColumn(isDuplicate);
            }
        }
Exemple #4
0
 private void UpdateDuplicateInAim(SquareCell selectCell)
 {
     UpdateDuplicateNumberOfColumn(selectCell.BoardCoorinate.column);
     UpdateDuplicateNumberOfRow(selectCell.BoardCoorinate.row);
 }