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


C# Square.GetLength方法代码示例

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


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

示例1: TargetPosition

        static int[,] TargetPosition(Square[,] levels)
        {
            List<int> coordRow = new List<int>();
            List<int> coordCol = new List<int>();
            for (int i = 0; i < levels.GetLength(0); i++)
            {
                for (int j = 0; j < levels.GetLength(1); j++)
                {
                    if (levels[i, j].state == SquareState.Rock)
                    {
                        coordRow.Add(i);
                        coordCol.Add(j);
                    }
                }
            }
            int[,] matrix = new int[2, coordRow.Count];

            for (int k = 0; k < matrix.GetLength(1); k++)
            {
                matrix[0, k] = coordCol[k];
                matrix[1, k] = coordRow[k];
            }
            return matrix;
        }
开发者ID:bankoff,项目名称:TelerikAcademy,代码行数:24,代码来源:Game.cs

示例2: PrintLevel

        //************************************
        //* Prints a level on the screen     *
        //* Gets the current board           *
        //* Returns nothing                  *
        //************************************
        static void PrintLevel(Square[,] arr)
        {
            Console.SetCursorPosition(0, 0);

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (arr[i, j].state == SquareState.Nothing)
                    {
                        PrintSquareType(arr[i, j].type, i * 3, j * 5);
                    }
                    else
                    {
                        PrintSquareState(arr[i, j].state, i * 3, j * 5);
                    }
                }
            }
        }
开发者ID:bankoff,项目名称:TelerikAcademy,代码行数:24,代码来源:Game.cs

示例3: LoadPenguinCoord

 //******************************************************
 //* Finds where on the board is located the player     *
 //* Gets the current board                             *
 //* Returns the coordinates in array                   *
 //******************************************************
 static int[] LoadPenguinCoord(Square[,] level)
 {
     int[] coord = new int[2];
     for (int i = 0; i < level.GetLength(0); i++)
     {
         for (int j = 0; j < level.GetLength(1); j++)
         {
             if (level[i, j].state == SquareState.Player)
             {
                 coord[0] = i;
                 coord[1] = j;
             }
         }
     }
     return coord;
 }
开发者ID:bankoff,项目名称:TelerikAcademy,代码行数:21,代码来源:Game.cs

示例4: CheckSolved

        //*****************************************************************
        //* Checks if the board is solved, i.e all targets have rocks     *
        //* Gets the current board                                        *
        //* Returns True if the board is solved and False otherwise       *
        //******************************************************************
        static bool CheckSolved(Square[,] levelToCheck)
        {
            bool solved = true;

            for (int i = 0; i < levelToCheck.GetLength(0); i++)
            {
                for (int j = 0; j < levelToCheck.GetLength(1); j++)
                {
                    if (levelToCheck[i, j].type == SquareType.Target)
                    {
                        if (levelToCheck[i, j].state != SquareState.Rock)
                        {
                            solved = false;
                            return solved;
                        }
                    }
                }
            }
            return solved;
        }
开发者ID:bankoff,项目名称:TelerikAcademy,代码行数:25,代码来源:Game.cs

示例5: InitGrid

        private void InitGrid()
        {
            _grid = new Square<GameObject>[GridSize, GridSize];

            for (int row = 0; row < _grid.GetLength(0); row++)
            {
                for (int col = 0; col < _grid.GetLength(1); col++)
                {
                    _grid[row, col] = new Square<GameObject>(row, col);
                }
            }
        }
开发者ID:charmisejani,项目名称:TelerikAcademy,代码行数:12,代码来源:GridManager.cs

示例6: SCheckRad

    /*
     * Checks radius for squares that aren't walls
     */
    public List<Square> SCheckRad(int rad, Vector2 origin)
    {
        Vector2 scoord = new Vector2(origin.x-rad, origin.y-rad);
        Vector2 ecoord = new Vector2(origin.x+rad, origin.y+rad);
        FixVector(ref scoord);
        FixVector(ref ecoord);
        int ex = (int)ecoord.x;
        int ey = (int)ecoord.y;
        int sx = (int)scoord.x;
        int sy = (int)scoord.y;
        Square[,] see = new Square[ex-sx+1, ey-sy+1];
        Square osquare = grid[(int)origin.x, (int)origin.y];

        for(int i = 0; i < see.GetLength(0); i++) {
            for(int j = 0; j < see.GetLength(1); j++) {
                if(i == rad && j == rad) {
                    see[i,j] = null;
                    continue;
                }
                if(sx+i <= ex) {
                    if(sy+j <= ey)
                        see[i,j] = grid[(int)scoord.x + i,(int)scoord.y + j];
                    else
                        see[i,j] = grid[(int)scoord.x + i,(int)scoord.y];
                }
                else if(sy + j <= ey)
                    see[i,j] = grid[(int)scoord.x,(int)scoord.y + j];

            }
        }

        List<Square> fsee = new List<Square>();

        for(int i = 0; i < see.GetLength(0); i++) {
            for(int j = 0; j < see.GetLength(1); j++) {
                if(see[i,j] != null){
                    RaycastHit[] hits = Physics.RaycastAll(osquare.wloc,
                                        (see[i,j].wloc - osquare.wloc).normalized,
                                        Vector3.Distance(osquare.wloc, see[i,j].wloc));
                if(Array.Find(hits,(RaycastHit hit) => {
                        return hit.transform.gameObject.GetComponent<Wall>() != null; })
                    .Equals(default(RaycastHit)))
                    fsee.Add(see[i, j]);
                }
            }
        }
        return fsee;
    }
开发者ID:oshoham,项目名称:RPFOD2,代码行数:51,代码来源:Grid.cs


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