Basic structure stuff for player health
This commit is contained in:
parent
9d0bf18030
commit
3646d1efb1
31
Global/InGameState.gd
Normal file
31
Global/InGameState.gd
Normal file
@ -0,0 +1,31 @@
|
||||
extends Node
|
||||
|
||||
|
||||
var max_health = 100.0
|
||||
var player_healths = []
|
||||
var player_count: int
|
||||
|
||||
signal player_win(player_id)
|
||||
signal player_count_updated(new_player_count)
|
||||
|
||||
|
||||
func set_player_count(new_player_count: int):
|
||||
assert(new_player_count <= 4)
|
||||
|
||||
player_count = new_player_count
|
||||
player_healths = []
|
||||
|
||||
for i in range(0, player_count):
|
||||
player_healths.append(max_health)
|
||||
|
||||
emit_signal("player_count_updated", new_player_count)
|
||||
|
||||
|
||||
func subtract_player_health(player_id, subtractor):
|
||||
assert(player_id < player_count)
|
||||
assert(player_id >= 0)
|
||||
|
||||
player_healths[player_id] -= subtractor
|
||||
|
||||
if player_healths[player_id] < 0.0:
|
||||
emit_signal("player_win", player_id)
|
75
UI/UI.tscn
Normal file
75
UI/UI.tscn
Normal file
@ -0,0 +1,75 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="UI" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
margin_right = -20.0
|
||||
margin_bottom = -20.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="PlayerHealthController" type="Control" parent="MarginContainer"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 560.0
|
||||
|
||||
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer/PlayerHealthController"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 560.0
|
||||
split_offset = 902
|
||||
dragger_visibility = 2
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HSplitContainer" type="HSplitContainer" parent="MarginContainer/PlayerHealthController/VSplitContainer"]
|
||||
margin_right = 984.0
|
||||
margin_bottom = 546.0
|
||||
split_offset = 492
|
||||
dragger_visibility = 1
|
||||
|
||||
[node name="Player1Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer"]
|
||||
margin_right = 496.0
|
||||
margin_bottom = 14.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Player2Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer"]
|
||||
margin_left = 508.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 14.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HSplitContainer2" type="HSplitContainer" parent="MarginContainer/PlayerHealthController/VSplitContainer"]
|
||||
margin_top = 546.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 560.0
|
||||
split_offset = 492
|
||||
dragger_visibility = 1
|
||||
|
||||
[node name="Player3Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer2"]
|
||||
margin_right = 496.0
|
||||
margin_bottom = 14.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Player4Health" type="ProgressBar" parent="MarginContainer/PlayerHealthController/VSplitContainer/HSplitContainer2"]
|
||||
margin_left = 508.0
|
||||
margin_right = 984.0
|
||||
margin_bottom = 14.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user