本文整理汇总了C#中Facing.Count方法的典型用法代码示例。如果您正苦于以下问题:C# Facing.Count方法的具体用法?C# Facing.Count怎么用?C# Facing.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facing
的用法示例。
在下文中一共展示了Facing.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetRoadIndex
/// <summary>
/// Gets the tile index according to the number of specified neighbor roads
/// </summary>
/// <returns>
/// The index.
/// </returns>
/// <param name='f'>
/// The directions of neighboring roads.
/// </param>
public int GetRoadIndex(Facing[] f)
{
if(f.Count() > 4)
throw new Exception("There cannot be more than 4 possible neighbors");
else if(f.Count() == 4)
return Tiles.ROAD4WAY;
else if(f.Count() == 3)
return Tiles.ROAD3WAY;
else if(f.Count() == 2){
if((f.Contains(Facing.North) && f.Contains(Facing.West)) || (f.Contains(Facing.South) && f.Contains(Facing.East)))
return Tiles.CORNER;
else if((f.Contains(Facing.South) && f.Contains(Facing.West)) || (f.Contains(Facing.North) && f.Contains(Facing.East)))
return Tiles.CORNER2;
else if((f.Contains(Facing.North) && f.Contains(Facing.South)) || (f.Contains(Facing.West) && f.Contains(Facing.East)))
return Tiles.ROAD;
}
//If f.Count == 1 or 0
return Tiles.ROAD;
}
示例2: GetRoadFlip
//TODO: Fix the road flip values to reflect Facing North = x--
public bool[] GetRoadFlip(Facing[] f)
{
if (f.Count() > 4)
throw new Exception ("Cannot have more than 4 possible neighbors!");
//If we know its a 4way.
else if (f.Count() == 4)
return new bool[]{false,false};
//Check the 3ways
else if (f.Count() == 3) {
if (f.Contains (Facing.North) && f.Contains (Facing.West) && f.Contains (Facing.East))
return new bool[]{true,true};
else if (f.Contains (Facing.North) && f.Contains (Facing.West) && f.Contains (Facing.South))
return new bool[]{true,false};
else if (f.Contains (Facing.North) && f.Contains (Facing.South) && f.Contains (Facing.East))
return new bool[]{false,true};
else if (f.Contains (Facing.West) && f.Contains (Facing.South) && f.Contains (Facing.East))
return new bool[]{false,false};
}
//Check the corners and roads
else if (f.Count() == 2) {
//Corner
if (f.Contains (Facing.North) && f.Contains (Facing.West))
return new bool[]{false,false};
else if (f.Contains (Facing.South) && f.Contains (Facing.East))
return new bool[]{false,true};
//Corner2
else if (f.Contains (Facing.North) && f.Contains (Facing.East))
return new bool[]{false,false};
else if (f.Contains (Facing.South) && f.Contains (Facing.West))
return new bool[]{true,false};
//Roads
else if (f.Contains (Facing.North) && f.Contains (Facing.South))
return new bool[]{false,false};
else if (f.Contains (Facing.East) && f.Contains (Facing.West))
return new bool[]{false,true};
}
else if (f.Count() == 1) {
if (f.Contains (Facing.North) || f.Contains (Facing.South))
return new bool[]{false,false};
else if (f.Contains (Facing.West) || f.Contains (Facing.East))
return new bool[]{false,true};
}
else if(f.Count () == 0)
return new bool[]{false,false};
throw new Exception("Array was malformed, contained duplicates, or just plain wrong.");
}