本文整理汇总了C#中Grid.GetCell方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.GetCell方法的具体用法?C# Grid.GetCell怎么用?C# Grid.GetCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid.GetCell方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyStyle
public void ApplyStyle(Grid grid, Range range)
{
for (int r = range.Start.Row; r <= range.End.Row; r++)
for (int c = range.Start.Column; c <= range.End.Column; c++)
ApplyStyle(grid.GetCell(r, c));
}
示例2: GetNeighbors
private static List<Cell> GetNeighbors(Grid grid,Cell cell)
{
List<Cell> neighbors = new List<Cell> ();
int x = (int)cell.position.x;
int y = (int)cell.position.y;
if (grid.GetCell (x - 1, y) != null) {
neighbors.Add(grid.GetCell(x - 1,y));
}
if (grid.GetCell (x + 1, y) != null) {
neighbors.Add(grid.GetCell(x + 1, y));
}
if (grid.GetCell (x, y - 1) != null) {
neighbors.Add(grid.GetCell (x, y - 1));
}
if (grid.GetCell (x, y + 1) != null) {
neighbors.Add(grid.GetCell (x, y + 1));
}
/*
// check voor diagonale cellen
if(grid.GetCell(x-1, y-1) != null) {
neighbors.Add(grid.GetCell(x-1, y-1));
}
if(grid.GetCell(x+1, y-1) != null) {
neighbors.Add(grid.GetCell(x+1, y-1));
}
if(grid.GetCell(x+1, y+1) != null) {
neighbors.Add(grid.GetCell(x+1, y+1));
}
if(grid.GetCell(x-1, y+1) != null) {
neighbors.Add(grid.GetCell(x-1, y+1));
}*/
return neighbors;
}
示例3: initializeNeighbors
public void initializeNeighbors(Grid grid)
{
down = grid.GetCell(location + Point.up);
up = grid.GetCell(location - Point.up);
right = grid.GetCell(location + Point.right);
left = grid.GetCell(location - Point.right);
if(down == null) isBottomEdge = true;
if(up == null) isTopEdge = true;
if(right == null) isRightEdge = true;
if(left == null) isLeftEdge = true;
}
示例4: Search
public static List<Cell> Search(Grid grid, Vector2 start, Vector2 end)
{
grid.Reset ();
List<Cell> openList = new List<Cell> ();
List<Cell> closedList = new List<Cell> ();
Cell currentCell;
Cell neighbor;
float gScore;
bool gScoreIsBest;
List<Cell> neighbors;
int maxJumpHeight = 8;
int maxDubbleJumpHeight = 2;
int currentMaxJumpHeight = maxJumpHeight;
currentCell = grid.GetCell ((int)start.x, (int)start.y);
if (currentCell.isWall) {
currentCell.isGround = true;
currentCell.isWall = false;
currentCell.tempGroundTile = true;
}
openList.Add (currentCell);
while (openList.Count > 0) {
openList.Sort(SortOnF);
currentCell = openList[0];
if(currentCell.position.Equals(end)){
List<Cell> path = new List<Cell>();
while(currentCell.parent != null){
path.Add(currentCell);
currentCell = currentCell.parent;
}
path.Reverse();
return path;
}
openList.Remove(currentCell);
closedList.Add(currentCell);
currentCell.isClosed = true;
currentCell.isOpen = false;
if(currentCell.neighbors == null){
currentCell.neighbors = GetNeighbors(grid,currentCell);
}
if(currentCell.j >= maxJumpHeight && currentMaxJumpHeight == maxJumpHeight){
currentMaxJumpHeight += maxDubbleJumpHeight;
}
neighbors = currentCell.neighbors;
int l = neighbors.Count;
for(int i = 0; i < l; i++){
neighbor = neighbors[i];
if(neighbor.isClosed || currentCell.isBlocked){
continue; // ignore cell
}
if(IsDiagonal(currentCell,neighbor)){
gScore = currentCell.g + diagonalScore;
}else{
gScore = currentCell.g + horizontalScore;
}
if(currentCell.j > 0 && !neighbor.isGround && !neighbor.isPassableGround && !neighbor.isWall){
if(GetNonDiagonalDirection(currentCell,neighbor) != Vector2.left && GetNonDiagonalDirection(currentCell,neighbor) != Vector2.right){
neighbor.j = currentCell.j + 1;
}else{
neighbor.j = currentCell.j + 0.5f;
}
}else if(currentCell.j > 0){
if((GetNonDiagonalDirection(currentCell,neighbor) != Vector2.left && GetNonDiagonalDirection(currentCell,neighbor) != Vector2.right && currentCell.parent != null && GetNonDiagonalDirection(currentCell,currentCell.parent) == Vector2.up) || neighbor.isWall){
neighbor.j = 0;
neighbor.th = 0;
}else{
continue;
}
}
if(GetNonDiagonalDirection(currentCell,neighbor) == Vector2.up){
//neighbor.infoCell.GetComponent<SpriteRenderer>().color = Color.cyan;
if(currentCell.j == 0){
neighbor.j = 2;
}else if(currentCell.j % 2 != 0){
neighbor.j = currentCell.j + 1;
}
/*else{
neighbor.j = currentCell.j + 1;
//.........这里部分代码省略.........
示例5: Bug0001
public void Bug0001()
{
var grid1 = new Grid();
grid1.Redim(4, 12);
grid1.FixedRows = 2;
grid1[0, 3] = new Cell("5 Column Header");
grid1[0, 3].ColumnSpan = 5;
//2 Header Row
grid1[1, 0] = new Cell("1");
grid1[1, 1] = new Cell("2");
var cell = new SourceGrid.Cells.CheckBox("CheckBox Column/Row Span", false);
grid1[2, 2] = cell;
grid1[2, 2].ColumnSpan = 2;
grid1[2, 2].RowSpan = 2;
// test that all cells point to the same cell
Assert.AreEqual(cell, grid1.GetCell(2, 3));
Assert.AreEqual(cell, grid1.GetCell(3, 2));
Assert.AreEqual(cell, grid1.GetCell(3, 3));
}