示例#1
0
        public void OpenCell(Сell field)
        {
            if (Status == GameStatus.Play)
            {
                if (field.Status == CellStatus.Mark)
                {
                    Marks.AddClick(field);
                }
                else if (!Mines.IsPresent(field))
                {
                    AddVisibleСell(field);

                    if (VisibleСells.IsCompleted(Size, CountMines))
                    {
                        Status = GameStatus.Victory;
                        VisibleMarkMine();
                        VisibleСells.Add(Mines);
                    }
                }
                else
                {
                    Status = GameStatus.GameOver;
                    VisibleСells.Add(new CellExplosion(field));
                    VisibleMarkMine();
                    VisibleСells.Add(Mines);
                }
            }
        }
示例#2
0
        private void VisibleMarkMine()
        {
            var markMineList = new ListСell();

            foreach (Сell fieldIntersection in ListСell.Intersection(Marks, Mines))
            {
                markMineList.Add(new CellMine(fieldIntersection, true));
            }

            VisibleСells.Add(markMineList);
        }
示例#3
0
        private void AddVisibleСell(Сell field)
        {
            var countMine = CountMineAroundCell(field);

            if (countMine == 0)
            {
                VisibleСells.Add(new Сell(field.Row, field.Column));

                var aroundCells = VisibleСells.GetAroundCellsNoTags(field, Size);
                foreach (Сell acell in aroundCells)
                {
                    AddVisibleСell(acell);
                }
            }
            else
            {
                VisibleСells.Add(new CellValue(field, countMine));
            }
        }