world receives score signal

This commit is contained in:
mightypanders 2021-06-12 23:28:48 +02:00
parent 31802c51ad
commit e1fff44040
2 changed files with 10 additions and 1 deletions

View File

@ -4,6 +4,8 @@ onready var streets = $Streets
onready var used_cells = streets.get_used_cells() onready var used_cells = streets.get_used_cells()
onready var guests = $Guests onready var guests = $Guests
export var player_score = 0
var Guest = load("res://Guest.tscn") var Guest = load("res://Guest.tscn")
var rng = RandomNumberGenerator.new() var rng = RandomNumberGenerator.new()
@ -36,7 +38,7 @@ func create_new_guest():
while !position_found: while !position_found:
if spawn_tries >= MAX_SPAWN_TRIES: if spawn_tries >= MAX_SPAWN_TRIES:
print("Max spawn tries reached!") #print("Max spawn tries reached!")
return return
position_found = true; position_found = true;
var new_guest_cell = used_cells[rng.randi_range(0, used_cells.size()) -1] var new_guest_cell = used_cells[rng.randi_range(0, used_cells.size()) -1]
@ -52,3 +54,9 @@ func create_new_guest():
new_guest.position = new_guest_position; new_guest.position = new_guest_position;
guests.add_child(new_guest) guests.add_child(new_guest)
spawn_tries = 0 spawn_tries = 0
func _on_Playa_scored(value:int):
print('Its a score of %s'% String(value))
player_score += value
pass # Replace with function body.

View File

@ -691,5 +691,6 @@ autostart = true
[node name="Guest" parent="Guests" instance=ExtResource( 5 )] [node name="Guest" parent="Guests" instance=ExtResource( 5 )]
position = Vector2( 337.119, 100.387 ) position = Vector2( 337.119, 100.387 )
[connection signal="scored" from="Playa" to="." method="_on_Playa_scored"]
[connection signal="timeout" from="GuestTimer" to="." method="_on_GuestTimer_timeout"] [connection signal="timeout" from="GuestTimer" to="." method="_on_GuestTimer_timeout"]
[connection signal="picked_up" from="Guests/Guest" to="." method="_on_Guest_picked_up"] [connection signal="picked_up" from="Guests/Guest" to="." method="_on_Guest_picked_up"]