本文整理汇总了Python中Units.shoot_at_best_target方法的典型用法代码示例。如果您正苦于以下问题:Python Units.shoot_at_best_target方法的具体用法?Python Units.shoot_at_best_target怎么用?Python Units.shoot_at_best_target使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Units
的用法示例。
在下文中一共展示了Units.shoot_at_best_target方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: turn
# 需要导入模块: import Units [as 别名]
# 或者: from Units import shoot_at_best_target [as 别名]
def turn(gc, unit):
Units.shoot_at_best_target(gc, unit)
if gc.is_move_ready(unit.id):
planet = unit.location.map_location().planet
path = get_closest_fact(unit) if planet == bc.Planet.Earth else Globals.updatePathMars
Navigation.path_with_bfs(gc, unit, path)
return
示例2: turn
# 需要导入模块: import Units [as 别名]
# 或者: from Units import shoot_at_best_target [as 别名]
def turn(gc, unit):
# t = time.time()
result = Units.shoot_at_best_target(gc, unit)
# Globals.ranger_find_time += time.time() - t
# print("find target time", Globals.ranger_find_time)
if isinstance(result, bc.Unit):
return
elif isinstance(result, bc.VecUnit):
nearby_enemies = result
else:
nearby_enemies = send_radar_info(unit, gc)
# t = time.time()
if gc.is_move_ready(unit.id):
e, should_retreat = ranger_retreat(unit, nearby_enemies)
if should_retreat:
moved = Navigation.retreatFromKnownEnemy(gc, unit, Globals.radar.get_enemy_center(unit.location.map_location().planet))
if moved:
return
if gc.is_attack_ready(unit.id):
planet = unit.location.map_location().planet
path = Globals.updatePath if planet == bc.Planet.Earth else Globals.updatePathMars
Navigation.path_with_bfs(gc, unit, path)
# Globals.ranger_else_time += time.time() - t
# print("other ranger time", Globals.ranger_else_time)
return