fix enemies sharing inventories
This also fixes an issue where enemies do not have weapons as their shared inventory is full and therefore can not equip any item.pull/3/head
parent
39d4069aa1
commit
423c3e3b17
|
@ -12,6 +12,7 @@
|
||||||
[ext_resource type="AudioStream" uid="uid://njun3e6v4854" path="res://Assets/Sounds/hurt.wav" id="10_n1e64"]
|
[ext_resource type="AudioStream" uid="uid://njun3e6v4854" path="res://Assets/Sounds/hurt.wav" id="10_n1e64"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ms3xg"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ms3xg"]
|
||||||
|
resource_local_to_scene = true
|
||||||
shader = ExtResource("1_fx1w5")
|
shader = ExtResource("1_fx1w5")
|
||||||
shader_parameter/color = Quaternion(1, 1, 1, 1)
|
shader_parameter/color = Quaternion(1, 1, 1, 1)
|
||||||
shader_parameter/intensity = 0.0
|
shader_parameter/intensity = 0.0
|
||||||
|
@ -49,6 +50,7 @@ atlas = ExtResource("3_ocaae")
|
||||||
region = Rect2(168, 0, 24, 24)
|
region = Rect2(168, 0, 24, 24)
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_6pejo"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_6pejo"]
|
||||||
|
resource_local_to_scene = true
|
||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
|
@ -177,7 +179,6 @@ shape = SubResource("RectangleShape2D_8lxmf")
|
||||||
[node name="Inventory" type="Node2D" parent="."]
|
[node name="Inventory" type="Node2D" parent="."]
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
script = ExtResource("7_43gq8")
|
script = ExtResource("7_43gq8")
|
||||||
Items = [null]
|
|
||||||
|
|
||||||
[node name="Sword" parent="Inventory" instance=ExtResource("8_s3c8r")]
|
[node name="Sword" parent="Inventory" instance=ExtResource("8_s3c8r")]
|
||||||
Knockback = 100.0
|
Knockback = 100.0
|
||||||
|
|
|
@ -203,6 +203,7 @@ horizontal_alignment = 1
|
||||||
y_sort_enabled = true
|
y_sort_enabled = true
|
||||||
position = Vector2(0, 4)
|
position = Vector2(0, 4)
|
||||||
script = ExtResource("7_xyenu")
|
script = ExtResource("7_xyenu")
|
||||||
|
Items = Array[Node2D]([])
|
||||||
InventoryMap = {
|
InventoryMap = {
|
||||||
"equip_1": 0,
|
"equip_1": 0,
|
||||||
"equip_2": 1
|
"equip_2": 1
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace SupaLidlGame.Items
|
||||||
public Character Character { get; private set; }
|
public Character Character { get; private set; }
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Array<Item> Items { get; private set; } = new Array<Item>();
|
public Array<Item> Items { get; private set; }
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public Dictionary<string, int> InventoryMap { get; set; }
|
public Dictionary<string, int> InventoryMap { get; set; }
|
||||||
|
@ -43,6 +43,26 @@ namespace SupaLidlGame.Items
|
||||||
InventoryMap.Add("equip_3", 2);
|
InventoryMap.Add("equip_3", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
if (Items is null)
|
||||||
|
{
|
||||||
|
// instantiating a new array will prevent characters from
|
||||||
|
// sharing inventories
|
||||||
|
Items = new Array<Item>();
|
||||||
|
}
|
||||||
|
Character = GetParent<Character>();
|
||||||
|
foreach (Node child in GetChildren())
|
||||||
|
{
|
||||||
|
if (child is Item item)
|
||||||
|
{
|
||||||
|
GD.Print("Adding item " + item.Name);
|
||||||
|
AddItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
base._Ready();
|
||||||
|
}
|
||||||
|
|
||||||
private bool EquipItem(Item item, ref Item slot)
|
private bool EquipItem(Item item, ref Item slot)
|
||||||
{
|
{
|
||||||
if (item is not null)
|
if (item is not null)
|
||||||
|
@ -122,19 +142,5 @@ namespace SupaLidlGame.Items
|
||||||
var e = SelectedItem = item;
|
var e = SelectedItem = item;
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
Character = GetParent<Character>();
|
|
||||||
foreach (Node child in GetChildren())
|
|
||||||
{
|
|
||||||
if (child is Item item)
|
|
||||||
{
|
|
||||||
GD.Print("Adding item " + item.Name);
|
|
||||||
AddItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
base._Ready();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue