本文整理汇总了C#中Faction.GetAllAllyUnits方法的典型用法代码示例。如果您正苦于以下问题:C# Faction.GetAllAllyUnits方法的具体用法?C# Faction.GetAllAllyUnits怎么用?C# Faction.GetAllAllyUnits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Faction
的用法示例。
在下文中一共展示了Faction.GetAllAllyUnits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HexesWithinRangeContainingAllies
public List<Hex> HexesWithinRangeContainingAllies(Hex location, int range, Faction faction)
{
List<Hex> hexes_in_range = new List<Hex>();
foreach (Unit enemy in faction.GetAllAllyUnits())
{
if (this.InRange(location, enemy.location, range))
{
hexes_in_range.Add(enemy.location);
}
}
return hexes_in_range;
/*
List<Hex> hexes_in_range = new List<Hex>();
int x = (int)location.coordinate.x;
int xMin = Mathf.Max(0, x - range * 2);
int xMax = Mathf.Min(x_max, x + range * 2);
int y = (int)location.coordinate.y;
int yMin = Mathf.Max(0, y - range * 2);
int yMax = Mathf.Min(y_max, y + range * 2);
for (int cur_x = xMin; cur_x <= xMax; cur_x++)
{
for (int cur_y = yMin; cur_y <= yMax; cur_y++)
{
Hex cur_hex;
hex_dictionary.TryGetValue(cur_x + "," + cur_y, out cur_hex);
if (cur_hex.occupying_unit != null && faction.IsAlly(cur_hex.occupying_unit))
hexes_in_range.Add(cur_hex);
}
}
return hexes_in_range;*/
}