Big fix of inventory system, add accessory item type
This commit is contained in:
@@ -8,7 +8,7 @@ namespace GameJamDungeon
|
|||||||
{
|
{
|
||||||
public readonly record struct StartGame();
|
public readonly record struct StartGame();
|
||||||
|
|
||||||
public readonly record struct SetInventoryMode(List<InventoryItemInfo> Inventory);
|
public readonly record struct SetInventoryMode(List<InventoryItem> Inventory);
|
||||||
|
|
||||||
public readonly record struct HideInventory();
|
public readonly record struct HideInventory();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public interface IGameRepo : IDisposable
|
|||||||
{
|
{
|
||||||
event Action? Ended;
|
event Action? Ended;
|
||||||
|
|
||||||
AutoProp<List<InventoryItemInfo>> InventoryItems { get; }
|
AutoProp<List<InventoryItem>> InventoryItems { get; }
|
||||||
|
|
||||||
IAutoProp<bool> IsInventoryScreenOpened { get; }
|
IAutoProp<bool> IsInventoryScreenOpened { get; }
|
||||||
|
|
||||||
@@ -23,13 +23,17 @@ public interface IGameRepo : IDisposable
|
|||||||
|
|
||||||
void SetPlayerGlobalPosition(Vector3 playerGlobalPosition);
|
void SetPlayerGlobalPosition(Vector3 playerGlobalPosition);
|
||||||
|
|
||||||
public void OnWeaponEquipped(WeaponInfo equippedItem);
|
public void OnWeaponEquipped(Weapon equippedItem);
|
||||||
|
|
||||||
public void OnArmorEquipped(ArmorInfo equippedItem);
|
public void OnArmorEquipped(Armor equippedItem);
|
||||||
|
|
||||||
public WeaponInfo EquippedWeapon { get; }
|
public void OnAccessoryEquipped(Accessory equippedItem);
|
||||||
|
|
||||||
public ArmorInfo EquippedArmor { get; }
|
public Weapon EquippedWeapon { get; }
|
||||||
|
|
||||||
|
public Armor EquippedArmor { get; }
|
||||||
|
|
||||||
|
public Accessory EquippedAccessory { get; }
|
||||||
|
|
||||||
public AutoProp<int> HPBarValue { get; }
|
public AutoProp<int> HPBarValue { get; }
|
||||||
|
|
||||||
@@ -40,10 +44,10 @@ public class GameRepo : IGameRepo
|
|||||||
{
|
{
|
||||||
public event Action? Ended;
|
public event Action? Ended;
|
||||||
|
|
||||||
private readonly AutoProp<List<InventoryItemInfo>> _inventoryItems;
|
private readonly AutoProp<List<InventoryItem>> _inventoryItems;
|
||||||
private readonly AutoProp<bool> _isInventoryScreenOpened;
|
private readonly AutoProp<bool> _isInventoryScreenOpened;
|
||||||
|
|
||||||
public AutoProp<List<InventoryItemInfo>> InventoryItems => _inventoryItems;
|
public AutoProp<List<InventoryItem>> InventoryItems => _inventoryItems;
|
||||||
|
|
||||||
public IAutoProp<bool> IsInventoryScreenOpened => _isInventoryScreenOpened;
|
public IAutoProp<bool> IsInventoryScreenOpened => _isInventoryScreenOpened;
|
||||||
|
|
||||||
@@ -53,12 +57,16 @@ public class GameRepo : IGameRepo
|
|||||||
public IAutoProp<bool> IsPaused => _isPaused;
|
public IAutoProp<bool> IsPaused => _isPaused;
|
||||||
private readonly AutoProp<bool> _isPaused;
|
private readonly AutoProp<bool> _isPaused;
|
||||||
|
|
||||||
private WeaponInfo _equippedWeapon;
|
private Weapon _equippedWeapon;
|
||||||
public WeaponInfo EquippedWeapon => _equippedWeapon;
|
public Weapon EquippedWeapon => _equippedWeapon;
|
||||||
|
|
||||||
private ArmorInfo _equippedArmor;
|
private Armor _equippedArmor;
|
||||||
|
|
||||||
public ArmorInfo EquippedArmor => _equippedArmor;
|
public Armor EquippedArmor => _equippedArmor;
|
||||||
|
|
||||||
|
private Accessory _equippedAccessory;
|
||||||
|
|
||||||
|
public Accessory EquippedAccessory => _equippedAccessory;
|
||||||
|
|
||||||
public AutoProp<int> HPBarValue { get; }
|
public AutoProp<int> HPBarValue { get; }
|
||||||
|
|
||||||
@@ -68,11 +76,11 @@ public class GameRepo : IGameRepo
|
|||||||
|
|
||||||
public GameRepo()
|
public GameRepo()
|
||||||
{
|
{
|
||||||
_inventoryItems = new AutoProp<List<InventoryItemInfo>>([]);
|
_inventoryItems = new AutoProp<List<InventoryItem>>([]);
|
||||||
_isInventoryScreenOpened = new AutoProp<bool>(false);
|
_isInventoryScreenOpened = new AutoProp<bool>(false);
|
||||||
_isPaused = new AutoProp<bool>(false);
|
_isPaused = new AutoProp<bool>(false);
|
||||||
_playerGlobalPosition = new AutoProp<Vector3>(Vector3.Zero);
|
_playerGlobalPosition = new AutoProp<Vector3>(Vector3.Zero);
|
||||||
_equippedWeapon = WeaponInfo.Default;
|
_equippedWeapon = new Weapon();
|
||||||
HPBarValue = new AutoProp<int>(0);
|
HPBarValue = new AutoProp<int>(0);
|
||||||
VTBarValue = new AutoProp<int>(0);
|
VTBarValue = new AutoProp<int>(0);
|
||||||
}
|
}
|
||||||
@@ -91,16 +99,21 @@ public class GameRepo : IGameRepo
|
|||||||
|
|
||||||
public void SetPlayerGlobalPosition(Vector3 playerGlobalPosition) => _playerGlobalPosition.OnNext(playerGlobalPosition);
|
public void SetPlayerGlobalPosition(Vector3 playerGlobalPosition) => _playerGlobalPosition.OnNext(playerGlobalPosition);
|
||||||
|
|
||||||
public void OnWeaponEquipped(WeaponInfo equippedItem)
|
public void OnWeaponEquipped(Weapon equippedItem)
|
||||||
{
|
{
|
||||||
_equippedWeapon = equippedItem;
|
_equippedWeapon = equippedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnArmorEquipped(ArmorInfo equippedItem)
|
public void OnArmorEquipped(Armor equippedItem)
|
||||||
{
|
{
|
||||||
_equippedArmor = equippedItem;
|
_equippedArmor = equippedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnAccessoryEquipped(Accessory equippedItem)
|
||||||
|
{
|
||||||
|
_equippedAccessory = equippedItem;
|
||||||
|
}
|
||||||
|
|
||||||
public void OnGameEnded()
|
public void OnGameEnded()
|
||||||
{
|
{
|
||||||
Pause();
|
Pause();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
public interface IInventoryMenu : IControl
|
public interface IInventoryMenu : IControl
|
||||||
{
|
{
|
||||||
public void PopulateItems(List<InventoryItemInfo> items);
|
public void PopulateItems(List<InventoryItem> items);
|
||||||
|
|
||||||
public void ClearItems();
|
public void ClearItems();
|
||||||
}
|
}
|
||||||
@@ -25,11 +25,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
|
|
||||||
private int _currentSelection = 0;
|
private int _currentSelection = 0;
|
||||||
|
|
||||||
public void PopulateItems(List<InventoryItemInfo> items)
|
public void PopulateItems(List<InventoryItem> items)
|
||||||
{
|
{
|
||||||
foreach (var item in items)
|
foreach (var item in items)
|
||||||
{
|
{
|
||||||
var label = new ItemLabel(item) { Text = item.Name };
|
var label = new ItemLabel(item) { Text = item.Info.Name };
|
||||||
ItemList.AddChild(label);
|
ItemList.AddChild(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
|
|
||||||
foreach (ItemLabel item in ItemList.GetChildren())
|
foreach (ItemLabel item in ItemList.GetChildren())
|
||||||
{
|
{
|
||||||
if (item.InventoryItem == GameRepo.EquippedWeapon || item.InventoryItem == GameRepo.EquippedArmor)
|
if (item.InventoryItem == GameRepo.EquippedWeapon || item.InventoryItem == GameRepo.EquippedArmor || item.InventoryItem == GameRepo.EquippedAccessory)
|
||||||
item.EquipItem();
|
item.EquipItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,62 +110,78 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
|
|
||||||
var currentlySelectedItem = ItemList.GetChild<ItemLabel>(_currentSelection);
|
var currentlySelectedItem = ItemList.GetChild<ItemLabel>(_currentSelection);
|
||||||
|
|
||||||
if (currentlySelectedItem.InventoryItem is WeaponInfo weapon && GameRepo.EquippedWeapon == weapon)
|
if (currentlySelectedItem.InventoryItem is Weapon weapon && GameRepo.EquippedWeapon == weapon)
|
||||||
{
|
{
|
||||||
UnequipItem(currentlySelectedItem);
|
UnequipItem(currentlySelectedItem);
|
||||||
GameRepo.OnWeaponEquipped(WeaponInfo.Default);
|
GameRepo.OnWeaponEquipped(new Weapon());
|
||||||
}
|
}
|
||||||
else if (currentlySelectedItem.InventoryItem is ArmorInfo armor && GameRepo.EquippedArmor == armor)
|
else if (currentlySelectedItem.InventoryItem is Armor armor && GameRepo.EquippedArmor == armor)
|
||||||
{
|
{
|
||||||
UnequipItem(currentlySelectedItem);
|
UnequipItem(currentlySelectedItem);
|
||||||
GameRepo.OnArmorEquipped(null);
|
GameRepo.OnArmorEquipped(null);
|
||||||
}
|
}
|
||||||
|
else if (currentlySelectedItem.InventoryItem is Accessory accessory && GameRepo.EquippedAccessory == accessory)
|
||||||
|
{
|
||||||
|
UnequipItem(currentlySelectedItem);
|
||||||
|
GameRepo.OnAccessoryEquipped(null);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
EquipItem(currentlySelectedItem);
|
EquipItem(currentlySelectedItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EquipItem(ItemLabel currentItem)
|
private void EquipItem(ItemLabel currentItem) => EquipItemInternal(currentItem, (dynamic)currentItem.InventoryItem);
|
||||||
{
|
|
||||||
if (currentItem.InventoryItem is WeaponInfo weaponInfo)
|
|
||||||
{
|
|
||||||
foreach (ItemLabel item in ItemList.GetChildren())
|
|
||||||
{
|
|
||||||
if (item.InventoryItem is WeaponInfo)
|
|
||||||
UnequipItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameRepo.OnWeaponEquipped(weaponInfo);
|
|
||||||
currentItem.EquipItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (currentItem.InventoryItem is ArmorInfo armorInfo)
|
|
||||||
{
|
|
||||||
foreach (ItemLabel item in ItemList.GetChildren())
|
|
||||||
{
|
|
||||||
if (item.InventoryItem is ArmorInfo)
|
|
||||||
UnequipItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
GameRepo.OnArmorEquipped(armorInfo);
|
|
||||||
currentItem.EquipItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UnequipItem(ItemLabel item)
|
private void UnequipItem(ItemLabel item)
|
||||||
{
|
{
|
||||||
item.UnequipItem();
|
item.UnequipItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EquipItemInternal(ItemLabel currentItem, Accessory accessory)
|
||||||
|
{
|
||||||
|
foreach (ItemLabel item in ItemList.GetChildren())
|
||||||
|
{
|
||||||
|
if (item.InventoryItem is Accessory)
|
||||||
|
UnequipItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameRepo.OnAccessoryEquipped(accessory);
|
||||||
|
currentItem.EquipItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EquipItemInternal(ItemLabel currentItem, Armor armor)
|
||||||
|
{
|
||||||
|
foreach (ItemLabel item in ItemList.GetChildren())
|
||||||
|
{
|
||||||
|
if (item.InventoryItem is Armor)
|
||||||
|
UnequipItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameRepo.OnArmorEquipped(armor);
|
||||||
|
currentItem.EquipItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EquipItemInternal(ItemLabel currentItem, Weapon weapon)
|
||||||
|
{
|
||||||
|
foreach (ItemLabel item in ItemList.GetChildren())
|
||||||
|
{
|
||||||
|
if (item.InventoryItem is Weapon)
|
||||||
|
UnequipItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
GameRepo.OnWeaponEquipped(weapon);
|
||||||
|
currentItem.EquipItem();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class ItemLabel : Label
|
public partial class ItemLabel : Label
|
||||||
{
|
{
|
||||||
public ItemLabel(InventoryItemInfo inventoryItem)
|
public ItemLabel(InventoryItem inventoryItem)
|
||||||
{
|
{
|
||||||
InventoryItem = inventoryItem;
|
InventoryItem = inventoryItem;
|
||||||
LabelSettings = UnequippedItemFont;
|
LabelSettings = UnequippedItemFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryItemInfo InventoryItem { get; set; } = default!;
|
public InventoryItem InventoryItem { get; set; } = default!;
|
||||||
|
|
||||||
private static LabelSettings UnequippedItemFont => GD.Load<LabelSettings>("res://src/inventory_menu/InventoryLabelSettings.tres");
|
private static LabelSettings UnequippedItemFont => GD.Load<LabelSettings>("res://src/inventory_menu/InventoryLabelSettings.tres");
|
||||||
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/inventory_menu/EquippedInventoryLabelSettings.tres");
|
private static LabelSettings EquippedItemFont => GD.Load<LabelSettings>("res://src/inventory_menu/EquippedInventoryLabelSettings.tres");
|
||||||
|
|||||||
@@ -2,14 +2,11 @@
|
|||||||
using Chickensoft.GodotNodeInterfaces;
|
using Chickensoft.GodotNodeInterfaces;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using Godot;
|
using Godot;
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace GameJamDungeon
|
namespace GameJamDungeon
|
||||||
{
|
{
|
||||||
public interface IInventoryItem : INode3D
|
public interface IInventoryItem : INode3D
|
||||||
{
|
{
|
||||||
public abstract InventoryItemInfo InventoryInfo { get; set; }
|
|
||||||
|
|
||||||
public IGameRepo GameRepo { get; }
|
public IGameRepo GameRepo { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,10 +14,9 @@ namespace GameJamDungeon
|
|||||||
public abstract partial class InventoryItem : Node3D, IInventoryItem
|
public abstract partial class InventoryItem : Node3D, IInventoryItem
|
||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||||
|
|
||||||
public abstract InventoryItemInfo InventoryInfo { get; set; }
|
internal abstract InventoryItemInfo Info { get; set; }
|
||||||
|
|
||||||
[Node] public Area3D Pickup { get; set; } = default!;
|
[Node] public Area3D Pickup { get; set; } = default!;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
[GlobalClass]
|
[GlobalClass]
|
||||||
public partial class InventoryItemInfo : Resource
|
public partial class InventoryItemInfo : Resource
|
||||||
|
|||||||
30
src/items/accessory/Accessory.cs
Normal file
30
src/items/accessory/Accessory.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using Chickensoft.AutoInject;
|
||||||
|
using Chickensoft.Introspection;
|
||||||
|
using GameJamDungeon;
|
||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
[Meta(typeof(IAutoNode))]
|
||||||
|
public partial class Accessory : InventoryItem
|
||||||
|
{
|
||||||
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
|
public AccessoryInfo AccessoryInfo { get => (AccessoryInfo)Info; }
|
||||||
|
|
||||||
|
[Export]
|
||||||
|
internal override InventoryItemInfo Info { get; set; }
|
||||||
|
|
||||||
|
public void OnReady()
|
||||||
|
{
|
||||||
|
Pickup.BodyEntered += OnEntered;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnEntered(Node3D body)
|
||||||
|
{
|
||||||
|
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
|
||||||
|
GameRepo.InventoryItems.OnNext(inventoryList);
|
||||||
|
QueueFree();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
31
src/items/accessory/Accessory.tscn
Normal file
31
src/items/accessory/Accessory.tscn
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
[gd_scene load_steps=6 format=3 uid="uid://1bbmod6680c2"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://src/items/accessory/Accessory.cs" id="1_jq0hu"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d0yqm7ars827b" path="res://src/items/accessory/accessory.png" id="1_sfkuo"]
|
||||||
|
[ext_resource type="Script" path="res://src/items/accessory/AccessoryInfo.cs" id="2_kejmw"]
|
||||||
|
|
||||||
|
[sub_resource type="Resource" id="Resource_lu6du"]
|
||||||
|
script = ExtResource("2_kejmw")
|
||||||
|
Name = "Basic Accessory"
|
||||||
|
Description = ""
|
||||||
|
|
||||||
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_uavx4"]
|
||||||
|
radius = 0.470016
|
||||||
|
height = 0.940032
|
||||||
|
|
||||||
|
[node name="Accessory" type="Node3D"]
|
||||||
|
script = ExtResource("1_jq0hu")
|
||||||
|
Info = SubResource("Resource_lu6du")
|
||||||
|
|
||||||
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
|
billboard = 2
|
||||||
|
texture_filter = 0
|
||||||
|
texture = ExtResource("1_sfkuo")
|
||||||
|
|
||||||
|
[node name="Pickup" type="Area3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
collision_layer = 4
|
||||||
|
collision_mask = 4
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Pickup"]
|
||||||
|
shape = SubResource("CapsuleShape3D_uavx4")
|
||||||
10
src/items/accessory/AccessoryInfo.cs
Normal file
10
src/items/accessory/AccessoryInfo.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace GameJamDungeon;
|
||||||
|
|
||||||
|
[GlobalClass]
|
||||||
|
public partial class AccessoryInfo : InventoryItemInfo
|
||||||
|
{
|
||||||
|
// TODO: List all possible status effects here
|
||||||
|
}
|
||||||
BIN
src/items/accessory/accessory.png
Normal file
BIN
src/items/accessory/accessory.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
35
src/items/accessory/accessory.png.import
Normal file
35
src/items/accessory/accessory.png.import
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://d0yqm7ars827b"
|
||||||
|
path.s3tc="res://.godot/imported/accessory.png-04ec32093cb21658c9558ccc9e7c09b2.s3tc.ctex"
|
||||||
|
metadata={
|
||||||
|
"imported_formats": ["s3tc_bptc"],
|
||||||
|
"vram_texture": true
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://src/items/accessory/accessory.png"
|
||||||
|
dest_files=["res://.godot/imported/accessory.png-04ec32093cb21658c9558ccc9e7c09b2.s3tc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=2
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=true
|
||||||
|
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=0
|
||||||
@@ -10,7 +10,9 @@ public partial class Armor : InventoryItem
|
|||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public override InventoryItemInfo InventoryInfo { get; set; }
|
internal override InventoryItemInfo Info { get; set; }
|
||||||
|
|
||||||
|
public ArmorInfo ArmorInfo { get => (ArmorInfo)Info; }
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
@@ -19,7 +21,7 @@ public partial class Armor : InventoryItem
|
|||||||
|
|
||||||
public void OnEntered(Node3D body)
|
public void OnEntered(Node3D body)
|
||||||
{
|
{
|
||||||
var inventoryList = GameRepo.InventoryItems.Value.Append(InventoryInfo).ToList();
|
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
|
||||||
GameRepo.InventoryItems.OnNext(inventoryList);
|
GameRepo.InventoryItems.OnNext(inventoryList);
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
[gd_scene load_steps=6 format=3 uid="uid://dorr7v1tkeiy0"]
|
[gd_scene load_steps=5 format=3 uid="uid://dorr7v1tkeiy0"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://src/items/armor/Armor.cs" id="1_cmjpq"]
|
[ext_resource type="Script" path="res://src/items/armor/Armor.cs" id="1_cmjpq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://cgoubcl86pib4" path="res://src/items/armor/armor.png" id="1_vpnem"]
|
[ext_resource type="Texture2D" uid="uid://cgoubcl86pib4" path="res://src/items/armor/armor.png" id="1_vpnem"]
|
||||||
[ext_resource type="Script" path="res://src/items/armor/ArmorInfo.cs" id="2_cuhrp"]
|
[ext_resource type="Resource" uid="uid://chjmkb3aiomvr" path="res://src/items/armor/resources/PatheticCoat.tres" id="2_eftit"]
|
||||||
|
|
||||||
[sub_resource type="Resource" id="Resource_o1cok"]
|
|
||||||
script = ExtResource("2_cuhrp")
|
|
||||||
Defense = 2
|
|
||||||
Name = "Pathetic"
|
|
||||||
Description = "A pathetic coat."
|
|
||||||
|
|
||||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1gpxo"]
|
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_1gpxo"]
|
||||||
radius = 0.470016
|
radius = 0.470016
|
||||||
@@ -16,7 +10,7 @@ height = 0.940032
|
|||||||
|
|
||||||
[node name="Armor" type="Node3D"]
|
[node name="Armor" type="Node3D"]
|
||||||
script = ExtResource("1_cmjpq")
|
script = ExtResource("1_cmjpq")
|
||||||
InventoryInfo = SubResource("Resource_o1cok")
|
Info = ExtResource("2_eftit")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
billboard = 2
|
billboard = 2
|
||||||
|
|||||||
@@ -7,17 +7,17 @@ using System.Linq;
|
|||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class Weapon : InventoryItem
|
public partial class Weapon : InventoryItem
|
||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
|
||||||
|
|
||||||
public Weapon()
|
public Weapon()
|
||||||
{
|
{
|
||||||
_inventoryInfo = WeaponInfo.Default;
|
Info = new WeaponInfo() { Damage = 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export]
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
private WeaponInfo _inventoryInfo { get; set; }
|
|
||||||
|
|
||||||
public override InventoryItemInfo InventoryInfo { get => _inventoryInfo; set => _inventoryInfo = value as WeaponInfo; }
|
[Export]
|
||||||
|
internal override InventoryItemInfo Info { get; set; }
|
||||||
|
|
||||||
|
public WeaponInfo WeaponInfo { get => (WeaponInfo)Info; }
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
@@ -26,7 +26,7 @@ public partial class Weapon : InventoryItem
|
|||||||
|
|
||||||
public void OnEntered(Node3D body)
|
public void OnEntered(Node3D body)
|
||||||
{
|
{
|
||||||
var inventoryList = GameRepo.InventoryItems.Value.Append(InventoryInfo).ToList();
|
var inventoryList = GameRepo.InventoryItems.Value.Append(this).ToList();
|
||||||
GameRepo.InventoryItems.OnNext(inventoryList);
|
GameRepo.InventoryItems.OnNext(inventoryList);
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,4 @@ public partial class WeaponInfo : InventoryItemInfo
|
|||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public double IgneousDamageBonus { get; set; }
|
public double IgneousDamageBonus { get; set; }
|
||||||
|
|
||||||
public static WeaponInfo Default => new WeaponInfo() { Damage = 1 };
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ height = 0.940032
|
|||||||
|
|
||||||
[node name="CommonSword" type="Node3D"]
|
[node name="CommonSword" type="Node3D"]
|
||||||
script = ExtResource("1_sr3bh")
|
script = ExtResource("1_sr3bh")
|
||||||
_inventoryInfo = ExtResource("2_krjts")
|
Info = ExtResource("2_krjts")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
billboard = 2
|
billboard = 2
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ height = 0.940032
|
|||||||
|
|
||||||
[node name="RareSword" type="Node3D"]
|
[node name="RareSword" type="Node3D"]
|
||||||
script = ExtResource("1_f8v7v")
|
script = ExtResource("1_f8v7v")
|
||||||
_inventoryInfo = ExtResource("2_6nmyd")
|
Info = ExtResource("2_6nmyd")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
billboard = 2
|
billboard = 2
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ height = 0.940032
|
|||||||
|
|
||||||
[node name="UncommonSword" type="Node3D"]
|
[node name="UncommonSword" type="Node3D"]
|
||||||
script = ExtResource("1_3o4dy")
|
script = ExtResource("1_3o4dy")
|
||||||
_inventoryInfo = ExtResource("2_ga52m")
|
Info = ExtResource("2_ga52m")
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
[node name="Sprite3D" type="Sprite3D" parent="."]
|
||||||
billboard = 2
|
billboard = 2
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Chickensoft.GodotNodeInterfaces;
|
|||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using GameJamDungeon;
|
using GameJamDungeon;
|
||||||
using Godot;
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
public interface IDungeonRoom : INode3D
|
public interface IDungeonRoom : INode3D
|
||||||
{
|
{
|
||||||
@@ -59,7 +60,7 @@ public partial class DungeonRoom : Node3D, IDungeonRoom, IProvide<DungeonRoomLog
|
|||||||
var instantiatedItem = item.Instantiate<InventoryItem>();
|
var instantiatedItem = item.Instantiate<InventoryItem>();
|
||||||
instantiatedItem.Position = spawnPoint.Position;
|
instantiatedItem.Position = spawnPoint.Position;
|
||||||
AddChild(instantiatedItem);
|
AddChild(instantiatedItem);
|
||||||
GD.Print(instantiatedItem.InventoryInfo.Name);
|
GD.Print(instantiatedItem.Info.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=18 format=3 uid="uid://dhpwwqow1ahrc"]
|
[gd_scene load_steps=19 format=3 uid="uid://dhpwwqow1ahrc"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_0tfda"]
|
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_0tfda"]
|
||||||
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="1_ti7ur"]
|
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="1_ti7ur"]
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://cbb1fxllrnlyr" path="res://src/items/weapons/models/UncommonSword.tscn" id="5_viqv4"]
|
[ext_resource type="PackedScene" uid="uid://cbb1fxllrnlyr" path="res://src/items/weapons/models/UncommonSword.tscn" id="5_viqv4"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c10nhqq8su6pp" path="res://src/items/weapons/models/RareSword.tscn" id="6_c8gn4"]
|
[ext_resource type="PackedScene" uid="uid://c10nhqq8su6pp" path="res://src/items/weapons/models/RareSword.tscn" id="6_c8gn4"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dorr7v1tkeiy0" path="res://src/items/armor/Armor.tscn" id="7_bm50w"]
|
[ext_resource type="PackedScene" uid="uid://dorr7v1tkeiy0" path="res://src/items/armor/Armor.tscn" id="7_bm50w"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://1bbmod6680c2" path="res://src/items/accessory/Accessory.tscn" id="8_1psf1"]
|
||||||
[ext_resource type="PackedScene" uid="uid://d4l4qutp8x40c" path="res://src/npc/goddess/Goddess.tscn" id="10_82rsb"]
|
[ext_resource type="PackedScene" uid="uid://d4l4qutp8x40c" path="res://src/npc/goddess/Goddess.tscn" id="10_82rsb"]
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_luhnj"]
|
[sub_resource type="PlaneMesh" id="PlaneMesh_luhnj"]
|
||||||
@@ -65,8 +66,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.053, -3, 0)
|
|||||||
|
|
||||||
[node name="ItemDatabase" parent="." instance=ExtResource("4_2mnb7")]
|
[node name="ItemDatabase" parent="." instance=ExtResource("4_2mnb7")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
ItemScene = Array[PackedScene]([ExtResource("7_bm50w"), ExtResource("4_chdi8"), ExtResource("5_viqv4"), ExtResource("6_c8gn4")])
|
ItemScene = Array[PackedScene]([ExtResource("7_bm50w"), ExtResource("4_chdi8"), ExtResource("5_viqv4"), ExtResource("6_c8gn4"), ExtResource("8_1psf1")])
|
||||||
DropRate = PackedFloat32Array(0.25, 0.25, 0.25, 0.25)
|
DropRate = PackedFloat32Array(0.25, 0.25, 0.25, 0.25, 0.25)
|
||||||
|
|
||||||
[node name="EnemyDatabase" parent="." instance=ExtResource("5_owpbq")]
|
[node name="EnemyDatabase" parent="." instance=ExtResource("5_owpbq")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=18 format=3 uid="uid://bbwgmqy3evhh2"]
|
[gd_scene load_steps=19 format=3 uid="uid://bbwgmqy3evhh2"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_o02dd"]
|
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_o02dd"]
|
||||||
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="2_jrlll"]
|
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="2_jrlll"]
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://dbvr8ewajja6a" path="res://src/enemy/EnemyDatabase.tscn" id="5_fabiq"]
|
[ext_resource type="PackedScene" uid="uid://dbvr8ewajja6a" path="res://src/enemy/EnemyDatabase.tscn" id="5_fabiq"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cbb1fxllrnlyr" path="res://src/items/weapons/models/UncommonSword.tscn" id="6_hb3sb"]
|
[ext_resource type="PackedScene" uid="uid://cbb1fxllrnlyr" path="res://src/items/weapons/models/UncommonSword.tscn" id="6_hb3sb"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c10nhqq8su6pp" path="res://src/items/weapons/models/RareSword.tscn" id="7_c5lye"]
|
[ext_resource type="PackedScene" uid="uid://c10nhqq8su6pp" path="res://src/items/weapons/models/RareSword.tscn" id="7_c5lye"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://1bbmod6680c2" path="res://src/items/accessory/Accessory.tscn" id="8_1fvbo"]
|
||||||
|
|
||||||
[sub_resource type="PlaneMesh" id="PlaneMesh_j8q3j"]
|
[sub_resource type="PlaneMesh" id="PlaneMesh_j8q3j"]
|
||||||
size = Vector2(50, 10)
|
size = Vector2(50, 10)
|
||||||
@@ -80,8 +81,8 @@ mesh = SubResource("PlaneMesh_j8q3j")
|
|||||||
|
|
||||||
[node name="ItemDatabase" parent="." instance=ExtResource("4_c51bx")]
|
[node name="ItemDatabase" parent="." instance=ExtResource("4_c51bx")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
ItemScene = Array[PackedScene]([ExtResource("4_2bf0o"), ExtResource("4_wqpwj"), ExtResource("6_hb3sb"), ExtResource("7_c5lye")])
|
ItemScene = Array[PackedScene]([ExtResource("4_2bf0o"), ExtResource("4_wqpwj"), ExtResource("6_hb3sb"), ExtResource("7_c5lye"), ExtResource("8_1fvbo")])
|
||||||
DropRate = PackedFloat32Array(0.25, 0.25, 0.25, 0.25)
|
DropRate = PackedFloat32Array(0.25, 0.25, 0.25, 0.25, 0.25)
|
||||||
|
|
||||||
[node name="EnemyDatabase" parent="." instance=ExtResource("5_fabiq")]
|
[node name="EnemyDatabase" parent="." instance=ExtResource("5_fabiq")]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace GameJamDungeon
|
|||||||
|
|
||||||
[Node] public IArea3D CollisionDetector { get; set; } = default!;
|
[Node] public IArea3D CollisionDetector { get; set; } = default!;
|
||||||
|
|
||||||
private IAutoProp<WeaponInfo> EquippedWeapon { get; set; } = default!;
|
private IAutoProp<Weapon> EquippedWeapon { get; set; } = default!;
|
||||||
|
|
||||||
private AutoProp<double> _currentHP { get; set; } = default!;
|
private AutoProp<double> _currentHP { get; set; } = default!;
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ namespace GameJamDungeon
|
|||||||
GameRepo.SetPlayerGlobalPosition(GlobalPosition);
|
GameRepo.SetPlayerGlobalPosition(GlobalPosition);
|
||||||
GameRepo.PlayerGlobalPosition.Sync += OnPlayerPositionUpdated;
|
GameRepo.PlayerGlobalPosition.Sync += OnPlayerPositionUpdated;
|
||||||
|
|
||||||
EquippedWeapon = new AutoProp<WeaponInfo>(WeaponInfo.Default);
|
EquippedWeapon = new AutoProp<Weapon>(new Weapon());
|
||||||
EquippedWeapon.Sync += OnEquippedWeaponChanged;
|
EquippedWeapon.Sync += OnEquippedWeaponChanged;
|
||||||
|
|
||||||
_currentHP = new AutoProp<double>(PlayerStatInfo.MaximumHP);
|
_currentHP = new AutoProp<double>(PlayerStatInfo.MaximumHP);
|
||||||
@@ -209,7 +209,7 @@ namespace GameJamDungeon
|
|||||||
AnimationPlayer.AnimationFinished -= OnAnimationFinished;
|
AnimationPlayer.AnimationFinished -= OnAnimationFinished;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEquippedWeaponChanged(WeaponInfo info) => Hitbox.Damage = info.Damage;
|
private void OnEquippedWeaponChanged(Weapon info) => Hitbox.Damage = info.WeaponInfo.Damage;
|
||||||
|
|
||||||
private void OnHPChanged(double newHP)
|
private void OnHPChanged(double newHP)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,27 +4,27 @@ namespace GameJamDungeon
|
|||||||
{
|
{
|
||||||
public static class DamageCalculator
|
public static class DamageCalculator
|
||||||
{
|
{
|
||||||
public static double CalculatePlayerDamage(int attackDamage, PlayerStatInfo playerStatInfo, EnemyStatInfo enemyStatInfo, WeaponInfo weapon)
|
public static double CalculatePlayerDamage(int attackDamage, PlayerStatInfo playerStatInfo, EnemyStatInfo enemyStatInfo, Weapon weapon)
|
||||||
{
|
{
|
||||||
var baseDamage = attackDamage + playerStatInfo.BaseAttack;
|
var baseDamage = attackDamage + playerStatInfo.BaseAttack;
|
||||||
var elementADamage = (weapon.BaseHydricDamageBonus > 0 ? weapon.BaseHydricDamageBonus - enemyStatInfo.HydricResistance : 0) / 100;
|
var elementADamage = (weapon.WeaponInfo.BaseHydricDamageBonus > 0 ? weapon.WeaponInfo.BaseHydricDamageBonus - enemyStatInfo.HydricResistance : 0) / 100;
|
||||||
var elementBDamage = (weapon.IgneousDamageBonus > 0 ? weapon.IgneousDamageBonus - enemyStatInfo.IgneousResistance : 0) / 100;
|
var elementBDamage = (weapon.WeaponInfo.IgneousDamageBonus > 0 ? weapon.WeaponInfo.IgneousDamageBonus - enemyStatInfo.IgneousResistance : 0) / 100;
|
||||||
var elementCDamage = (weapon.TelluricDamageBonus > 0 ? weapon.TelluricDamageBonus - enemyStatInfo.TelluricResistance : 0) / 100;
|
var elementCDamage = (weapon.WeaponInfo.TelluricDamageBonus > 0 ? weapon.WeaponInfo.TelluricDamageBonus - enemyStatInfo.TelluricResistance : 0) / 100;
|
||||||
var elementDDamage = (weapon.AeolicDamageBonus > 0 ? weapon.AeolicDamageBonus - enemyStatInfo.AeolicResistance : 0) / 100;
|
var elementDDamage = (weapon.WeaponInfo.AeolicDamageBonus > 0 ? weapon.WeaponInfo.AeolicDamageBonus - enemyStatInfo.AeolicResistance : 0) / 100;
|
||||||
var elementalBonusDamage = baseDamage + (baseDamage * elementADamage) + (baseDamage * elementBDamage) + (baseDamage * elementCDamage) + (baseDamage * elementDDamage);
|
var elementalBonusDamage = baseDamage + (baseDamage * elementADamage) + (baseDamage * elementBDamage) + (baseDamage * elementCDamage) + (baseDamage * elementDDamage);
|
||||||
var calculatedDamage = elementalBonusDamage - enemyStatInfo.BaseDefense;
|
var calculatedDamage = elementalBonusDamage - enemyStatInfo.BaseDefense;
|
||||||
return calculatedDamage;
|
return calculatedDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double CalculateEnemyDamage(int attackDamage, PlayerStatInfo playerStatInfo, EnemyStatInfo enemyStatInfo, ArmorInfo armor)
|
public static double CalculateEnemyDamage(int attackDamage, PlayerStatInfo playerStatInfo, EnemyStatInfo enemyStatInfo, Armor armor)
|
||||||
{
|
{
|
||||||
var baseDamage = attackDamage + enemyStatInfo.BaseAttack;
|
var baseDamage = attackDamage + enemyStatInfo.BaseAttack;
|
||||||
var elementADamage = (enemyStatInfo.BaseHydricDamageBonus > 0 ? enemyStatInfo.BaseHydricDamageBonus - armor.HydricResistance : 0) / 100;
|
var elementADamage = (enemyStatInfo.BaseHydricDamageBonus > 0 ? enemyStatInfo.BaseHydricDamageBonus - armor.ArmorInfo.HydricResistance : 0) / 100;
|
||||||
var elementBDamage = (enemyStatInfo.IgneousDamageBonus > 0 ? enemyStatInfo.IgneousDamageBonus - armor.IgneousResistance : 0) / 100;
|
var elementBDamage = (enemyStatInfo.IgneousDamageBonus > 0 ? enemyStatInfo.IgneousDamageBonus - armor.ArmorInfo.IgneousResistance : 0) / 100;
|
||||||
var elementCDamage = (enemyStatInfo.TelluricDamageBonus > 0 ? enemyStatInfo.TelluricDamageBonus - armor.TelluricResistance : 0) / 100;
|
var elementCDamage = (enemyStatInfo.TelluricDamageBonus > 0 ? enemyStatInfo.TelluricDamageBonus - armor.ArmorInfo.TelluricResistance : 0) / 100;
|
||||||
var elementDDamage = (enemyStatInfo.AeolicDamageBonus > 0 ? enemyStatInfo.AeolicDamageBonus - armor.AeolicResistance : 0) / 100;
|
var elementDDamage = (enemyStatInfo.AeolicDamageBonus > 0 ? enemyStatInfo.AeolicDamageBonus - armor.ArmorInfo.AeolicResistance : 0) / 100;
|
||||||
var elementalBonusDamage = baseDamage + (baseDamage * elementADamage) + (baseDamage * elementBDamage) + (baseDamage * elementCDamage) + (baseDamage * elementDDamage);
|
var elementalBonusDamage = baseDamage + (baseDamage * elementADamage) + (baseDamage * elementBDamage) + (baseDamage * elementCDamage) + (baseDamage * elementDDamage);
|
||||||
var calculatedDamage = elementalBonusDamage - playerStatInfo.BaseDefense - armor.Defense;
|
var calculatedDamage = elementalBonusDamage - playerStatInfo.BaseDefense - (armor != null ? armor.ArmorInfo.Defense : 0);
|
||||||
return calculatedDamage;
|
return calculatedDamage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user