-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.gd
53 lines (46 loc) · 1.94 KB
/
main.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class_name Main extends Node2D
var player_resource : EntityResource = preload("res://resources/entities/player.tres")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
var player : Entity = player_resource.make_entity()
add_child(player)
$level.generate_bsp()
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta : float) -> void:
if not get_tree().get_first_node_in_group("players"):
return
var player : Entity = player_resource.make_entity()
add_child(player)
($level as Level).move_player(player)
func regen_after_delay() -> void:
await get_tree().create_timer(5).timeout
await transition()
Global.floor_number = 1
var player : Entity = player_resource.make_entity()
add_child(player)
$level.generate_bsp()
await get_tree().create_timer(1).timeout
detransition()
func transition() -> void:
var rect : ColorRect = get_tree().get_first_node_in_group("postprocessrect")
var shader : ShaderMaterial = rect.material as ShaderMaterial
var tween = get_tree().create_tween()
var lambda = func a(x : float): shader.set_shader_parameter("quantizationSteps", x)
tween.tween_method(lambda, shader.get_shader_parameter("quantizationSteps"), 0, 3)
tween.tween_interval(1)
await tween.finished
func detransition() -> void:
var rect : ColorRect = get_tree().get_first_node_in_group("postprocessrect")
var shader : ShaderMaterial = rect.material as ShaderMaterial
var tween = get_tree().create_tween()
var lambda = func a(x : float): shader.set_shader_parameter("quantizationSteps", x)
tween.tween_method(lambda, shader.get_shader_parameter("quantizationSteps"), 16, 1)
await tween.finished
func next_level() -> void:
Global.floor_number += 1
if Global.floor_number > 3:
Global.queue_announcement("YOU WIN!", "Keep going for a high score!", Color.DARK_GREEN, [0.1, 15, 0.5])
await get_tree().create_timer(5).timeout
await transition()
$level.generate_bsp()
detransition()