当前位置: 首页>>代码示例>>C#>>正文


C# CellType.GetLength方法代码示例

本文整理汇总了C#中CellType.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# CellType.GetLength方法的具体用法?C# CellType.GetLength怎么用?C# CellType.GetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CellType的用法示例。


在下文中一共展示了CellType.GetLength方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Calculate

        public IEnumerable<CellCost> Calculate(CellType[,] grid, int horizontalPosition, int verticalPosition)
        {
            var output = new List<CellCost>();

            if (horizontalPosition > 0)
            {
                var left = horizontalPosition - 1;
                var leftCell = grid[verticalPosition, left];
                output.Add( new CellCost(verticalPosition, left, GetCost(leftCell)));
            }

            if (horizontalPosition < grid.GetLength(1) - 1)
            {
                var right = horizontalPosition + 1;
                var leftCell = grid[verticalPosition, right];
                output.Add( new CellCost(verticalPosition, right, GetCost(leftCell)));
            }

            if (verticalPosition > 0)
            {
                var down = verticalPosition - 1;
                var leftCell = grid[down, horizontalPosition];
                output.Add( new CellCost(down, horizontalPosition, GetCost(leftCell)));
            }

            if (verticalPosition < grid.GetLength(0) - 1)
            {
                var up = verticalPosition + 1;
                var leftCell = grid[up, horizontalPosition];
                output.Add( new CellCost(up, horizontalPosition, GetCost(leftCell)));
            }

            return output;
        }
开发者ID:osw,项目名称:SC2012.Maze,代码行数:34,代码来源:CostCalculator.cs

示例2: CMap

        //internal CMap(MapRepresent_ProD representMap)
        //{
        //    colCount = representMap.ColCount;
        //    rowCount = representMap.RowCount;
        //    mx = new CCell[colCount, rowCount];
        //    for (int i = 0; i < colCount; i++)
        //        for (int j = 0; j < rowCount; j++)
        //        {
        //            var cell = new CCell(i, j, representMap[i, j]);
        //            mx[i, j] = cell;
        //            if (cell.IsWall) wall.Add(cell);
        //            else
        //                switch (cell.Type)
        //                {
        //                    case CellType.Entrance:
        //                        entranceCell = cell;
        //                        break;
        //                    case CellType.Exit:
        //                        exitCell = cell;
        //                        break;
        //                    case CellType.Door:
        //                        doorCells.Add(cell);
        //                        break;
        //                }
        //        }
        //}
        internal CMap(CellType[,] cellMatrix)
        {
            colCount = cellMatrix.GetLength(0);
            rowCount = cellMatrix.GetLength(1);
            mx = new CCell[colCount, rowCount];

            for (int i = 0; i < colCount; i++)
                for (int j = 0; j < rowCount; j++)
                {
                    var cell = new CCell(i, j, cellMatrix[i, j]);

                    mx[i, j] = cell;
                    if (cell.IsWall) wall.Add(cell);
                    else
                        switch (cell.Type)
                        {
                            case CellType.Entrance:
                                entranceCell = cell;
                                break;
                            case CellType.Exit:
                                exitCell = cell;
                                break;
                            case CellType.Door:
                                doorCells.Add(cell);
                                break;
                        }
                }
        }
开发者ID:RrrEeGina,项目名称:PackMan,代码行数:54,代码来源:CMap.cs

示例3: DrawField

        public void DrawField(GameField field, CellType[,] pt, bool isYours)
        {
            lock (lck)
            {
                Bitmap newBitmap = isYours ? TempBitmapYours : TempBitmapEnemy;

                Graphics g = Graphics.FromImage(newBitmap);
                using (g)
                {
                    g.Clear(Color.White);
                    g.DrawImage(grid, 0, 0);

                    for (int i = 0; i < pt.GetLength(0); i++)
                    {
                        for (int j = 0; j < pt.GetLength(1); j++)
                        {
                            if (pt[i, j] == CellType.Point)
                                g.FillEllipse(Brushes.Green, i * StructMap.BlockSize + 10, j * StructMap.BlockSize + 10, 10, 10);
                        }
                    }

                    for (int i = 0; i < field.ships.Count; i++)
                    {
                        for (int j = 0; j < field.ships[i].palub.Count; j++)
                        {
                            if (field.ships[i].palub[j].type == DeckType.Live)
                            {
                                g.FillRectangle(Brushes.Red, field.ships[i].palub[j].point.X * StructMap.BlockSize + 1, field.ships[i].palub[j].point.Y * StructMap.BlockSize + 1, StructMap.BlockSize - 1, StructMap.BlockSize - 1);
                            }
                            else if (field.ships[i].palub[j].type == DeckType.Hurt)
                            {
                                g.FillRectangle(Brushes.Orange, field.ships[i].palub[j].point.X * StructMap.BlockSize + 1, field.ships[i].palub[j].point.Y * StructMap.BlockSize + 1, StructMap.BlockSize - 1, StructMap.BlockSize - 1);
                            }
                            else if (field.ships[i].palub[j].type == DeckType.Dead)
                            {
                                g.FillRectangle(Brushes.Black, field.ships[i].palub[j].point.X * StructMap.BlockSize + 1, field.ships[i].palub[j].point.Y * StructMap.BlockSize + 1, StructMap.BlockSize - 1, StructMap.BlockSize - 1);
                            }
                        }
                    }

                }

                Graphics tmp = isYours ? Graphics.FromImage(MainBitmapYours) : Graphics.FromImage(MainBitmapEnemy);

                using (tmp)
                {
                    tmp.Clear(Color.White);
                    tmp.DrawImage(newBitmap, 0, 0);
                }

            }
        }
开发者ID:Boykooo,项目名称:Boom,代码行数:52,代码来源:Paint.cs

示例4: Init

 public void Init(CellType[,] cells)
 {
     _undoStack.Clear();
     NotifyPropertyChanged("Moves");
     _width = cells == null ? 0 : cells.GetLength(0);
     NotifyPropertyChanged("Width");
     _height = cells == null ? 0 : cells.GetLength(1);
     NotifyPropertyChanged("Height");
     if (cells == null)
     {
         _cells = null;
     }
     else
     {
         _cells = new ObservableCollection<CellType>();
         for (int y = 0; y < _height; y++)
         {
             for (int x = 0; x < _width; x++)
             {
                 _cells.Add(cells[x, y]);
             }
         }
     }
     NotifyPropertyChanged("Cells");
 }
开发者ID:bdachev,项目名称:Sokoban,代码行数:25,代码来源:SokobanLogic.cs

示例5: BuildMapByFerr2D

        private void BuildMapByFerr2D(CellType[,] cells)
        {
            var mx = new ProdToFerra2D.CellType[cells.GetLength(0), cells.GetLength(1)];
            for (int i = 0; i < mx.GetLength(0); i++)
                for (int j = 0; j < mx.GetLength(1); j++)
                    mx[i, j] = Interpret(cells[i, j]);

            CMap map = new CMap(mx);
            map.RunAnalyze();

            FerrTerrainBuilder builder = new FerrTerrainBuilder(map.FinalPolygons.ConvertAll((p) => new Polygon2D(p.mainPoints, p.lines)),
                ferraPrototype.GetComponent<Ferr2D_Path>(), GameConst.UNITS_PER_CELL, GameConst.UNITS_PER_CELL);
            builder.Build();
        }
开发者ID:RrrEeGina,项目名称:PackMan,代码行数:14,代码来源:MapBuilder.cs

示例6: SetCells

        private void SetCells(IntVector2 origin, CellType[,] cells)
        {
            for (int x = 0; x < cells.GetLength(0); x++) {
                for (int z = 0; z < cells.GetLength(1); z++) {
                    var spacePosition = new IntVector2(origin.x + x, origin.z + z);

                    if (spacePosition.x >= 0 && spacePosition.x < AreaSize &&
                        spacePosition.z >= 0 && spacePosition.z < AreaSize) {

                        this.cells[spacePosition.x, spacePosition.z] = cells[x, z];
                    }
                }
            }
        }
开发者ID:PhilippCh,项目名称:SpaceStationSimulator,代码行数:14,代码来源:RoomBuilderUI.cs


注:本文中的CellType.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。