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


C# Chain.ReportMatch方法代码示例

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


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

示例1: CheckMatch


//.........这里部分代码省略.........
        {
            if (StateAt(left - 1, y) != GridElement.ElementState.Block)
                break;
            if (!MatchAt(left - 1, y, block))
                break;
            left--;
        }

        int right = x + 1;
        while (right < PlayWidth)
        {
            if (StateAt(right, y) != GridElement.ElementState.Block)
                break;
            if (!MatchAt(right, y, block))
                break;
            right++;
        }

        int bottom = y;
        while (bottom > 1)
        {
            if (StateAt(x, bottom - 1) != GridElement.ElementState.Block)
                break;
            if (!MatchAt(x, bottom - 1, block))
                break;
            bottom--;
        }

        int top = y + 1;
        while (top < PlayHeight)
        {
            if (StateAt(x, top) != GridElement.ElementState.Block)
                break;
            if (!MatchAt(x, top, block))
                break;
            top++;
        }

        int width = right - left;
        int height = top - bottom;
        int magnitude = 0;
        bool horizontalPattern = false;
        bool verticalPattern = false;

        if (width >= MinimumPatternLength)
        {
            horizontalPattern = true;
            magnitude += width;
        }

        if (height >= MinimumPatternLength)
        {
            verticalPattern = true;
            magnitude += height;
        }

        if (!horizontalPattern && !verticalPattern)
        {
            block.EndChainInvolvement(chain);
            return;
        }

        if (chain == null)
        {
            chain = ChainManager.CreateChain();
        }

        // if pattern matches both directions
        if (horizontalPattern && verticalPattern)
            magnitude--;

        // kill the pattern's blocks and look for touching garbage
        block.StartDying(chain, magnitude);

        if (horizontalPattern)
        {
            // kill the pattern's blocks
            for (int killX = left; killX < right; killX++)
            {
                if (killX != x)
                {
                    BlockAt(killX, y).StartDying(chain, magnitude);
                }
            }
        }

        if (verticalPattern)
        {
            // kill the pattern's blocks
            for (int killY = bottom; killY < top; killY++)
            {
                if (killY != y)
                {
                    BlockAt(x, killY).StartDying(chain, magnitude);
                }
            }
        }

        chain.ReportMatch(magnitude, block);
    }
开发者ID:ronforbes,项目名称:BlockParty1,代码行数:101,代码来源:Grid.cs


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