Merge pull request '[Feature]: Hp und Geld anzeigen' (!9) from task/TD-47-Lebenspunkte-Anzeigen into trunk
All checks were successful
Quality Check / Linting (push) Successful in 6s

Reviewed-on: #9
Reviewed-by: Snoweuph <snow+git@euph.email>
This commit is contained in:
SZUT-Kevin 2025-03-13 12:26:44 +00:00 committed by Euph Forge
commit e672567b3d
Signed by: Euph Forge
GPG key ID: 85A06461FB6BDBB7
6 changed files with 96 additions and 2 deletions

View file

@ -1,7 +1,9 @@
[gd_scene load_steps=5 format=4 uid="uid://co1x3hlc2efr6"]
[gd_scene load_steps=7 format=4 uid="uid://co1x3hlc2efr6"]
[ext_resource type="Script" path="res://scripts/match/ui/opponent_name.gd" id="1_saby1"]
[ext_resource type="Script" path="res://scripts/match/ui/player_money.gd" id="2_3jcub"]
[ext_resource type="TileSet" uid="uid://cvp867israfjk" path="res://tile_set.tres" id="3_0etcd"]
[ext_resource type="Script" path="res://scripts/match/ui/player_hitpoints.gd" id="3_oc5vk"]
[ext_resource type="Script" path="res://scripts/match/map.gd" id="4_4c550"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_86u83"]
@ -34,6 +36,45 @@ scroll_active = false
autowrap_mode = 0
script = ExtResource("1_saby1")
[node name="Money" type="RichTextLabel" parent="UI/HUD"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -582.0
offset_top = -529.0
offset_right = -436.0
offset_bottom = -484.0
grow_horizontal = 2
grow_vertical = 2
text = "Test"
fit_content = true
scroll_active = false
autowrap_mode = 0
script = ExtResource("2_3jcub")
[node name="Hitpoints" type="RichTextLabel" parent="UI/HUD"]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -946.0
offset_top = 479.0
offset_right = -800.0
offset_bottom = 524.0
grow_horizontal = 2
grow_vertical = 2
text = "HP
"
fit_content = true
scroll_active = false
autowrap_mode = 0
script = ExtResource("3_oc5vk")
[node name="Seperator" type="Panel" parent="UI/HUD"]
custom_minimum_size = Vector2(4, 0)
layout_mode = 1

View file

@ -2,6 +2,8 @@ extends Channel
signal on_match_update(msg: TowerPlacedMessage)
signal on_invalid_placing(msg: InvalidPlacementMessage)
signal on_money_update(msg: PlayerMoneyMessage)
signal on_hitpoints_update(msg: PlayerHitpointsMessage)
func get_channel_location() -> String:
@ -17,7 +19,12 @@ func _process(_delta: float) -> void:
Message
. deserialize(
self.socket.get_packet().get_string_from_utf8(),
[TowerPlacedMessage, InvalidPlacementMessage],
[
TowerPlacedMessage,
InvalidPlacementMessage,
PlayerMoneyMessage,
PlayerHitpointsMessage,
],
)
)
match msg.get_message_id():
@ -25,6 +32,10 @@ func _process(_delta: float) -> void:
on_match_update.emit(msg)
InvalidPlacementMessage.MESSAGE_ID:
on_invalid_placing.emit(msg)
PlayerMoneyMessage.MESSAGE_ID:
on_money_update.emit(msg)
PlayerHitpointsMessage.MESSAGE_ID:
on_hitpoints_update.emit(msg)
_:
continue

View file

@ -0,0 +1,11 @@
class_name PlayerHitpointsMessage
extends Message
const MESSAGE_ID: String = "PlayerHitpoints"
# gdlint:ignore = class-variable-name
@export var playerHitpoints: int
func get_message_id() -> String:
return MESSAGE_ID

View file

@ -0,0 +1,11 @@
class_name PlayerMoneyMessage
extends Message
const MESSAGE_ID: String = "PlayerMoney"
# gdlint:ignore = class-variable-name
@export var playerMoney: int
func get_message_id() -> String:
return MESSAGE_ID

View file

@ -0,0 +1,10 @@
extends RichTextLabel
func _ready() -> void:
MatchChannel.connect("on_hitpoints_update", on_hitpoints_update)
func on_hitpoints_update(msg: PlayerHitpointsMessage) -> void:
print(msg.playerHitpoints, "test")
self.text = str(msg.playerHitpoints, "HP")

View file

@ -0,0 +1,10 @@
extends RichTextLabel
func _ready() -> void:
MatchChannel.connect("on_money_update", on_money_update)
func on_money_update(msg: PlayerMoneyMessage) -> void:
print(msg.playerMoney, "test")
self.text = str(msg.playerMoney)