forked from team-sg/hero-mark-2
45 lines
1.3 KiB
GDScript
45 lines
1.3 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
|
|
#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
|
|
Game.shards_collected[5] = true
|
|
#Time bonus
|
|
if Game.golds == 50 && Game.shards == 5:
|
|
if Game.time < map.target_time_100:
|
|
Game.score += max(2500 - 2500 * int(Game.time / map.target_time_100), 0)
|
|
Game.shards_collected[6] = true
|
|
else:
|
|
if Game.time < map.target_time_any:
|
|
Game.score += max(2500 - 2500 * int(Game.time / map.target_time_any), 0)
|
|
Game.shards_collected[6] = true
|
|
#Life bonus
|
|
if Game.lives == 1: Game.score += 500
|
|
if Game.lives == 2:
|
|
Game.score += 1500
|
|
Game.shards_collected[7] = true
|
|
#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"))
|