示例#1
0
        //Initial board creation
        public Board(int x, int y, int r)
        {
            length = x;

            width = y;

            connectR = r;

            board = new Cell[length, width];

            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    Cell cell = new Cell(i, j);

                    if (i == length - 1)
                    {
                        cell.isPlayable(true);
                    }

                    board[i, j] = cell;
                }
            }
        }
示例#2
0
 //Copy Constructor
 public Cell(Cell cell)
 {
     rowPos = cell.rowPos;
     colPos = cell.colPos;
     playable = cell.isPlayable();
     state = cell.state;
     connectCells = new SortedDictionary<int, List<Cell>>();
     observers = new SortedDictionary<int, HashSet<Cell>>();
 }
示例#3
0
        public void AddObserver(int index, Cell cell)
        {
            if (observers.ContainsKey(index))
            {
                if(cell.state.Equals(CellState.empty))
                {
                    if(cell.isPlayable())
                    {
                        observers[index].Add(cell);
                        return;
                    }
                }

                if (this.state.Equals(CellState.empty))
                {
                    //this giving me problems - not evaluating correclty
                    //if(cell.isPlayable())
                    {
                        observers[index].Add(cell);
                        return;
                    }
                }

                if(cell.state.Equals(this.state))
                {
                    observers[index].Add(cell);
                    return;
                }

            }

            //Dictionary Doesn't contain key
            else
            {
                if (cell.state.Equals(CellState.empty))
                {
                    //this giving me problems - not evaluating correctly
                    if(cell.isPlayable())
                    {
                        HashSet<Cell> c = new HashSet<Cell>();
                        c.Add(cell);
                        observers.Add(index, c);
                        return;
                    }
                }

                if (this.state.Equals(CellState.empty))
                {
                    //this giving me problems - not evaluating correctly
                    //if (cell.isPlayable())
                    {
                        HashSet<Cell> c = new HashSet<Cell>();
                        c.Add(cell);
                        observers.Add(index, c);
                        return;
                    }
                }

                if (cell.state.Equals(this.state))
                {
                    HashSet<Cell> c = new HashSet<Cell>();
                    c.Add(cell);
                    observers.Add(index, c);
                    return;
                }
            }
        }