root/3d/intro/intro.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
extends "res://src/scene.gd"

enum TUTORIAL_PHASE {
	INTRO = 1
	DONE = 2
	GIVE_FOOD = 3
	MOVE_LOCATION = 4
	END = 5
}

export(int) var phase = TUTORIAL_PHASE.INTRO

func _ready():
	$Path/PathFollow/intro_camera.focus = $nyoron
	var _e = $AnimationPlayer.connect("animation_finished", self, "animation_ended")
	pass

func animation_ended(name:String):
	if name == "intro":
		var egg_top = $nyoron/body/body_arm_r/pine_egg_top
		var egg_bottom = $pine_egg
		egg_top.get_parent().remove_child(egg_top)
		egg_bottom.get_parent().remove_child(egg_bottom)

func start_tutorial():
	phase = TUTORIAL_PHASE.GIVE_FOOD
	var pfriend = $nyoron
	pfriend.pause_mode = PAUSE_MODE_INHERIT
	pfriend.link_nodes()
	pfriend.needs.food.value = 50
	pfriend.animation.play("t_pose")
	$ui.setup_for_tutorial(phase)
	$ui/presents.connect("give_item", self, "given_item")
	
func given_item(name):
	$nyoron.receive_item(name)
	advance_phase()
	$ui.setup_for_tutorial(phase)

func advance_phase():
	phase += 1
	if phase >= TUTORIAL_PHASE.END or phase == TUTORIAL_PHASE.DONE:
		phase = TUTORIAL_PHASE.DONE
		# TODO switch scene
		return
	$ui.setup_for_tutorial(phase)