41 lines
649 B
GDScript
41 lines
649 B
GDScript
extends Node
|
|
|
|
signal update_currency(amount)
|
|
|
|
var __currency: int
|
|
var __items: Array
|
|
|
|
|
|
func _ready() -> void:
|
|
__currency = 100
|
|
__items = []
|
|
return
|
|
|
|
|
|
func get_currency() -> int:
|
|
return __currency
|
|
|
|
|
|
func add_currency(amount: int) -> void:
|
|
__currency += amount
|
|
emit_signal('update_currency', __currency)
|
|
return
|
|
|
|
|
|
func contains(item: String) -> bool:
|
|
if item in __items:
|
|
return true
|
|
return false
|
|
|
|
|
|
func add(item: String) -> void:
|
|
__items.append(item)
|
|
return
|
|
|
|
|
|
func remove(item: String) -> void:
|
|
for k in range(len(__items)):
|
|
if __items[k] == item:
|
|
__items.remove(k)
|
|
return
|