shard respawn collection system
This commit is contained in:
parent
1c9291868a
commit
1755c6080a
2 changed files with 47 additions and 26 deletions
|
@ -4,7 +4,12 @@ signal collected(shard_number)
|
||||||
|
|
||||||
export var number = 0 #Used for saving which specific shards collected
|
export var number = 0 #Used for saving which specific shards collected
|
||||||
|
|
||||||
|
onready var player: Node2D = get_tree().get_nodes_in_group("player").pop_back()
|
||||||
|
|
||||||
|
var gotten := false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
player.connect("died", self, "_on_player_died")
|
||||||
var hud = get_tree().get_nodes_in_group("hud").pop_back()
|
var hud = get_tree().get_nodes_in_group("hud").pop_back()
|
||||||
if hud != null:
|
if hud != null:
|
||||||
connect("collected",hud,"shard_popup")
|
connect("collected",hud,"shard_popup")
|
||||||
|
@ -12,11 +17,21 @@ func _ready():
|
||||||
|
|
||||||
func _on_Area2D_body_entered(body):
|
func _on_Area2D_body_entered(body):
|
||||||
#Collect
|
#Collect
|
||||||
if body.is_in_group("player"):
|
if body.is_in_group("player") and not gotten:
|
||||||
emit_signal("collected",number)
|
gotten = true
|
||||||
Audio.play_shard_sound()
|
$Sprite.visible = false
|
||||||
|
Audio.play_sound(Audio.a_star,Audio.ac_collectible)
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
if gotten or Game.shards >= 4:
|
||||||
|
var player: Node2D = get_tree().get_nodes_in_group("player").pop_back()
|
||||||
|
if Game.get_sector(player.global_position) != Game.get_sector(global_position):
|
||||||
Game.score += 500
|
Game.score += 500
|
||||||
Game.shards_collected[number] = true
|
Game.shards_collected[number] = true
|
||||||
if Game._get_shards() >= 5 && Game.keys == 50:
|
emit_signal("collected",number)
|
||||||
Audio.great_job()
|
Audio.play_shard_sound()
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
|
func _on_player_died() -> void:
|
||||||
|
gotten = false
|
||||||
|
$Sprite.visible = true
|
||||||
|
|
|
@ -11,6 +11,9 @@ shader = ExtResource( 1 )
|
||||||
shader_param/border_color = Color( 0, 0, 0, 1 )
|
shader_param/border_color = Color( 0, 0, 0, 1 )
|
||||||
shader_param/border_corners = false
|
shader_param/border_corners = false
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id=17]
|
||||||
|
_data = [ Vector2( 0, 0 ), 0.0, 0.100639, 0, 0, Vector2( 0.158257, 1 ), 7.51724, -6.83592, 0, 0, Vector2( 0.31422, 0 ), 0.0, 0.0, 0, 0 ]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=6]
|
[sub_resource type="RectangleShape2D" id=6]
|
||||||
extents = Vector2( 3.5, 3.5 )
|
extents = Vector2( 3.5, 3.5 )
|
||||||
|
|
||||||
|
@ -46,35 +49,25 @@ tracks/0/keys = {
|
||||||
"values": [ Color( 0.766, 0.73, 1, 1 ), Color( 1.1, 1.1, 1.1, 1 ), Color( 0.766, 0.73, 1, 1 ) ]
|
"values": [ Color( 0.766, 0.73, 1, 1 ), Color( 1.1, 1.1, 1.1, 1 ), Color( 0.766, 0.73, 1, 1 ) ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Curve" id=17]
|
|
||||||
_data = [ Vector2( 0, 0 ), 0.0, 0.100639, 0, 0, Vector2( 0.158257, 1 ), 7.51724, -6.83592, 0, 0, Vector2( 0.31422, 0 ), 0.0, 0.0, 0, 0 ]
|
|
||||||
|
|
||||||
[node name="Shard" type="Node2D"]
|
[node name="Shard" type="Node2D"]
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
script = ExtResource( 3 )
|
script = ExtResource( 3 )
|
||||||
|
|
||||||
|
[node name="Empy" type="Sprite" parent="."]
|
||||||
|
modulate = Color( 0, 0, 0, 1 )
|
||||||
|
material = SubResource( 7 )
|
||||||
|
position = Vector2( 5, 3 )
|
||||||
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="."]
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
light_mask = 0
|
light_mask = 0
|
||||||
material = SubResource( 7 )
|
material = SubResource( 7 )
|
||||||
position = Vector2( 5, 3 )
|
position = Vector2( 5, 3 )
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
[node name="Area2D" type="Area2D" parent="."]
|
[node name="Sparkles" type="CPUParticles2D" parent="Sprite"]
|
||||||
collision_layer = 0
|
|
||||||
collision_mask = 128
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
|
||||||
visible = false
|
|
||||||
position = Vector2( 4.5, 2.5 )
|
|
||||||
shape = SubResource( 6 )
|
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
|
||||||
anims/RESET = SubResource( 18 )
|
|
||||||
anims/glow = SubResource( 8 )
|
|
||||||
|
|
||||||
[node name="Sparkles" type="CPUParticles2D" parent="."]
|
|
||||||
light_mask = 0
|
light_mask = 0
|
||||||
position = Vector2( 4.5, 2.5 )
|
position = Vector2( -0.5, -0.5 )
|
||||||
amount = 1
|
amount = 1
|
||||||
lifetime = 2.0
|
lifetime = 2.0
|
||||||
texture = ExtResource( 4 )
|
texture = ExtResource( 4 )
|
||||||
|
@ -89,4 +82,17 @@ scale_amount_curve = SubResource( 17 )
|
||||||
color = Color( 0.72549, 0.956863, 1, 1 )
|
color = Color( 0.72549, 0.956863, 1, 1 )
|
||||||
script = ExtResource( 5 )
|
script = ExtResource( 5 )
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
collision_layer = 0
|
||||||
|
collision_mask = 128
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
visible = false
|
||||||
|
position = Vector2( 4.5, 2.5 )
|
||||||
|
shape = SubResource( 6 )
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
anims/RESET = SubResource( 18 )
|
||||||
|
anims/glow = SubResource( 8 )
|
||||||
|
|
||||||
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue