-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobal.gd
124 lines (112 loc) · 3.85 KB
/
Global.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
tool
extends Node
signal deconstruct_mode_changed(enabled)
signal itemcounts_changed
enum ItemType {NONE,BAR,COG,PLATE,COPPER_PLATE,ARROW_PLATE,CIRCUITBOARD,BLOCK_TILE,COPPER_BAR,MACHINE,ROBO_HEAD,ROBO_PART,WALLS,WIRES,STORAGE_BOX,ROBO}
enum Dir {UP, RIGHT, DOWN, LEFT}
enum TransitionType {LINEAR = 0,SINE = 1,QUINT = 2,QUART = 3,QUAD = 4,EXPO = 5,ELASTIC = 6,CUBIC = 7,CIRC = 8,BOUNCE = 9,BACK = 10}
enum EaseType {IN = 0,OUT=1,IN_OUT=2,OUT_IN=3}
enum PhyLayer {ROBO = 1, FULL_ROBO = 2, EMPTY_ROBO = 4, SPECIAL_TILE = 8}
var item_counts = {}
var current_level
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func instance_item(itemnum : int):
match itemnum:
ItemType.BAR:
return preload("res://Items/IronBar.tscn").instance()
ItemType.COG:
return preload("res://Items/Cog.tscn").instance()
ItemType.PLATE:
return preload("res://Items/IronPlate.tscn").instance()
ItemType.COPPER_PLATE:
return preload("res://Items/CopperPlate.tscn").instance()
ItemType.ARROW_PLATE:
return preload("res://Items/ArrowTile.tscn").instance()
ItemType.CIRCUITBOARD:
return preload("res://Items/Circuitboard.tscn").instance()
ItemType.BLOCK_TILE:
return preload("res://Items/DumpTile.tscn").instance()
ItemType.COPPER_BAR:
return preload("res://Items/CopperBar.tscn").instance()
ItemType.MACHINE:
return preload("res://Items/Machine.tscn").instance()
ItemType.ROBO_HEAD:
return preload("res://Items/RoboHead.tscn").instance()
ItemType.ROBO_PART:
return preload("res://Items/RoboPart.tscn").instance()
ItemType.WIRES:
return preload("res://Items/Wires.tscn").instance()
ItemType.WALLS:
return preload("res://Items/Wall.tscn").instance()
ItemType.ROBO:
return preload("res://Items/Robo.tscn").instance()
func get_icon_texture(itemnum : int):
match itemnum:
ItemType.BAR:
return preload("res://Items/Icons/IronBar0000.png")
ItemType.COG:
return preload("res://Items/Icons/Cog0000.png")
ItemType.PLATE:
return preload("res://Items/Icons/IronPlate0000.png")
ItemType.COPPER_PLATE:
return preload("res://Items/Icons/CopperPlate0000.png")
ItemType.ARROW_PLATE:
return preload("res://Items/Icons/ArrowTile0000.png")
ItemType.CIRCUITBOARD:
return preload("res://Items/Icons/Curicuitboard0000.png")
ItemType.BLOCK_TILE:
return preload("res://Items/Icons/DumpTile0000.png")
ItemType.COPPER_BAR:
return preload("res://Items/Icons/CopperBar0000.png")
ItemType.MACHINE:
return preload("res://Items/Icons/Machine0000.png")
ItemType.ROBO_HEAD:
return preload("res://Items/Icons/RoboHead0000.png")
ItemType.ROBO_PART:
return preload("res://Items/Icons/RoboPart0000.png")
ItemType.WIRES:
return preload("res://Items/Icons/Wires0000.png")
ItemType.WALLS:
return preload("res://Items/Icons/Wall0000.png")
ItemType.ROBO:
return preload("res://Items/Icons/Robo0000.png")
func get_dir_vec(dir : int):
var dir_vec = Vector2.ZERO
dir = dir % 4
match dir:
Global.Dir.UP:
dir_vec = Vector2(0, -1)
Global.Dir.RIGHT:
dir_vec = Vector2(1, 0)
Global.Dir.DOWN:
dir_vec = Vector2(0, 1)
Global.Dir.LEFT:
dir_vec = Vector2(-1, 0)
return dir_vec
func deposit_item(itemnum : int):
if itemnum == Global.ItemType.NONE:
return
if item_counts.has(itemnum):
item_counts[itemnum] += 1
else:
item_counts[itemnum] = 1
emit_signal("itemcounts_changed")
func take_item(itemnum : int):
if itemnum == Global.ItemType.NONE:
return false
if item_counts.has(itemnum) && item_counts[itemnum] > 0:
item_counts[itemnum] -= 1
emit_signal("itemcounts_changed")
return true
return false
func get_itemcount(itemnum : int):
if item_counts.has(itemnum):
return item_counts[itemnum]
return 0
func clear_items():
item_counts = {}
emit_signal("itemcounts_changed")
func set_deconstruct_mode(enabled):
emit_signal("deconstruct_mode_changed", enabled)