added player count to ui
This commit is contained in:
parent
d3eb64493c
commit
d2f639dc14
@ -10,6 +10,7 @@ torsoPath = NodePath("Torso")
|
|||||||
cameraPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport/Camera")
|
cameraPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport/Camera")
|
||||||
rayCastPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport/MouseLook")
|
rayCastPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport/MouseLook")
|
||||||
viewPortPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport")
|
viewPortPath = NodePath("GUI/HBoxC/ViewportContainer/Viewport")
|
||||||
|
playerNumPath = NodePath("PlayerCountLabel")
|
||||||
|
|
||||||
[node name="GUI" type="MarginContainer" parent="."]
|
[node name="GUI" type="MarginContainer" parent="."]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
@ -65,5 +66,17 @@ enabled = true
|
|||||||
collide_with_areas = true
|
collide_with_areas = true
|
||||||
collide_with_bodies = false
|
collide_with_bodies = false
|
||||||
|
|
||||||
|
[node name="PlayerCountLabel" type="Label" parent="."]
|
||||||
|
anchor_left = 1.0
|
||||||
|
anchor_right = 1.0
|
||||||
|
margin_left = -30.0
|
||||||
|
margin_right = 1.90735e-06
|
||||||
|
margin_bottom = 600.0
|
||||||
|
rect_min_size = Vector2( 30, 30 )
|
||||||
|
text = "1/4"
|
||||||
|
__meta__ = {
|
||||||
|
"_edit_use_anchors_": false
|
||||||
|
}
|
||||||
|
|
||||||
[node name="Torso" parent="." instance=ExtResource( 1 )]
|
[node name="Torso" parent="." instance=ExtResource( 1 )]
|
||||||
[connection signal="pressed" from="GUI/HBoxC/VBoxC/Start" to="." method="_on_Start_pressed"]
|
[connection signal="pressed" from="GUI/HBoxC/VBoxC/Start" to="." method="_on_Start_pressed"]
|
||||||
|
@ -4,6 +4,7 @@ export(NodePath) var torsoPath
|
|||||||
export(NodePath) var cameraPath
|
export(NodePath) var cameraPath
|
||||||
export(NodePath) var rayCastPath
|
export(NodePath) var rayCastPath
|
||||||
export(NodePath) var viewPortPath
|
export(NodePath) var viewPortPath
|
||||||
|
export(NodePath) var playerNumPath
|
||||||
|
|
||||||
const ROT_MOD = 500
|
const ROT_MOD = 500
|
||||||
const ROT_DECLINE = 0.1
|
const ROT_DECLINE = 0.1
|
||||||
@ -14,12 +15,14 @@ var _camera : Camera
|
|||||||
var _rayCast : RayCast
|
var _rayCast : RayCast
|
||||||
var _torso : RigidBody
|
var _torso : RigidBody
|
||||||
var _viewport : Viewport
|
var _viewport : Viewport
|
||||||
|
var _playerNum : Label
|
||||||
|
|
||||||
var _velx = 0
|
var _velx = 0
|
||||||
var _vely = 0
|
var _vely = 0
|
||||||
var _attachment_point : Spatial
|
var _attachment_point : Spatial
|
||||||
|
|
||||||
var _default_grav
|
var _default_grav
|
||||||
|
var done_player_count = 0
|
||||||
|
|
||||||
signal start_fight()
|
signal start_fight()
|
||||||
|
|
||||||
@ -31,6 +34,14 @@ func _ready():
|
|||||||
_camera = get_node(cameraPath) as Camera
|
_camera = get_node(cameraPath) as Camera
|
||||||
_rayCast = get_node(rayCastPath) as RayCast
|
_rayCast = get_node(rayCastPath) as RayCast
|
||||||
_viewport = get_node(viewPortPath) as Viewport
|
_viewport = get_node(viewPortPath) as Viewport
|
||||||
|
_playerNum = get_node(playerNumPath) as Label
|
||||||
|
|
||||||
|
|
||||||
|
func change_count_ui():
|
||||||
|
if done_player_count == null:
|
||||||
|
print("test")
|
||||||
|
done_player_count = 0
|
||||||
|
_playerNum.text = str(done_player_count + 1) + "/" + str(InGameState.player_count)
|
||||||
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
@ -36,6 +36,7 @@ func _prep_scene(scene_name) -> Node:
|
|||||||
return _win_screen_scene
|
return _win_screen_scene
|
||||||
return null
|
return null
|
||||||
|
|
||||||
|
|
||||||
func _switch_scene(scene, scene_name):
|
func _switch_scene(scene, scene_name):
|
||||||
#delete children
|
#delete children
|
||||||
for child in get_children():
|
for child in get_children():
|
||||||
@ -64,6 +65,9 @@ func _switch_to_fighting(torso):
|
|||||||
if _body_count < InGameState.player_count:
|
if _body_count < InGameState.player_count:
|
||||||
_bodies.append(torso)
|
_bodies.append(torso)
|
||||||
_switch_scene(_body_build_scene, "body_build")
|
_switch_scene(_body_build_scene, "body_build")
|
||||||
|
|
||||||
|
_body_build_scene.done_player_count = _body_count
|
||||||
|
_body_build_scene.change_count_ui()
|
||||||
else:
|
else:
|
||||||
_switch_scene(_fighting_scene, "fight_scene")
|
_switch_scene(_fighting_scene, "fight_scene")
|
||||||
|
|
||||||
@ -74,5 +78,3 @@ func _switch_to_fighting(torso):
|
|||||||
|
|
||||||
func _switch_to_body_build():
|
func _switch_to_body_build():
|
||||||
_switch_scene(_body_build_scene, "body_build")
|
_switch_scene(_body_build_scene, "body_build")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user