本文整理汇总了C#中IFigure.ForEachNonEmptyCell方法的典型用法代码示例。如果您正苦于以下问题:C# IFigure.ForEachNonEmptyCell方法的具体用法?C# IFigure.ForEachNonEmptyCell怎么用?C# IFigure.ForEachNonEmptyCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFigure
的用法示例。
在下文中一共展示了IFigure.ForEachNonEmptyCell方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveMoveLeft
private CollisionType ResolveMoveLeft(IFigure figure)
{
var collision = CollisionType.None;
figure.ForEachNonEmptyCell((i, j) =>
{
var absoluteLeft = figure.Placement.Left + i;
var absoluteTop = figure.Placement.Top + j;
if (absoluteLeft < 0)
{
collision = CollisionType.Borders;
return false;
}
if (!_gameField.GroundView[absoluteLeft, absoluteTop].IsEmptyCell())
{
collision = CollisionType.Ground;
return false;
}
return true;
});
return collision;
}
示例2: AttachFigureToTheGround
public void AttachFigureToTheGround(IFigure figure)
{
figure.ForEachNonEmptyCell((i, j) =>
{
var x = figure.Placement.Left + i;
var y = figure.Placement.Top + j;
var cell = _sprite[x, y];
if (!cell.IsEmptyCell())
throw new InvalidOperationException("can't attach figure to ground - it's already filled");
_sprite[x, y] = figure[i, j];
_peak = Math.Min(_peak, y);
});
var fullRows = FindFullRows();
foreach (var rowNumber in fullRows)
RemoveRow(rowNumber);
var rowsDeleted = fullRows.Length;
//todo: notify multiplayer that n rows were deleted
}
示例3: ResolveMoveDown
private CollisionType ResolveMoveDown(IFigure figure)
{
var collision = CollisionType.None;
figure.ForEachNonEmptyCell((i, j) =>
{
var absoluteX = figure.Placement.Left + i;
var absoluteY = figure.Placement.Top + j;
if (absoluteY > _gameField.Size.Height - 1)
{
collision = CollisionType.Ground;
return false;
}
if (absoluteY < 0)
return true;
if (_gameField.GroundView[absoluteX, absoluteY].IsEmptyCell())
return true;
collision = CollisionType.Ground;
if (figure.Placement.Top == 1) // a little bad assumpotion that figures always start at 0, and thatn moves down by 1
collision = CollisionType.Critical;
return false;
});
return collision;
}