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


C# IFigure.ForEachNonEmptyCell方法代码示例

本文整理汇总了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;
        }
开发者ID:MarkiyanMatsekh,项目名称:MultiplayerTetris,代码行数:24,代码来源:CollisisonDetector.cs

示例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
        }
开发者ID:MarkiyanMatsekh,项目名称:MultiplayerTetris,代码行数:21,代码来源:GameField.cs

示例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;
        }
开发者ID:MarkiyanMatsekh,项目名称:MultiplayerTetris,代码行数:29,代码来源:CollisisonDetector.cs


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