コード例 #1
0
 private IReadOnlyList <ICellInternal> CreateCells()
 {
     return(Enumerable.Range(1, Size)
            .SelectMany(row => Enumerable.Range(1, Size).Select(col => _cellFactory.CreateCell(row, col)))
            .Cast <ICellInternal>()
            .ToList());
 }
コード例 #2
0
        public virtual void Fill()
        {
            if (!SettingsHelper.CheckValidity(Height, Width, MinesCount, out string reason))
            {
                throw new Exception(reason);
            }

            FlagsCount         = 0;
            notMinedCellsCount = Height * Width - MinesCount;
            openedCellsCount   = 0;

            Cells = new List <List <ICell> >(Height);
            for (int y = 0; y < Height; ++y)
            {
                List <ICell> row = new List <ICell>(Width);
                for (int x = 0; x < Width; ++x)
                {
                    ICell cell = cellFactory.CreateCell(this, x, y);
                    cell.OnStateChanged += Cell_OnStateChanged;
                    row.Add(cell);
                }
                Cells.Add(row);
            }

            MineAField();

            OnFilled?.Invoke(this, EventArgs.Empty);
            State = FieldState.NotStarted;
        }
コード例 #3
0
        public IPlantCell CreateCell(PlantCellType type, Vector3 center, float radius, float height)
        {
            var geometry = CreateCellGeometry(center, radius, height);

            var vacuole = new Vacuole();

            var wall = new CellWall();

            return(cellFactory.CreateCell(type, geometry, vacuole, wall));
        }
コード例 #4
0
        private IPlantCell CreateCell(Vector3 center, Vector3 direction)
        {
            var geometry = CreateCellGeometry(center, direction);

            var vacuole = new Vacuole();

            var cellWall = new CellWall();

            return(cellCreator.CreateCell(PlantCellType.Parenchyma, geometry, vacuole, cellWall));
        }
コード例 #5
0
        private IEnumerable <IPlantCell> CreateNodeCells(IPlantPartDescriptor descriptor)
        {
            var top     = descriptor.Top;
            var bottom  = new Vector3(top.X, top.Y, top.Z);
            var polygon = new Vector2[0];
            var face    = new Face(polygon);
            var geo     = new CellGeometry(top, bottom, face);
            var cell    = cellFactory.CreateCell(PlantCellType.Parenchyma, geo, new Vacuole(), new CellWall());

            return(new [] { cell });
        }
コード例 #6
0
 private IPlantCell CreatePlantCell(PlantCellType type, ICellGeometry geometry, IVacuole vacuole,
                                    ICellWall cellWall)
 {
     return(cellFactory.CreateCell(type, geometry, vacuole, cellWall));
 }