glitch-in-the-system/scripts/Exit.gd

24 lines
534 B
GDScript3
Raw Normal View History

2024-01-28 15:05:54 +01:00
class_name Exit
2019-09-16 08:07:41 +02:00
extends Node2D
2024-01-28 15:05:54 +01:00
@export
var area: Area2D
2019-09-16 08:07:41 +02:00
2024-01-28 15:05:54 +01:00
@export
var victory_scene: PackedScene
2019-09-16 08:07:41 +02:00
2024-01-28 15:05:54 +01:00
func _ready() -> void:
area.body_entered.connect(self._on_body_entered)
$Area2D.connect("body_entered",Callable(self,"on_collide"))
2019-09-16 08:07:41 +02:00
2024-01-28 15:05:54 +01:00
func _on_body_entered(body: PhysicsBody2D) -> void:
if body is Player:
2019-09-16 08:07:41 +02:00
MusicPlayer.stop()
MusicPlayer.stream = load("res://Music/DOS-88/Smooth Sailing.ogg")
MusicPlayer.volume_db = 0
MusicPlayer.play()
2024-01-28 15:05:54 +01:00
SaveManager.change_upgrade_points(1)
get_tree().change_scene_to_packed(victory_scene)