Add more interactive effects to inventory menu

This commit is contained in:
2024-09-10 19:40:19 -07:00
parent 081bde1d9a
commit d854f159b4
21 changed files with 279 additions and 112 deletions

View File

@@ -11,5 +11,9 @@ namespace GameJamDungeon
public IGameRepo GameRepo { get; }
public InventoryItemInfo Info { get; }
public void Throw();
public void Drop();
}
}

View File

@@ -30,6 +30,16 @@ public partial class Accessory : Node3D, IInventoryItem, IEquipable
Pickup.BodyEntered += OnEntered;
}
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)

View File

@@ -30,6 +30,16 @@ public partial class Armor : Node3D, IInventoryItem, IEquipable
Pickup.BodyEntered += OnEntered;
}
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)

View File

@@ -29,6 +29,56 @@ public partial class ConsumableItem : Node3D, IInventoryItem
Pickup.BodyEntered += OnEntered;
}
public void Use()
{
if (ConsumableItemInfo.RaiseHPAmount != 0)
RaiseHP();
if (ConsumableItemInfo.RaiseVTAmount != 0)
RaiseVT();
if (ConsumableItemInfo.HealHPAmount != 0)
HealHP();
if (ConsumableItemInfo.HealVTAmount != 0)
HealVT();
}
private void RaiseHP()
{
if (GameRepo.PlayerStatInfo.Value.CurrentHP == GameRepo.PlayerStatInfo.Value.MaximumHP)
{
GameRepo.PlayerStatInfo.Value.MaximumHP += ConsumableItemInfo.RaiseHPAmount;
GameRepo.PlayerStatInfo.Value.CurrentHP = GameRepo.PlayerStatInfo.Value.MaximumHP;
}
}
private void HealHP()
{
GameRepo.PlayerStatInfo.Value.CurrentHP += ConsumableItemInfo.HealHPAmount;
}
private void RaiseVT()
{
if (GameRepo.PlayerStatInfo.Value.CurrentVT == GameRepo.PlayerStatInfo.Value.MaximumVT)
{
GameRepo.PlayerStatInfo.Value.MaximumVT += ConsumableItemInfo.RaiseVTAmount;
GameRepo.PlayerStatInfo.Value.CurrentVT = GameRepo.PlayerStatInfo.Value.MaximumVT;
}
}
private void HealVT()
{
GameRepo.PlayerStatInfo.Value.CurrentVT += ConsumableItemInfo.HealVTAmount;
}
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)

View File

@@ -5,4 +5,15 @@ namespace GameJamDungeon;
[GlobalClass]
public partial class ConsumableItemInfo : InventoryItemInfo
{
[Export]
public int HealHPAmount { get; set; } = 0;
[Export]
public int RaiseHPAmount { get; set; } = 0;
[Export]
public int HealVTAmount { get; set; } = 0;
[Export]
public int RaiseVTAmount { get; set; } = 0;
}

View File

@@ -5,7 +5,10 @@
[resource]
script = ExtResource("1_f8ogj")
HealVTAmount = 30
RaiseVTAmount = 10
Name = "Stelo Fragment"
Description = "A small gathered piece of the former heavens.
Restores 30 VT. If VT full, raises MAX VT by 10."
Texture = ExtResource("1_ic5xm")
SpawnRate = 0.5

View File

@@ -35,6 +35,16 @@ public partial class ThrowableItem : Node3D, IInventoryItem
Pickup.BodyEntered += OnEntered;
}
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)

View File

@@ -29,6 +29,16 @@ public partial class Weapon : Node3D, IInventoryItem, IEquipable
Pickup.BodyEntered += OnEntered;
}
public void Throw()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void Drop()
{
GameRepo.InventoryItems.Value.Remove(this);
}
public void OnEntered(Node3D body)
{
if (GameRepo.InventoryItems.Value.Count() >= GameRepo.MaxItemSize)