/
Main.gd
46 lines (31 loc) · 957 Bytes
/
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
extends Node2D
var current_scene = null
signal new_frame
func _ready():
current_scene = "choose"
$Choose.choices[0] = instantiate_plant("water")
$Choose.choices[1] = instantiate_plant("fire")
$Choose.choices[2] = instantiate_plant("grass")
$Choose.goto_choose()
func _process(delta):
emit_signal('new_frame')
func to_spaceship():
$Spaceship.goto_spaceship()
func to_map():
$Map.goto_map()
func to_choose(plant_list):
var new_list = [null, null, null]
for plant in range(3):
new_list[plant] = instantiate_plant(plant_list[plant])
#equivalent to the much more readable-> [instantiate_plant(plant) for plant in plant_list]
$Choose.choices = new_list
$Choose.goto_choose()
func instantiate_plant(species):
return $PlantFactory.instantiate_plant(species)
func _CHOOSE_choose_plant():
$Spaceship.seedling = $Choose.user_chose
to_spaceship()
func _on_Spaceship_open_map():
to_map()
func _on_Map_open_spaceship():
to_spaceship()