-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFloorPanel.gd
40 lines (31 loc) · 1.09 KB
/
FloorPanel.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
extends StaticBody
var tree = preload("res://Tree.tscn")
var deer = preload("res://Models/Deer/Deer.tscn")
const MIN_TREES = 0
const MAX_TREES = 2
const MIN_DEER = 0
const MAX_DEER = 2
func _ready():
recreate()
func recreate():
for child in $Trees.get_children():
child.queue_free()
for child in $Deers.get_children():
child.queue_free()
randomize()
var tree_count = randi() % MAX_TREES + MIN_TREES
for index in range(0, tree_count):
var total_locations = $TreeSpawnLocations.get_child_count()
var position = $TreeSpawnLocations.get_children()[randi() % total_locations]
var instance = tree.instance()
instance.translation = position.translation
instance.translation.y = 4.5
$Trees.add_child(instance)
var deer_count = randi() % MAX_TREES + MIN_TREES
for index in range(0, deer_count):
var total_locations = $DeerSpawnLocations.get_child_count()
var position = $DeerSpawnLocations.get_children()[randi() % total_locations]
var instance = deer.instance()
instance.translation = position.translation
instance.rotation_degrees.y = randi() % 360
$Deers.add_child(instance)