/
Planet.gd
68 lines (52 loc) · 1.26 KB
/
Planet.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
extends Node2D
var locked_image = null
var unlocked_image = null
var place = null
var plant_rarities = null
var locked = true
const starter_planet = {
"fire": 1,
"water": 1,
"grass": 1,
"spoon": 1,
"redspider": 1,
"digiveg": 1,
"kniveleaves": 1,
"livingblub": 1,
"potatocoon": 1,
"stonemoss": 1,
"purpletentacles": 1,
"firefleur" : 1,
"hand": 1,
"alienboi": 2,
"strangerock" : 2
}
func _ready():
pass
func render():
if locked:
$Button.set_normal_texture(load(locked_image))
elif not locked:
$Button.set_normal_texture(load(unlocked_image))
func give_plant_choices():
var choices = [null, null, null]
if place == 0:
for picks in range(3):
choices[picks] = give_plant_from_dict(starter_planet)
return choices
func give_plant_from_dict(planetdict):
var total_weight = 0
for plant in planetdict:
total_weight = total_weight + planetdict[plant]
var rng = rand_range(0, total_weight)
var running_total = 0
for plant in planetdict:
running_total = running_total + planetdict[plant]
if rng < running_total:
return plant
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _on_Button_pressed():
var choices = give_plant_choices()
get_parent().goto_choose_screen(choices)