Esempio n. 1
0
        public static List<FlingMove> SearchMoves(CellCollection cells)
        {
            List<FlingMove> _result = new List<FlingMove>();

            foreach (Cell item in cells)
            {
                if (!item.IsEmpty)
                {
                    foreach (Directions dir in DirectionManager.AllDirections)
                    {
                        if (DirectionManager.IsCrosswise(dir))
                            continue;

                        Cell _startBall = item;
                        Cell _hitBall = item;
                        FlingMove _parentMove = null;
                        FlingMove _activeMove = null;
                        int _moveCount = 0;

                        while (cells.RoverCell(ref _hitBall, dir))
                        {
                            _moveCount++;
                            if (!_hitBall.IsEmpty)
                            {
                                if (_parentMove != null ||
                                    _moveCount > 1)
                                {
                                    FlingMove _move = new FlingMove()
                                    {
                                        StartBall = _startBall,
                                        Dir = dir,
                                        MoveCount = _moveCount,
                                        HitBall = _hitBall,
                                    };

                                    if (_parentMove == null)
                                    {
                                        _parentMove = _activeMove = _move;
                                        _result.Add(_parentMove);
                                    }
                                    else
                                    {
                                        _activeMove.RelatedMove = _activeMove = _move;
                                    }
                                    _moveCount = 0;
                                    _startBall = _hitBall;
                                }
                                else
                                    break;
                            }
                        }
                    }
                }
            }

            return _result;
        }
Esempio n. 2
0
        public CellCollection(CellCollection collection)
        {
            this.m_xCount = collection.m_xCount;
            this.m_yCount = collection.m_yCount;
            this.m_items = new Cell[m_xCount, m_yCount];

            for (int x = 0; x < this.m_xCount; x++)
                for (int y = 0; y < this.m_yCount; y++)
                    this.m_items[x, y] = new Cell(collection[x, y]);
        }
Esempio n. 3
0
        public bool Contains(CellCollection cells, Cell cell)
        {
            Cell _rover = this.StartBall;

            while (_rover != this.HitBall)
            {
                if (_rover == cell)
                    return true;

                cells.RoverCell(ref _rover, this.Dir);
            }

            return false;
        }
Esempio n. 4
0
        protected void InitializeBoard(int xCount, int yCount)
        {
            this.m_xCount = xCount;
            this.m_yCount = yCount;

            this.m_cells = new CellCollection(xCount, yCount);
            this.m_selectedCell = null;
            this.m_lastPlayedCell = null;

            this.m_pic.Size = new Size(this.m_xCount * this.m_oneSize + 1, this.m_yCount * this.m_oneSize + 1);
            this.m_pic.Location = new Point(-1, -1);
            this.m_pic.Parent.Size = new Size(this.m_pic.Width + 2, this.m_pic.Height + 2);
            this.m_pic.CreateGraphics();
            this.m_pic.Visible = true;

            this.RefreshBoard();
        }