Show unit facing on battlefield
This commit is contained in:
@@ -3390,6 +3390,7 @@ func _draw_units() -> void:
|
||||
_draw_pixel_unit_sprite(rect, unit, team_color, sprite_modulate, _unit_pixel_facing(unit))
|
||||
_draw_unit_identity_marks(rect, center, unit, team_color)
|
||||
_draw_unit_class_badge(rect, unit, team_color)
|
||||
_draw_unit_facing_marker(rect, unit, team_color, sprite_modulate)
|
||||
|
||||
var hp_ratio := float(unit["hp"]) / float(max(1, int(unit["max_hp"])))
|
||||
var hp_back := Rect2(rect.position + Vector2(8, TILE_SIZE - 8), Vector2(TILE_SIZE - 16, 5))
|
||||
@@ -3944,6 +3945,57 @@ func _draw_unit_class_badge(rect: Rect2, unit: Dictionary, team_color: Color) ->
|
||||
draw_string(font, badge_rect.position + Vector2(0, 15), _unit_class_abbrev(unit), HORIZONTAL_ALIGNMENT_CENTER, badge_rect.size.x, 13, UI_PARCHMENT_TEXT)
|
||||
|
||||
|
||||
func _draw_unit_facing_marker(rect: Rect2, unit: Dictionary, team_color: Color, modulate: Color = Color.WHITE) -> void:
|
||||
var points := _unit_facing_marker_points(rect, unit)
|
||||
if points.size() < 3:
|
||||
return
|
||||
var fill := _unit_facing_marker_fill_color(unit, team_color)
|
||||
fill.a *= modulate.a
|
||||
var shadow_points := _offset_points(points, Vector2(1.2, 1.2))
|
||||
draw_colored_polygon(shadow_points, Color(0.020, 0.012, 0.006, 0.64 * modulate.a))
|
||||
draw_colored_polygon(points, fill)
|
||||
draw_polyline(_closed_polyline_points(points), Color(UI_OLD_BRONZE.r, UI_OLD_BRONZE.g, UI_OLD_BRONZE.b, 0.88 * modulate.a), 1.3)
|
||||
|
||||
|
||||
func _unit_facing_marker_points(rect: Rect2, unit: Dictionary) -> PackedVector2Array:
|
||||
var facing := _unit_pixel_facing(unit)
|
||||
var center_y := rect.position.y + rect.size.y * 0.48
|
||||
if facing < 0:
|
||||
return PackedVector2Array([
|
||||
Vector2(rect.position.x + 5.0, center_y),
|
||||
Vector2(rect.position.x + 18.0, center_y - 7.0),
|
||||
Vector2(rect.position.x + 18.0, center_y + 7.0)
|
||||
])
|
||||
return PackedVector2Array([
|
||||
Vector2(rect.end.x - 5.0, center_y),
|
||||
Vector2(rect.end.x - 18.0, center_y - 7.0),
|
||||
Vector2(rect.end.x - 18.0, center_y + 7.0)
|
||||
])
|
||||
|
||||
|
||||
func _unit_facing_marker_fill_color(unit: Dictionary, team_color: Color) -> Color:
|
||||
if _is_generic_enemy_unit(unit):
|
||||
return Color(ENEMY_COLOR.r, ENEMY_COLOR.g, ENEMY_COLOR.b, 0.84)
|
||||
var facing_color := team_color.lightened(0.24)
|
||||
return Color(facing_color.r, facing_color.g, facing_color.b, 0.84)
|
||||
|
||||
|
||||
func _offset_points(points: PackedVector2Array, offset: Vector2) -> PackedVector2Array:
|
||||
var result := PackedVector2Array()
|
||||
for point in points:
|
||||
result.append(point + offset)
|
||||
return result
|
||||
|
||||
|
||||
func _closed_polyline_points(points: PackedVector2Array) -> PackedVector2Array:
|
||||
var result := PackedVector2Array()
|
||||
for point in points:
|
||||
result.append(point)
|
||||
if not points.is_empty():
|
||||
result.append(points[0])
|
||||
return result
|
||||
|
||||
|
||||
func _draw_unit_class_emblem(rect: Rect2, center: Vector2, unit: Dictionary, team_color: Color) -> void:
|
||||
var family := _unit_class_family(unit)
|
||||
var class_color := _unit_class_badge_color(unit, team_color)
|
||||
@@ -5239,11 +5291,12 @@ func _format_unit_focus_text(unit: Dictionary, prefix: String) -> String:
|
||||
int(unit.get("int", 0)),
|
||||
int(unit.get("agi", 0))
|
||||
])
|
||||
lines.append("행군 %d (%s) 타격 %d-%d" % [
|
||||
lines.append("행군 %d (%s) 타격 %d-%d 시선 %s" % [
|
||||
int(unit.get("move", 0)),
|
||||
_format_move_type(str(unit.get("move_type", "foot"))),
|
||||
int(unit.get("min_range", 1)),
|
||||
int(unit.get("range", 1))
|
||||
int(unit.get("range", 1)),
|
||||
_unit_facing_text(unit)
|
||||
])
|
||||
lines.append(_unit_action_status_text(unit))
|
||||
var ai_text := _unit_ai_behavior_text(unit)
|
||||
@@ -5298,6 +5351,10 @@ func _unit_action_status_text(unit: Dictionary) -> String:
|
||||
return "군령: %s%s" % [_join_strings(actions, ", "), suffix]
|
||||
|
||||
|
||||
func _unit_facing_text(unit: Dictionary) -> String:
|
||||
return "서쪽" if _unit_pixel_facing(unit) < 0 else "동쪽"
|
||||
|
||||
|
||||
func _unit_has_usable_item_target(unit_id: String) -> bool:
|
||||
for item_id in state.get_usable_item_ids():
|
||||
if _item_has_valid_target(unit_id, str(item_id)):
|
||||
@@ -5494,11 +5551,12 @@ func _update_cell_info() -> void:
|
||||
var unit: Dictionary = summary["unit"]
|
||||
if not unit.is_empty():
|
||||
var control_label := " 호위" if not bool(unit.get("controllable", true)) else ""
|
||||
text += "\n군기: %s%s %s 품계 %d\n%s %s 병력 %d/%d 기력 %d/%d\n병장: %s" % [
|
||||
text += "\n군기: %s%s %s 품계 %d 시선 %s\n%s %s 병력 %d/%d 기력 %d/%d\n병장: %s" % [
|
||||
unit["name"],
|
||||
control_label,
|
||||
_unit_team_text(str(unit["team"])),
|
||||
unit["level"],
|
||||
_unit_facing_text(unit),
|
||||
_unit_class_display_name(unit),
|
||||
_unit_role_text(unit),
|
||||
unit["hp"],
|
||||
|
||||
Reference in New Issue
Block a user