Show board status effect pips
This commit is contained in:
@@ -36,6 +36,10 @@ const FLOATING_TEXT_RISE := 42.0
|
||||
const UNIT_MOVE_ANIMATION_DURATION := 0.18
|
||||
const TARGET_PREVIEW_BADGE_SIZE := Vector2(92, 22)
|
||||
const LOW_HP_WARNING_RATIO := 0.35
|
||||
const UNIT_STATUS_MARKER_RADIUS := 4.0
|
||||
const UNIT_STATUS_MARKER_GAP := 9.0
|
||||
const UNIT_STATUS_MARKER_OFFSET_Y := 14.0
|
||||
const MAX_UNIT_STATUS_MARKERS := 4
|
||||
|
||||
var state: BattleState = BattleStateScript.new()
|
||||
var campaign_state: CampaignState = CampaignStateScript.new()
|
||||
@@ -981,7 +985,7 @@ func _draw_units() -> void:
|
||||
var hp_front := Rect2(hp_back.position, Vector2(hp_back.size.x * hp_ratio, hp_back.size.y))
|
||||
draw_rect(hp_back, Color(0.08, 0.08, 0.09))
|
||||
draw_rect(hp_front, _unit_hp_color(hp_ratio))
|
||||
_draw_unit_status_markers(center, hp_ratio)
|
||||
_draw_unit_status_markers(center, hp_ratio, unit)
|
||||
|
||||
if unit.get("id", "") == state.selected_unit_id:
|
||||
draw_arc(center, 29, 0.0, TAU, 48, Color(1.0, 0.92, 0.25), 3.0)
|
||||
@@ -995,10 +999,66 @@ func _unit_hp_color(hp_ratio: float) -> Color:
|
||||
return Color(0.28, 0.82, 0.36)
|
||||
|
||||
|
||||
func _draw_unit_status_markers(center: Vector2, hp_ratio: float) -> void:
|
||||
func _draw_unit_status_markers(center: Vector2, hp_ratio: float, unit: Dictionary) -> void:
|
||||
if hp_ratio <= LOW_HP_WARNING_RATIO:
|
||||
draw_arc(center, 27, 0.0, TAU, 48, Color(1.0, 0.28, 0.14), 3.0)
|
||||
|
||||
var marker_kinds := _unit_status_marker_kinds(unit)
|
||||
if marker_kinds.is_empty():
|
||||
return
|
||||
|
||||
var start_x := -float(marker_kinds.size() - 1) * UNIT_STATUS_MARKER_GAP * 0.5
|
||||
for index in range(marker_kinds.size()):
|
||||
var marker_center := center + Vector2(start_x + float(index) * UNIT_STATUS_MARKER_GAP, UNIT_STATUS_MARKER_OFFSET_Y)
|
||||
draw_circle(marker_center, UNIT_STATUS_MARKER_RADIUS + 1.5, Color(0.02, 0.022, 0.028, 0.88))
|
||||
draw_circle(marker_center, UNIT_STATUS_MARKER_RADIUS, _unit_status_marker_color(marker_kinds[index]))
|
||||
|
||||
|
||||
func _unit_status_marker_kinds(unit: Dictionary) -> Array[String]:
|
||||
var result: Array[String] = []
|
||||
var status_effects = unit.get("status_effects", [])
|
||||
if typeof(status_effects) != TYPE_ARRAY:
|
||||
return result
|
||||
|
||||
for effect in status_effects:
|
||||
if typeof(effect) != TYPE_DICTIONARY:
|
||||
continue
|
||||
if int(effect.get("remaining_phases", 0)) <= 0:
|
||||
continue
|
||||
|
||||
var marker_kind := _unit_status_marker_kind(effect)
|
||||
if marker_kind.is_empty() or result.has(marker_kind):
|
||||
continue
|
||||
|
||||
result.append(marker_kind)
|
||||
if result.size() >= MAX_UNIT_STATUS_MARKERS:
|
||||
break
|
||||
|
||||
return result
|
||||
|
||||
|
||||
func _unit_status_marker_kind(effect: Dictionary) -> String:
|
||||
var effect_type := str(effect.get("type", "stat_bonus"))
|
||||
if effect_type == "damage_over_time" and int(effect.get("amount", 0)) > 0:
|
||||
return str(effect.get("status", "poison"))
|
||||
if effect_type == "stat_bonus":
|
||||
var amount := int(effect.get("amount", 0))
|
||||
if amount > 0:
|
||||
return "support"
|
||||
if amount < 0:
|
||||
return "debuff"
|
||||
return ""
|
||||
|
||||
|
||||
func _unit_status_marker_color(marker_kind: String) -> Color:
|
||||
if marker_kind == "support":
|
||||
return Color(1.0, 0.88, 0.30)
|
||||
if marker_kind == "debuff":
|
||||
return Color(0.78, 0.55, 1.0)
|
||||
if marker_kind == "poison":
|
||||
return Color(0.54, 0.95, 0.36)
|
||||
return Color(0.72, 0.86, 1.0)
|
||||
|
||||
|
||||
func _visual_rect_for_unit(unit: Dictionary) -> Rect2:
|
||||
var cell: Vector2i = unit.get("pos", Vector2i(-1, -1))
|
||||
|
||||
Reference in New Issue
Block a user