working on items and inventory
This commit is contained in:
45
PickupableObjects/GluePatch/GluePatch.gd
Normal file
45
PickupableObjects/GluePatch/GluePatch.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
extends PU_Item
|
||||
|
||||
@onready var is_reachable := false
|
||||
@onready var current_player:CharacterBody2D = null
|
||||
|
||||
@onready var item_info = {
|
||||
"item_name": item_name,
|
||||
"item_description": item_description,
|
||||
"item_type": item_type,
|
||||
"item_clip_size": item_clip_size,
|
||||
"item_ammo": item_ammo,
|
||||
"item_cooldown": item_cooldown,
|
||||
"item_texture": item_texture,
|
||||
}
|
||||
|
||||
func _input(event):
|
||||
if Input.is_action_pressed("interact") and is_reachable and current_player:
|
||||
print("ITEM TYPE: ", item_type)
|
||||
# if item_type == 0: # 0 is weapon
|
||||
# print("Weapon!")
|
||||
current_player.add_inventory_item(item_info)
|
||||
print("Adding inventory item!")
|
||||
cleanup.rpc()
|
||||
|
||||
@rpc("call_local", "any_peer")
|
||||
func cleanup():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_glue_patch_pu_area_body_exited(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player.set_context_label("")
|
||||
current_player = null
|
||||
is_reachable = false
|
||||
|
||||
|
||||
func _on_glue_patch_pu_area_body_entered(body):
|
||||
if body.is_in_group("player"):
|
||||
current_player = body
|
||||
is_reachable = true
|
||||
current_player.set_context_label.rpc_id(current_player.get_multiplayer_authority(), "Pickup " + item_info.item_name + "?")
|
||||
|
||||
|
||||
|
||||
|
28
PickupableObjects/GluePatch/GluePatch.tscn
Normal file
28
PickupableObjects/GluePatch/GluePatch.tscn
Normal file
@@ -0,0 +1,28 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://r0424mbc1jx8"]
|
||||
|
||||
[ext_resource type="Script" path="res://PickupableObjects/GluePatch/GluePatch.gd" id="1_j7usm"]
|
||||
[ext_resource type="Texture2D" uid="uid://t7jsxx1bf6dl" path="res://PickupableObjects/GluePatch/glue_patch.png" id="2_aflxg"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dpesl"]
|
||||
size = Vector2(17, 25)
|
||||
|
||||
[node name="GluePatch" type="Node2D"]
|
||||
script = ExtResource("1_j7usm")
|
||||
item_name = "Glue Patch"
|
||||
item_description = "Lay down to slow down enemies!"
|
||||
item_type = 0
|
||||
item_clip_size = 3
|
||||
item_ammo = 3
|
||||
item_texture = ExtResource("2_aflxg")
|
||||
|
||||
[node name="GluePatchPUArea" type="Area2D" parent="."]
|
||||
|
||||
[node name="GluePatchImage" type="Sprite2D" parent="GluePatchPUArea"]
|
||||
texture = ExtResource("2_aflxg")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="GluePatchPUArea"]
|
||||
position = Vector2(0.5, 3.5)
|
||||
shape = SubResource("RectangleShape2D_dpesl")
|
||||
|
||||
[connection signal="body_entered" from="GluePatchPUArea" to="." method="_on_glue_patch_pu_area_body_entered"]
|
||||
[connection signal="body_exited" from="GluePatchPUArea" to="." method="_on_glue_patch_pu_area_body_exited"]
|
BIN
PickupableObjects/GluePatch/glue_patch.png
Normal file
BIN
PickupableObjects/GluePatch/glue_patch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 517 B |
34
PickupableObjects/GluePatch/glue_patch.png.import
Normal file
34
PickupableObjects/GluePatch/glue_patch.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://t7jsxx1bf6dl"
|
||||
path="res://.godot/imported/glue_patch.png-0c65bf8d7d6c6677dda74b8b236a0fa9.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://PickupableObjects/GluePatch/glue_patch.png"
|
||||
dest_files=["res://.godot/imported/glue_patch.png-0c65bf8d7d6c6677dda74b8b236a0fa9.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
Reference in New Issue
Block a user