-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAdAgency.gd
125 lines (90 loc) · 2.18 KB
/
AdAgency.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
extends 'Building.gd'
tool
const type := Global.BuildingType.AD_AGENCY
const effects := [Global.StatType.ADS]
var building_name = 'Ad Agency'
var description = 'Pumping ads 24/7 towards the populace. Guaranteed to increase sales.'
func init(world):
.init(world)
supports_boost = true
update_upgrade_label()
add_upgrade_action(level, levels)
# notify any interested listeners that there might be some changes
emit_signal("info_updated", self, Global.StatType.ADS, get_ads())
world.connect("info_updated", self, "_on_world_info_updated")
func init_data():
levels = [
{
'number': 1,
'description': 'Level 1 ad agency.',
'base_ads': 1,
},
{
'number': 2,
'description': 'Level 2 ad agency.',
'base_ads': 2,
},
{
'number': 3,
'description': 'Level 3 ad agency.',
'base_ads': 3,
},
{
'number': 4,
'description': 'Level 4 ad agency.',
'base_ads': 4,
},
{
'number': 5,
'description': 'Level 5 ad agency.',
'base_ads': 5,
},
{
'number': 6,
'description': 'Level 6 ad agency.',
'base_ads': 6,
},
{
'number': 7,
'description': 'Level 7 ad agency.',
'base_ads': 7,
},
]
current_level = levels[0]
func get_stats():
return [
Global.new_stat(Global.StatType.LEVEL, level),
Global.new_stat(Global.StatType.ADS, get_ads()),
]
func get_boost_factor():
return pow(10, boost)
func get_ads():
return current_level['base_ads'] * get_boost_factor()
func get_property(property):
if property == Global.StatType.ADS:
return get_ads()
func get_actions():
return $actions.get_children()
func update():
emit_signal("info_updated", self, Global.StatType.ADS, get_ads())
func post_level_upgrade():
update()
func perform_action(action, _count):
if action.name == 'level_upgrade':
set_level(level + 1)
return
func _boost_changed():
update()
func _serialize():
return {}
func _deserialize(_data):
update()
func _on_world_info_updated(_world, item, _value):
if item == Global.StatType.MONEY:
update_upgrade_label()
func _on_flip_timer_timeout():
$base/animation.flip_h = not $base/animation.flip_h
if $base/animation.flip_h:
$base/animation.position.x += 1
else:
$base/animation.position.x -= 1