added price economy
This commit is contained in:
+27
-7
@@ -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)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
extends Node
|
||||
|
||||
signal on_try_buy_ball(id: int)
|
||||
signal on_money_changed(new_money: int)
|
||||
|
||||
Reference in New Issue
Block a user