aboutsummaryrefslogtreecommitdiff
path: root/lib/building_interface.gd
blob: cb890dde9778f31c374ba379bf180616e56e1fbd (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
27
28
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 = $Node2D/Label
	var cost : Label = $Node2D/Cost
	label.text = str(get_amount())
	cost.text = str(get_cost())

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)