Compare commits

...

4 commits

Author SHA1 Message Date
Kevin Schmidt
20466ed45f TD-47: Show Money and Hitpoints
All checks were successful
Quality Check / Linting (pull_request) Successful in 6s
Quality Check / Linting (push) Successful in 6s
2025-03-13 13:21:53 +01:00
31075ba2b5
Chore: Bump to newest API version
All checks were successful
Quality Check / Linting (push) Successful in 6s
Build Application / generate (push) Successful in 21s
Build Application / build (tower_defence_web, build/*, build, build/index.html, Web) (push) Successful in 16s
Build Application / build (tower_defence.elf, tower_defence.elf, tower_defence.elf, Linux) (push) Successful in 19s
Build Application / build (tower_defence.exe, tower_defence.exe, tower_defence.exe, Windows) (push) Successful in 21s
Build Application / build-docker (push) Successful in 16s
Build Application / release (push) Successful in 9s
2025-03-13 04:22:29 +01:00
8b61ddb89e
Merge pull request '[Fix]: Dead Code' (!8) from fix/unused-breaking-old-template-code into trunk
All checks were successful
Quality Check / Linting (push) Successful in 7s
Build Application / generate (push) Successful in 22s
Build Application / build (tower_defence_web, build/*, build, build/index.html, Web) (push) Successful in 15s
Build Application / build (tower_defence.elf, tower_defence.elf, tower_defence.elf, Linux) (push) Successful in 18s
Build Application / build (tower_defence.exe, tower_defence.exe, tower_defence.exe, Windows) (push) Successful in 20s
Build Application / build-docker (push) Successful in 17s
Build Application / release (push) Successful in 9s
Reviewed-on: #8
Reviewed-by: SZUT-Kevin <kevin.schmidt9101@gmail.com>
2025-03-12 10:07:21 +00:00
ca2fb20e6f
Fix: remove old Code that breaks the current one
All checks were successful
Quality Check / Linting (push) Successful in 6s
Quality Check / Linting (pull_request) Successful in 7s
2025-03-12 09:58:08 +01:00
9 changed files with 86 additions and 20 deletions

View file

@ -5,7 +5,7 @@ lint:
-gdlint .
-gdformat .
api_version := "v0.0.0-rc.4"
api_version := "v0.0.0-rc.8"
api_location := "scripts/api-client"
generate:
#!/bin/sh

View file

@ -1,8 +1,9 @@
[gd_scene load_steps=6 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/current_game_time.gd" id="2_3jcub"]
[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"]
@ -35,24 +36,45 @@ scroll_active = false
autowrap_mode = 0
script = ExtResource("1_saby1")
[node name="Time" type="RichTextLabel" parent="UI/HUD"]
[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 = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
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:
@ -14,10 +16,15 @@ func _process(_delta: float) -> void:
return
while self.socket.get_available_packet_count():
var msg: Message = (
CurrentUnixTimeMessage
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

@ -1,6 +1,6 @@
class_name Message
enum Channels { CONNECTION, MATCHMAKING }
enum Channels { CONNECTION, MATCHMAKING, MATCH }
func get_message_id() -> String:

View file

@ -1,9 +0,0 @@
extends RichTextLabel
func _ready() -> void:
MatchChannel.connect("on_match_update", on_match_update)
func on_match_update(msg: CurrentUnixTimeMessage) -> void:
self.text = str(msg.time)

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)