- added basic inventory and items (ugly but working!)

- TODO: move inventory handling to global
This commit is contained in:
SyntaX 2019-11-19 13:46:44 +01:00
parent 2ce505fe78
commit 785254f98a
10 changed files with 152 additions and 12 deletions

View File

@ -25,6 +25,8 @@ var _dir = Vector3();
var _vel = Vector3();
var _is_sprinting;
var _prev_look;
# TODO: move to global
var _inventory: Control
func _ready():
@ -39,6 +41,8 @@ func _ready():
# TODO: move to Designer:
ui_interact_nodepath = get_node("HUD").get_node("PressInteract").get_path()
_inventory = get_node("HUD")
func _physics_process(delta):
process_input()
@ -114,6 +118,7 @@ func check_interact():
#do interaction
if Input.is_action_just_pressed("interact"):
collider.do_interact(self)
_inventory.add_item(collider.name)
else:
#stop showing interact tooltip
get_node(ui_interact_nodepath).hide()

View File

@ -1,14 +1,32 @@
extends Control
var _container: GridContainer
var _labelPillLevel: Label
var _pillLevel: TextureProgress
# Called when the node enters the scene tree for the first time.
func _ready():
_container = get_node("GridContainer");
pass # Replace with function body.
_container = get_node("InventoryContainer")
_labelPillLevel = get_node("PillLevel")
_pillLevel = get_node("TextureProgress")
# TODO: may use global values in Inspector?
_pillLevel.max_value = Pills._max
func add_Item ():
func add_item (name):
Logger.info("Adding item \"" + name + "\" to inventory")
#TODO: global member for inventory?
Node item = new Node();
_container.add_child(item)
var text = Texture.new()
if name == "Key":
text = load("res://Models/key/key.png")
elif name == "Keycard":
text = load("res://Models/keycard/keycard.png")
var rect = TextureRect.new()
rect.texture = text
_container.add_child(rect)
func _process(delta):
_labelPillLevel.text = "curLevel: " + String(Pills._level)
_pillLevel.value = Pills._level

View File

@ -1,12 +1,13 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=3 format=2]
[ext_resource path="res://Characters/Player/UI/UI.gd" type="Script" id=1]
[ext_resource path="res://Things/ReusableMaterials/pillLevel_fill.png" type="Texture" id=2]
[node name="HUD" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 5.12134
margin_right = 5.12134
margin_left = 10.2837
margin_right = 10.2837
script = ExtResource( 1 )
[node name="PressInteract" type="Label" parent="."]
@ -16,9 +17,22 @@ margin_right = 569.005
margin_bottom = 529.582
text = "Press E to interact"
[node name="GridContainer" type="GridContainer" parent="."]
[node name="InventoryContainer" type="GridContainer" parent="."]
margin_left = 868.0
margin_top = 48.0
margin_right = 1000.0
margin_bottom = 491.0
columns = 3
margin_right = 1007.0
margin_bottom = 565.0
[node name="PillLevel" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 14.0
[node name="TextureProgress" type="TextureProgress" parent="."]
margin_left = -0.571533
margin_top = 24.7845
margin_right = 247.428
margin_bottom = 64.7845
max_value = 6.0
step = 0.1
value = 6.0
texture_progress = ExtResource( 2 )

BIN
Models/key/key.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

34
Models/key/key.png.import Normal file
View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/key.png-abaafa745205ccd95a158b352a19e47b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Models/key/key.png"
dest_files=[ "res://.import/key.png-abaafa745205ccd95a158b352a19e47b.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
Models/keycard/keycard.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/keycard.png-ccb60db0ca109718910ca2cd9f03027c.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Models/keycard/keycard.png"
dest_files=[ "res://.import/keycard.png-ccb60db0ca109718910ca2cd9f03027c.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/pillLevel_fill.png-fdb431190d360a95b9350b24d68930cb.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Things/ReusableMaterials/pillLevel_fill.png"
dest_files=[ "res://.import/pillLevel_fill.png-fdb431190d360a95b9350b24d68930cb.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -110,6 +110,7 @@ move_sprint={
take_pill={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":82,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":70,"unicode":0,"echo":false,"script":null)
]
}
interact={