-
Notifications
You must be signed in to change notification settings - Fork 1
/
select.gd
132 lines (92 loc) · 2.96 KB
/
select.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
extends MeshInstance
var array = ["", "res://house3.tscn", "res://cube.tscn"]
var index = 0
var money = 10000
var mode="build"
var istaken=0
func _input(event):
if event.is_action_released("select_right"):
global_translate(Vector3(4,0,0))
if event.is_action_released("select_left"):
global_translate(Vector3(-4,0,0))
if event.is_action_released("select_up"):
global_translate(Vector3(0,0,-4))
if event.is_action_released("select_down"):
global_translate(Vector3(0,0,4))
func _on_Button2_pressed():
visible = false
get_tree().get_root().get_node("Spatial/Control/Panel").visible=false
get_tree().get_root().get_node("Spatial/Control/Panel3").visible=false
func _ready():
var timer = Timer.new()
timer.set_wait_time(1.0)
timer.set_one_shot(false)
timer.connect("timeout", self, "repeat_me")
add_child(timer)
timer.start()
func repeat_me():
get_tree().get_root().get_node("Spatial/Control/Panel2/label").text=str(money)
func _on_Button_pressed():
rotate_y(deg2rad(45))
func _on_build_pressed():
visible = true
mode="build"
get_tree().get_root().get_node("Spatial/Control/Panel").visible=true
get_tree().get_root().get_node("Spatial/Control/Panel3").visible=true
get_tree().get_root().get_node("Spatial/Control/Panel4").visible=false
get_surface_material(0).albedo_color=Color(0,1,0,0.5)
func _on_Button3_pressed():
if mode=="build":
if istaken==0:
if money >=100:
if index!=0:
var scene = load(array[index])
var building = scene.instance()
building.transform.origin = transform.origin
building.transform.origin.y = 0
building.rotation = rotation
get_tree().get_root().get_node("Spatial/container").add_child(building)
money=money-100
get_tree().get_root().get_node("Spatial/Control/Panel2/label").text=str(money)
else:
pass
func _on_test_pressed(extra_arg_0):
index=1
func _on_test2_pressed():
index=2
var okornot
var collisions := 0
var del
func _on_Area_area_entered(area):
if mode=="build":
collisions += 1
if collisions > 0:
get_surface_material(0).albedo_color=Color(1,0,0,0.5)
istaken=1
del = area.get_node("../../")
func _on_Area_area_exited(area):
if mode=="build":
collisions -= 1
if collisions == 0:
get_surface_material(0).albedo_color=Color(0,1,0,0.5)
istaken=0
del=null
func _on_no_pressed():
get_tree().get_root().get_node("Spatial/Control/Panel4").visible=false
visible=false
func _on_ok_pressed():
if del!=null and money>=10:
money=money-10
get_tree().get_root().get_node("Spatial/Control/Panel2/label").text=str(money)
del.queue_free()
func _on_delete_pressed():
mode="delete"
get_tree().get_root().get_node("Spatial/Control/Panel").visible=false
get_tree().get_root().get_node("Spatial/Control/Panel3").visible=false
get_tree().get_root().get_node("Spatial/Control/Panel4").visible=true
istaken=0
if collisions>0:
collisions-=1
get_surface_material(0).albedo_color=Color(1,1,0,0.5)
rotation=Vector3(0,0,0)
visible=true