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