- added basic inventory and items (ugly but working!)
- TODO: move inventory handling to global
This commit is contained in:
parent
2ce505fe78
commit
785254f98a
@ -25,6 +25,8 @@ var _dir = Vector3();
|
|||||||
var _vel = Vector3();
|
var _vel = Vector3();
|
||||||
var _is_sprinting;
|
var _is_sprinting;
|
||||||
var _prev_look;
|
var _prev_look;
|
||||||
|
# TODO: move to global
|
||||||
|
var _inventory: Control
|
||||||
|
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
@ -38,6 +40,8 @@ func _ready():
|
|||||||
|
|
||||||
# TODO: move to Designer:
|
# TODO: move to Designer:
|
||||||
ui_interact_nodepath = get_node("HUD").get_node("PressInteract").get_path()
|
ui_interact_nodepath = get_node("HUD").get_node("PressInteract").get_path()
|
||||||
|
|
||||||
|
_inventory = get_node("HUD")
|
||||||
|
|
||||||
|
|
||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
@ -114,6 +118,7 @@ func check_interact():
|
|||||||
#do interaction
|
#do interaction
|
||||||
if Input.is_action_just_pressed("interact"):
|
if Input.is_action_just_pressed("interact"):
|
||||||
collider.do_interact(self)
|
collider.do_interact(self)
|
||||||
|
_inventory.add_item(collider.name)
|
||||||
else:
|
else:
|
||||||
#stop showing interact tooltip
|
#stop showing interact tooltip
|
||||||
get_node(ui_interact_nodepath).hide()
|
get_node(ui_interact_nodepath).hide()
|
||||||
|
@ -1,14 +1,32 @@
|
|||||||
extends Control
|
extends Control
|
||||||
|
|
||||||
var _container: GridContainer
|
var _container: GridContainer
|
||||||
|
var _labelPillLevel: Label
|
||||||
|
var _pillLevel: TextureProgress
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
_container = get_node("GridContainer");
|
_container = get_node("InventoryContainer")
|
||||||
pass # Replace with function body.
|
_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?
|
#TODO: global member for inventory?
|
||||||
Node item = new Node();
|
var text = Texture.new()
|
||||||
_container.add_child(item)
|
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
|
@ -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://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"]
|
[node name="HUD" type="Control"]
|
||||||
anchor_right = 1.0
|
anchor_right = 1.0
|
||||||
anchor_bottom = 1.0
|
anchor_bottom = 1.0
|
||||||
margin_left = 5.12134
|
margin_left = 10.2837
|
||||||
margin_right = 5.12134
|
margin_right = 10.2837
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="PressInteract" type="Label" parent="."]
|
[node name="PressInteract" type="Label" parent="."]
|
||||||
@ -16,9 +17,22 @@ margin_right = 569.005
|
|||||||
margin_bottom = 529.582
|
margin_bottom = 529.582
|
||||||
text = "Press E to interact"
|
text = "Press E to interact"
|
||||||
|
|
||||||
[node name="GridContainer" type="GridContainer" parent="."]
|
[node name="InventoryContainer" type="GridContainer" parent="."]
|
||||||
margin_left = 868.0
|
margin_left = 868.0
|
||||||
margin_top = 48.0
|
margin_top = 48.0
|
||||||
margin_right = 1000.0
|
margin_right = 1007.0
|
||||||
margin_bottom = 491.0
|
margin_bottom = 565.0
|
||||||
columns = 3
|
|
||||||
|
[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
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
34
Models/key/key.png.import
Normal 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
BIN
Models/keycard/keycard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.9 KiB |
34
Models/keycard/keycard.png.import
Normal file
34
Models/keycard/keycard.png.import
Normal 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
|
BIN
Things/ReusableMaterials/pillLevel_fill.png
Normal file
BIN
Things/ReusableMaterials/pillLevel_fill.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 378 B |
34
Things/ReusableMaterials/pillLevel_fill.png.import
Normal file
34
Things/ReusableMaterials/pillLevel_fill.png.import
Normal 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
|
@ -110,6 +110,7 @@ move_sprint={
|
|||||||
take_pill={
|
take_pill={
|
||||||
"deadzone": 0.5,
|
"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)
|
"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={
|
interact={
|
||||||
|
Loading…
x
Reference in New Issue
Block a user