本文整理汇总了C#中MoveType.Move方法的典型用法代码示例。如果您正苦于以下问题:C# MoveType.Move方法的具体用法?C# MoveType.Move怎么用?C# MoveType.Move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MoveType
的用法示例。
在下文中一共展示了MoveType.Move方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanNotBeMoved
static bool CanNotBeMoved(this iBoard b, int x, int y, MoveType mt)
{
mt.Move(ref x, ref y);
CellType t = b[x, y];
if (t == CellType.Wall)
return true;
if (Is(t, CellType.Box))
{
bool u = mt == MoveType.Down || b.CanNotBeMoved(x, y, MoveType.Up);
bool d = mt == MoveType.Up || b.CanNotBeMoved(x, y, MoveType.Down);
bool l = mt == MoveType.Right || b.CanNotBeMoved(x, y, MoveType.Left);
bool r = mt == MoveType.Left || b.CanNotBeMoved(x, y, MoveType.Right);
if ((u || d) && (l || r))
{
return true;
}
}
return false;
}
示例2: Move
public static bool Move(this iBoard b, MoveType moveType)
{
int dx = 0, dy = 0;
moveType.Move(ref dx, ref dy);
int bx = b.BuddyX, by = b.BuddyY;
int nx = bx+ dx, ny = by + dy;
// on border check
if (dx < 0 && nx <= 0 || dx > 0 && nx >= b.Width - 1)
return false;
if (dy < 0 && ny <= 0 || dy > 0 && ny >= b.Height - 1)
return false;
if (IsEmpty(b[nx, ny]))
{
string boardInfo = b.GetBoardInfo(true);
b[bx,by] &= ~CellType.Buddy;
b[nx, ny] |= CellType.Buddy;
b.BuddyX = nx;
b.BuddyY = ny;
b.PushStep(new UndoStep(moveType, false, boardInfo));
return true;
}
if (Is(b[nx, ny], CellType.Box))
{
int nbx = nx + dx, nby = ny + dy;
// on border check
if (dx < 0 && nbx <= 0 || dx > 0 && nbx >= b.Width - 1)
return false;
if (dy < 0 && nby <= 0 || dy > 0 && nby >= b.Height - 1)
return false;
if (IsEmpty(b[nbx, nby]))
{
string boardInfo = b.GetBoardInfo(true);
b[nx, ny] &= ~CellType.Box;
b[nbx, nby] |= CellType.Box;
b[bx, by] &= ~CellType.Buddy;
b[nx, ny] |= CellType.Buddy;
b.BuddyX = nx;
b.BuddyY = ny;
b.PushStep(new UndoStep(moveType, true, boardInfo));
return true;
}
}
return false;
}