37 lines
978 B
GDScript3
Raw Normal View History

2019-11-19 12:43:35 +01:00
extends Control
var _container: GridContainer
var _labelPillLevel: Label
var _pillLevel: TextureProgress
2019-11-19 12:43:35 +01:00
2019-12-14 21:05:09 +01:00
onready var _keyTexture = load("res://Resources/Models/key/key.png")
onready var _cardTexture = load("res://Resources/Models/keycard/keycard.png")
2019-11-19 12:43:35 +01:00
# Called when the node enters the scene tree for the first time.
func _ready():
_container = get_node("InventoryContainer")
_labelPillLevel = get_node("PillLevel")
_pillLevel = get_node("TextureProgress")
# TODO: may use global values in Inspector?
_pillLevel.max_value = Pills.get_max()
2019-11-19 12:43:35 +01:00
func add_item (name):
Logger.info("Adding item \"" + name + "\" to inventory")
2019-11-19 12:43:35 +01:00
#TODO: global member for inventory?
var text
if name == "Key":
2019-12-14 21:05:09 +01:00
text = _keyTexture
elif name == "Keycard":
2019-12-14 21:05:09 +01:00
text = _cardTexture
else:
return
var rect = TextureRect.new()
rect.texture = text
_container.add_child(rect)
func _process(_delta):
_labelPillLevel.text = "curLevel: " + String(Pills._level)
_pillLevel.value = Pills._level