more work on inventory

This commit is contained in:
2023-02-05 22:38:50 -05:00
parent d7572b48cc
commit 836a0e4a93
22 changed files with 613 additions and 68 deletions

View File

@@ -0,0 +1,35 @@
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:
# if item_type == 0: # 0 is weapon
# print("Weapon!")
var result = current_player.add_inventory_item(item_info)
if result:
queue_free()
func _on_bomb_pu_area_body_entered(body):
if body.is_in_group("player"):
current_player = body
is_reachable = true
current_player.set_context_label("Pickup " + item_info.item_name + "?")
func _on_bomb_pu_area_body_exited(body):
if body.is_in_group("player"):
current_player.set_context_label("")
current_player = null
is_reachable = false

View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=4 format=3 uid="uid://dp6umanf58x5t"]
[ext_resource type="Script" path="res://PickupableObjects/Bomb/bomb.gd" id="1_0j4vj"]
[ext_resource type="Texture2D" uid="uid://dmqfqmr16bdqk" path="res://PickupableObjects/Bomb/bomb_icon.png" id="2_c4hvj"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_1taf2"]
size = Vector2(20, 34)
[node name="bomb" type="Node"]
script = ExtResource("1_0j4vj")
[node name="BombPUArea" type="Area2D" parent="."]
[node name="bombImage" type="Sprite2D" parent="BombPUArea"]
texture = ExtResource("2_c4hvj")
[node name="CollisionShape2D" type="CollisionShape2D" parent="BombPUArea"]
position = Vector2(0, 7)
shape = SubResource("RectangleShape2D_1taf2")
[connection signal="body_entered" from="BombPUArea" to="." method="_on_bomb_pu_area_body_entered"]
[connection signal="body_exited" from="BombPUArea" to="." method="_on_bomb_pu_area_body_exited"]

View File

@@ -0,0 +1,13 @@
extends Node
class_name PU_Item
enum ItemType {WEAPON, ITEM, OTHER, ELSE}
@export var item_name:String = ""
@export_multiline var item_description:String = ""
@export var item_type = ItemType
@export var item_clip_size:int = 0
@export var item_ammo:int = 0
@export var item_cooldown:float = 1.0
@export var item_texture:Texture2D