Show Money, show hitpoints
This commit is contained in:
parent
8342b744a7
commit
f0805a14a8
8 changed files with 85 additions and 18 deletions
|
@ -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/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="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"]
|
[ext_resource type="Script" path="res://scripts/match/map.gd" id="4_4c550"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_86u83"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_86u83"]
|
||||||
|
@ -42,17 +43,38 @@ anchor_left = 0.5
|
||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
offset_left = -20.0
|
offset_left = -582.0
|
||||||
offset_top = -20.0
|
offset_top = -529.0
|
||||||
offset_right = 20.0
|
offset_right = -436.0
|
||||||
offset_bottom = 20.0
|
offset_bottom = -484.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
|
text = "Test"
|
||||||
fit_content = true
|
fit_content = true
|
||||||
scroll_active = false
|
scroll_active = false
|
||||||
autowrap_mode = 0
|
autowrap_mode = 0
|
||||||
script = ExtResource("2_3jcub")
|
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"]
|
[node name="Seperator" type="Panel" parent="UI/HUD"]
|
||||||
custom_minimum_size = Vector2(4, 0)
|
custom_minimum_size = Vector2(4, 0)
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|
|
@ -2,6 +2,8 @@ extends Channel
|
||||||
|
|
||||||
signal on_match_update(msg: TowerPlacedMessage)
|
signal on_match_update(msg: TowerPlacedMessage)
|
||||||
signal on_invalid_placing(msg: InvalidPlacementMessage)
|
signal on_invalid_placing(msg: InvalidPlacementMessage)
|
||||||
|
signal on_money_update(msg: PlayerMoneyMessage)
|
||||||
|
signal on_hitpoints_update(msg: PlayerHitpointsMessage)
|
||||||
|
|
||||||
|
|
||||||
func get_channel_location() -> String:
|
func get_channel_location() -> String:
|
||||||
|
@ -14,17 +16,27 @@ func _process(_delta: float) -> void:
|
||||||
return
|
return
|
||||||
while self.socket.get_available_packet_count():
|
while self.socket.get_available_packet_count():
|
||||||
var msg: Message = (
|
var msg: Message = (
|
||||||
CurrentUnixTimeMessage
|
Message
|
||||||
. deserialize(
|
. deserialize(
|
||||||
self.socket.get_packet().get_string_from_utf8(),
|
self.socket.get_packet().get_string_from_utf8(),
|
||||||
[TowerPlacedMessage, InvalidPlacementMessage],
|
[
|
||||||
|
TowerPlacedMessage,
|
||||||
|
InvalidPlacementMessage,
|
||||||
|
PlayerMoneyMessage,
|
||||||
|
PlayerHitpointsMessage,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
match msg.get_message_id():
|
match msg.get_message_id():
|
||||||
TowerPlacedMessage.MESSAGE_ID:
|
TowerPlacedMessage.MESSAGE_ID:
|
||||||
on_match_update.emit(msg)
|
on_match_update.emit(msg)
|
||||||
InvalidPlacementMessage.MESSAGE_ID:
|
InvalidPlacementMessage.MESSAGE_ID:
|
||||||
on_invalid_placing.emit(msg)
|
on_invalid_placing.emit(msg)
|
||||||
|
PlayerMoneyMessage.MESSAGE_ID:
|
||||||
|
on_money_update.emit(msg)
|
||||||
|
PlayerHitpointsMessage.MESSAGE_ID:
|
||||||
|
on_hitpoints_update.emit(msg)
|
||||||
_:
|
_:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
11
scripts/channel/match/player_hitpoints_message.gd
Normal file
11
scripts/channel/match/player_hitpoints_message.gd
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class_name PlayerHitpointsMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
const MESSAGE_ID: String = "PlayerHitpoints"
|
||||||
|
|
||||||
|
@export var playerHitpoints: int
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return MESSAGE_ID
|
11
scripts/channel/match/player_money_message.gd
Normal file
11
scripts/channel/match/player_money_message.gd
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
class_name PlayerMoneyMessage
|
||||||
|
extends Message
|
||||||
|
|
||||||
|
const MESSAGE_ID: String = "PlayerMoney"
|
||||||
|
|
||||||
|
@export var playerMoney: int
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func get_message_id() -> String:
|
||||||
|
return MESSAGE_ID
|
|
@ -1,6 +1,6 @@
|
||||||
class_name Message
|
class_name Message
|
||||||
|
|
||||||
enum Channels { CONNECTION, MATCHMAKING }
|
enum Channels { CONNECTION, MATCHMAKING, MATCH }
|
||||||
|
|
||||||
|
|
||||||
func get_message_id() -> String:
|
func get_message_id() -> String:
|
||||||
|
|
|
@ -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)
|
|
10
scripts/match/ui/player_hitpoints.gd
Normal file
10
scripts/match/ui/player_hitpoints.gd
Normal 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")
|
10
scripts/match/ui/player_money.gd
Normal file
10
scripts/match/ui/player_money.gd
Normal 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)
|
Loading…
Add table
Reference in a new issue