-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrbSelectionContainer.gd
46 lines (39 loc) · 1.29 KB
/
OrbSelectionContainer.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 ColorRect
signal orbSelected(orb)
signal orbsSelected(orbs)
var orbs = []
func _on_OrbSelection_orbSelected(orbName):
# emit_signal("orbSelected", orbName)
orbs.append(orbName)
if len(orbs) == 3:
emit_signal("orbsSelected", orbs)
Variables.initialOrbs = orbs
# hide()
get_tree().change_scene("res://Orb.tscn")
# orbs = []
else:
randomizeSelection()
var selectedOrbsHolder = $OrbSelection/VBoxContainer/Orbs2
var orbSprite = OrbSprite.new(orbName)
if len(orbs) == 1:
selectedOrbsHolder.get_node("Orb1").add_child(orbSprite)
elif len(orbs) == 2:
selectedOrbsHolder.get_node("Orb2").add_child(orbSprite)
elif len(orbs) == 3:
selectedOrbsHolder.get_node("Orb3").add_child(orbSprite)
print(orbs)
func randomizeSelection():
var orbs = Data.orbs.keys()
var index = randi() % orbs.size()
var selected1 = orbs[index]
orbs.remove(index)
index = randi() % orbs.size()
var selected2 = orbs[index]
orbs.remove(index)
index = randi() % orbs.size()
var selected3 = orbs[index]
print(selected1+" "+selected2+" "+selected3)
$OrbSelection.initialize(selected1, selected2, selected3)
func _ready():
randomize()
randomizeSelection()