aboutsummaryrefslogtreecommitdiff
path: root/lib/building_interface.gd
blob: b03d3d1de3a6bd9845ddf091563868088c19190c (plain)
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
extends Ticked
class_name BuildingInterface

export var base_cost := 1.0
export var cost_multiplier := 1.0
export var building_identifier := ""

func _process(delta):
	._process(delta)
	update_label()

func update_label():
	var label : Label = $Label
	label.text = str(get_amount())

func get_cost() -> float:
	return floor(base_cost * pow(cost_multiplier, get_amount()))

func get_amount() -> int:
	return SaveState.buildings[building_identifier]

func set_amount(value : int) -> void:
	SaveState.buildings[building_identifier] = value

func _bought() -> void:
	set_amount(get_amount() + 1)