added price economy

This commit is contained in:
2024-11-13 17:23:04 +01:00
parent a12a965a2b
commit 0e850fd373
9 changed files with 283 additions and 18 deletions
+27 -7
View File
@@ -4,13 +4,33 @@ extends Node2D
@export_range(1, 1000) var _basic_ball: int
@export_range(1, 1000) var _speed_ball: int
@onready var _price_basic_current = _basic_ball
@onready var _price_speed_current = _speed_ball
@onready var _price_basic_current: int = _basic_ball
@onready var _price_speed_current: int = _speed_ball
@onready var _catalogue = {
"1": _price_basic_current,
"2": _price_speed_current,
}
signal on_update_ball_price(id: int, new_price: int)
var money: int = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
_update_money()
for k in _catalogue:
on_update_ball_price.emit(int(k), _catalogue[k])
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func may_buy_ball(id: int) -> bool:
if _catalogue["%s" % id] <= money:
print(_catalogue["%s" % id])
money -= _catalogue["%s" % id]
_catalogue["%s" % id] = _catalogue["%s" % id] * 1.1
_update_money()
on_update_ball_price.emit(int(id), _catalogue["%s" % id])
return true
else:
return false
func _update_money():
SignalBus.on_money_changed.emit(money)