本文整理汇总了C#中RuleSet.GetBleedValue方法的典型用法代码示例。如果您正苦于以下问题:C# RuleSet.GetBleedValue方法的具体用法?C# RuleSet.GetBleedValue怎么用?C# RuleSet.GetBleedValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleSet
的用法示例。
在下文中一共展示了RuleSet.GetBleedValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BleedValue
private bool BleedValue(RuleSet rule, RuleValue value, Direction direction)
{
int x, y;
if(rule.mID == RuleID.RI_ROW)
{
x = direction == Direction.RIGHT ? value.minIndex : value.maxIndex;
y = rule.mIndex;
}
else
{
x = rule.mIndex;
y = direction == Direction.DOWN ? value.minIndex : value.maxIndex;
}
int idx = GetIndex(x, y);
// Have we already found our start position?
if (mBoard[idx] == SquareType.ST_BLACK)
{
bool canContinue = false;
for (int i = 0; i < value.mValue; ++i)
{
SetBoardValue(idx, SquareType.ST_BLACK);
value.AddIndex(idx);
canContinue = ShiftIndex(ref idx, direction);
}
if (canContinue)
SetBoardValue(idx, SquareType.ST_WHITE);
value.ClampMinMax(rule.GetBleedValue(x, y), value.mValue - 1, direction);
return true;
}
bool foundPortion = false;
bool isValid = false;
for (int i = 0; i < value.mValue; ++i)
{
if (mBoard[idx] == SquareType.ST_UNKNOWN)
{
if (foundPortion) // If we already found a portion of ourselves, it's impossible for this to not be black
{
SetBoardValue(idx, SquareType.ST_BLACK);
//if (direction == Direction.RIGHT || direction == Direction.DOWN)
//value.ClampMinMax(i + (value.mValue - 1));
value.ClampMinMax(rule.GetBleedValue(x, y), i + (value.mValue - 1), direction);
//else
// value.ClampMinMax(value.maxIndex - i - (value.mValue - 1));
}
isValid = ShiftIndex(ref idx, direction);
continue;
}
if (mBoard[idx] == SquareType.ST_WHITE) // It's not possible to fit in this space. Blank it out, and move ourselves forward
{
Debug.Assert(foundPortion == false); // It shouldn't be possible to have found a portion of ourselves, and then run out of room.
int initIdx = GetIndex(x, y);
for (int j = 0; j < i; ++j)
{
SetBoardValue(initIdx, SquareType.ST_WHITE);
ShiftIndex(ref initIdx, direction);
}
if (direction == Direction.RIGHT || direction == Direction.DOWN)
value.minIndex += (i + 1);
else
value.maxIndex -= (i+1);
return BleedValue(rule, value, direction);
}
if (mBoard[idx] == SquareType.ST_BLACK)
{
if (!foundPortion) // special case. We can sometimes reduce our max range by 1 if this would make two black runs collide
{
int p;
if (GetIndexOffset(idx, value.mValue, direction, rule, out p))
{
if (mBoard[p] == SquareType.ST_BLACK)
{
value.ClampMinMax(rule.GetBleedValue(x, y), i + (value.mValue - 2), direction);
}
}
}
foundPortion = true;
//if (direction == Direction.RIGHT || direction == Direction.DOWN)
// value.SetMaxIndex(value.minIndex + i + (value.mValue - 1));
//else
// value.SetMinIndex(value.maxIndex - i - (value.mValue - 1));
value.ClampMinMax(rule.GetBleedValue(x, y), i + (value.mValue - 1), direction);
}
isValid = ShiftIndex(ref idx, direction);
}
if (isValid)
{
if (foundPortion && mBoard[idx] == SquareType.ST_WHITE)
//.........这里部分代码省略.........