- Third-Person Spieler mit WASD-Bewegung und Kamerasteuerung (RMB + Mausrad-Zoom) - HP-System mit Healthbar und Aktionsleiste (Slots 1-9) - Autoattack-System: Linksklick markiert Ziel, Rechtsklick markiert + greift an - Waffensystem-Basis: Schaden basiert auf ausgerüsteter Waffe (unbewaffnet = 1) - Gegner-KI: läuft auf Spieler zu, greift bei Reichweite an, zeigt HP-Label bei Markierung - Ressourcen-Klassen: Attack und Weapon Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
33 lines
981 B
GDScript
33 lines
981 B
GDScript
# HUD.gd
|
|
# Verwaltet die Spieler-UI: HP-Leiste, Aktionsleiste (Slots 1-9)
|
|
extends CanvasLayer
|
|
|
|
@onready var health_bar = $Control/HealthBar
|
|
@onready var health_label = $Control/HealthBar/HealthLabel
|
|
@onready var action_slots = [
|
|
$Control/ActionBar/A1,
|
|
$Control/ActionBar/A2,
|
|
$Control/ActionBar/A3,
|
|
$Control/ActionBar/A4,
|
|
$Control/ActionBar/A5,
|
|
$Control/ActionBar/A6,
|
|
$Control/ActionBar/A7,
|
|
$Control/ActionBar/A8,
|
|
$Control/ActionBar/A9
|
|
]
|
|
|
|
var active_slot = 0
|
|
|
|
# HP-Leiste und Text aktualisieren
|
|
func update_health(current_hp, max_hp):
|
|
health_bar.max_value = max_hp
|
|
health_bar.value = current_hp
|
|
health_label.text = str(current_hp) + " / " + str(max_hp)
|
|
|
|
# Aktions-Slot kurz golden hervorheben (0.1s)
|
|
func set_active_slot(index):
|
|
action_slots[active_slot].self_modulate = Color(1, 1, 1)
|
|
active_slot = index
|
|
action_slots[active_slot].self_modulate = Color(1, 0.8, 0)
|
|
await get_tree().create_timer(0.1).timeout
|
|
action_slots[active_slot].self_modulate = Color(1, 1, 1)
|