diff --git a/scripts/Main.gd b/scripts/Main.gd index 47cc8d0..9a3ac75 100644 --- a/scripts/Main.gd +++ b/scripts/Main.gd @@ -48,6 +48,11 @@ var progress_bg: ColorRect var upgrade_panel: Panel var gameover_panel: Panel +# Equipment slots +var equip_fills: Array[ColorRect] = [] +var equip_labels: Array[Label] = [] +var _equip_prev_tiers: Array[int] = [-1, -1, -1] + func _ready() -> void: _spawn_level() _create_camera() @@ -460,6 +465,8 @@ func _make_hud() -> void: # Tier display tier_label = _label(Vector2(12, 148), "", 17) + _make_equipment_slots() + func _make_upgrade_panel() -> void: upgrade_panel = Panel.new() upgrade_panel.process_mode = Node.PROCESS_MODE_ALWAYS @@ -539,6 +546,96 @@ func _make_gameover_panel() -> void: restart_btn.connect("pressed", _restart) vbox.add_child(restart_btn) +# ─── Equipment slots ────────────────────────────────────────────────────────── + +const _EQUIP_SLOT_SIZE := 54 +const _EQUIP_SLOT_GAP := 8 +const _EQUIP_SLOT_PAD := 3 +const _EQUIP_START_X := 12 +const _EQUIP_START_Y := 170 +const _EQUIP_EMPTY_COL := Color(0.10, 0.10, 0.16) +const _EQUIP_BORDER_COL := Color(0.30, 0.30, 0.42) + +# [slot_index][tier] = [fill_color, label_text] +const _EQUIP_DATA := [ + [ # shield + [Color(0.10, 0.10, 0.16), ""], + [Color(0.55, 0.38, 0.18), "Wood\nShield"], + [Color(0.55, 0.58, 0.62), "Iron\nShield"], + ], + [ # armor (toughness_tier) + [Color(0.10, 0.10, 0.16), ""], + [Color(0.76, 0.47, 0.18), "Leather\nArmor"], + [Color(0.58, 0.68, 1.00), "Metal\nArmor"], + ], + [ # boots (kick_tier) + [Color(0.10, 0.10, 0.16), ""], + [Color(0.76, 0.47, 0.18), "Leather\nBoots"], + [Color(0.58, 0.68, 1.00), "Plate\nBoots"], + [Color(0.75, 0.18, 1.00), "Magic\nBoots"], + ], +] + +func _make_equipment_slots() -> void: + var titles := ["Shield", "Armor", "Boots"] + for i in range(3): + var x := _EQUIP_START_X + i * (_EQUIP_SLOT_SIZE + _EQUIP_SLOT_GAP) + var y := _EQUIP_START_Y + + var title := _label(Vector2(x, y), titles[i], 12) + title.size.x = _EQUIP_SLOT_SIZE + title.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + + var border := ColorRect.new() + border.position = Vector2(x, y + 16) + border.size = Vector2(_EQUIP_SLOT_SIZE, _EQUIP_SLOT_SIZE) + border.color = _EQUIP_BORDER_COL + canvas.add_child(border) + + var fill := ColorRect.new() + fill.position = Vector2(x + _EQUIP_SLOT_PAD, y + 16 + _EQUIP_SLOT_PAD) + fill.size = Vector2(_EQUIP_SLOT_SIZE - _EQUIP_SLOT_PAD * 2, _EQUIP_SLOT_SIZE - _EQUIP_SLOT_PAD * 2) + fill.color = _EQUIP_EMPTY_COL + canvas.add_child(fill) + equip_fills.append(fill) + + var lbl := Label.new() + lbl.position = fill.position + lbl.size = fill.size + lbl.text = "" + lbl.add_theme_font_size_override("font_size", 11) + lbl.add_theme_color_override("font_color", Color.WHITE) + lbl.add_theme_color_override("font_shadow_color", Color(0, 0, 0, 0.85)) + lbl.add_theme_constant_override("shadow_offset_x", 1) + lbl.add_theme_constant_override("shadow_offset_y", 1) + lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER + lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER + lbl.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART + canvas.add_child(lbl) + equip_labels.append(lbl) + +func _update_equipment_slots() -> void: + if not is_instance_valid(player): + return + var tiers := [ + player.get("shield_tier") as int, + player.get("toughness_tier") as int, + player.get("kick_tier") as int, + ] + for i in range(3): + var tier: int = tiers[i] + if tier == _equip_prev_tiers[i]: + continue + _equip_prev_tiers[i] = tier + var data: Array = _EQUIP_DATA[i] + var entry: Array = data[clampi(tier, 0, data.size() - 1)] + equip_fills[i].color = entry[0] as Color + equip_labels[i].text = entry[1] as String + if tier > 0: + var tw := create_tween() + tw.tween_property(equip_fills[i], "color", Color.WHITE, 0.06) + tw.tween_property(equip_fills[i], "color", entry[0] as Color, 0.22) + # ─── UI helpers ─────────────────────────────────────────────────────────────── func _label(pos: Vector2, text: String, size: int) -> Label: @@ -577,3 +674,4 @@ func _update_tier_label() -> void: var st: int = player.get("shield_tier") var shield_str := "-" if st == 0 else str(st) tier_label.text = "Kick: %d Tough: %d Shield: %s" % [kt, tt, shield_str] + _update_equipment_slots()