~kmdodrill/my-brother-lives-in-a-canyon

ref: a9d84c742f9ddee630027cb3498c6f0aecb97907 my-brother-lives-in-a-canyon/src/Utils/Cameras.gd -rw-r--r-- 1.3 KiB
a9d84c74 — Kenneth Dodrill Code Cleanup and organization 7 months ago
                                                                                
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
extends Spatial

onready var cameras = get_children()
onready var dialogue_system = get_tree().root.get_node("DialogueSystem")
onready var player = get_tree().root.get_node("World/Objects/Player")
onready var main_screen = get_tree().root.get_node("World/UI/MainScreen")
onready var blur = $CanvasLayer/AnimationPlayer
onready var music_player = get_tree().root.get_node("MusicPlayer/AnimationPlayer")

export(bool) var on = false

func _ready():
    if on:
        init()

func init():
    cameras[0].get_node("PathFollow/Camera").set_current(true)
    
    player.hide()
    main_screen.get_node("Camera").current = false
    main_screen.get_node("MainMenu").hide()
    dialogue_system.pause_mode = PAUSE_MODE_PROCESS
    
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
    get_tree().paused = false
    
    yield(get_tree().create_timer(2.0), "timeout")
    
    dialogue_system.load_dialogue("res://assets/dialogue/trailer.json")
    dialogue_system.start_dialogue()
    
    for camera in cameras:
        if !camera is Path:
            continue
        
        player.set_mouth(camera.speaker)
        player.radio.set_speaker(camera.speaker)
        camera.init()
        yield(camera, "finished")
    
    blur.play("fade_in")
    music_player.play("turn_down_trailer")