我有一个函数,为给定另一个图块的特定图块设置绘图状态。绘制状态的图块将更改周围的图块,然后相应更新。我试图说明如下有没有办法摆脱返回void的函数?
[b] [b] [a]
[b] [a] [a]
[a] [a] [a] where a = sand && b = water
当a检测到b与其相邻时,它必须更新其绘制状态。所以我有一个适用于大写,小写,左大小写和右大写的函数。我现在需要修改功能,因此,它可以处理左右的情况下,右上的情况下,右下的情况下,等等,等等这是我的功能
public override void CompareBorderingTiles(Tile T)
{
if (T is Water)
{
float leftBound = location.X - (Tile.TileWidth * Tile.TileScale);
float rightBound = location.X + (Tile.TileWidth * Tile.TileScale);
float upperBound = location.Y - (Tile.TileHieght * Tile.TileScale);
float bottomBound = location.Y + (Tile.TileHieght * Tile.TileScale);
if (T.GridLocation.X == leftBound)
{
drawstate = DrawState.Left;
}
if (T.GridLocation.X == rightBound)
drawstate = DrawState.Right;
if (T.GridLocation.Y == upperBound)
drawstate = DrawState.Upper;
if (T.GridLocation.Y == bottomBound)
drawstate = DrawState.Lower;
}
base.CompareBorderingTiles(T);
}
它应该是相当解释,为什么我想打破这个功能,或者不是。基本上我有一个枚举,告诉我什么是draw-state(drawstate是enum)。 有人可以告诉我,如果我可以设置正确的绘制状态,然后离开我的功能?
你意味着你想停止你的功能?如果这是真的,你可以使用'return;'为它 –