本文整理汇总了C#中Unit.GetRange方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.GetRange方法的具体用法?C# Unit.GetRange怎么用?C# Unit.GetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unit
的用法示例。
在下文中一共展示了Unit.GetRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AllyScoreOnHex
// See how many allies there are around this hex
public float AllyScoreOnHex(Unit cur_unit, Hex hex)
{
float score = 0;
if (cur_unit.ally_grouping_score > 0)
{
// Find all hexes with allies on them
List<Hex> potential_targets = HexMap.hex_map.HexesWithinRangeContainingAllies(hex, cur_unit.GetRange(), cur_unit.owner);
foreach (Hex target_hex in potential_targets)
{
if (target_hex.occupying_unit != cur_unit)
score += cur_unit.ally_grouping_score;
}
}
return score;
}
示例2: UnitSelected
// Player left clicked on the unit
public void UnitSelected(Unit unit)
{
//UnitDeselected();
StopRotatingUnit();
ShowUnitStatsPanel(unit);
if (unit.owner == BattleManager.battle_manager.current_player)
{
selected_unit = unit;
//unit.unit_menu.SetActive(true);
PopulateAbilitiesMenu(unit);
// Check all enemies and see if they are within attack range of the selected unit
foreach (Unit enemy in unit.owner.GetAllEnemyUnits())
{
if (HexMap.hex_map.InRange(unit.location, enemy.location, unit.GetRange()))
{
enemy.location.HighlightAttackableHex(!unit.has_attacked && unit.active);
}
}
}
UnhighlightHexes();
unit.HighlightHexesWeCanMoveTo(unit.has_moved);
HighlightAttacksFrom(unit, unit.location);
}
示例3: SetRangeText
public void SetRangeText(Unit unit)
{
attack_range_text.text = "Attack Range: " + unit.GetRange();
attack_range_bar.value = (float) unit.GetRange() / 5.0f;
}
示例4: HighlightAttacksFromUnitLocationAndFrom
public void HighlightAttacksFromUnitLocationAndFrom(Unit unit, Hex hex)
{
if (!unit.has_attacked)
{
foreach (Unit enemy in selected_unit.owner.GetAllEnemyUnits())
{
if (HexMap.hex_map.InRange(hex, enemy.location, unit.GetRange())
|| HexMap.hex_map.InRange(unit.location, enemy.location, unit.GetRange()))
{
enemy.location.HighlightAttackableHex(!unit.has_attacked && unit.active);
}
}
}
}
示例5: EnemyScoreOnHex
// Check how much damage we can do to an enemy from this hex
public float EnemyScoreOnHex(Unit cur_unit, Hex hex)
{
float score = 0;
// Check if we can attack a unit from this hex
List<Hex> potential_targets = HexMap.hex_map.HexesWithinRangeContainingEnemies(hex, cur_unit.GetRange(), cur_unit.owner);
foreach (Hex target_hex in potential_targets)
{
score = Mathf.Max(score, target_hex.occupying_unit.CalculateDamage(cur_unit, target_hex));
// Increase the score of this hex if we can attack them without being counterattacked
if (cur_unit.attacks_are_counterable)
{
if (!target_hex.occupying_unit.counter_attacks || !target_hex.occupying_unit.IsFacing(hex)) //??
{
score *= cur_unit.flanking_factor;
}
}
}
// If we can't attack someone from this hex,
if ((score == 0 && cur_unit.owner.offensive_ai_score > 0) || cur_unit.GetRange() > 1)
{
float closest_enemy_distance = 100000;
// Find the closest enemy unit, and make this score higher the closer we are to it
foreach (Unit enemy in cur_unit.owner.GetAllEnemyUnits())
{
int dist = HexMap.hex_map.DistanceBetweenHexes(hex.coordinate, enemy.location.coordinate);
if (dist < closest_enemy_distance)
closest_enemy_distance = dist;
}
// Move towards enemies if we have no target
if (score == 0 && closest_enemy_distance < 100000)
score = (20f - closest_enemy_distance) / 2f;
// This section is for ranged units. They should move to their max range to stay away from enemy melee
// If the value is positive, that means that this unit is closer than this unit's range. We don't like that, so try to move to max range to stay alive
if (cur_unit.GetRange() > 1)
{
float distance_versus_range = closest_enemy_distance - cur_unit.GetRange();
if (distance_versus_range < 0)
{
score += distance_versus_range;
}
}
}
return score;
}