hero-mark-2/objects/exit/exit.gd
2023-01-07 03:02:26 -05:00

37 lines
1.1 KiB
GDScript

extends Node2D
export var cost = 0
onready var label = $Label
onready var anims = $AnimationPlayer
onready var map = get_owner()
func _ready():
anims.play("closed")
label.text = str(cost)
func _physics_process(delta):
if Game.shards >= cost:
anims.play("open")
func _on_Area2D_area_entered(area):
if area.is_in_group("player"):
if Game.score > Game.high_score: Game.high_score = Game.score
#BONUSES
#Time bonus
if Game.golds == 50 && Game.shards == 5:
if Game.time < map.target_time_100: Game.score += floor(2500 * (Game.time / map.target_time_100))
else:
if Game.time < map.target_time_any: Game.score += floor(2500 * (Game.time / map.target_time_any))
#Collection bonus
if Game.golds == 50: Game.score += 500
if Game.shards == 5: Game.score += 500
if Game.golds == 50 && Game.shards == 5: Game.score += 250
#Life bonus
if Game.lives == 1: Game.score += 500
if Game.lives == 2: Game.score += 1500
#Perfect bonus
if Game.lives == 2 && Game.golds == 50 && Game.shards == 5 && Game.time < map.target_time_100:
Game.score += 1000
Game.save()
Game.change_map(load("res://maps/level_select.tscn"))