Compare commits

...

7 Commits

Author SHA1 Message Date
Pal
7e56202e76 Merge branch 'main' of https://git.zenny.quest/zenayi/GameJamDungeon 2026-02-15 03:04:47 -08:00
Pal
fc04a93f58 Pixel Art Resizes Added + fix of 2 3D render icons 2026-02-15 03:04:42 -08:00
fa66ba24e2 Small inventory fixes 2026-02-15 02:58:10 -08:00
9c4c82af68 All items have an image 2026-02-15 02:56:26 -08:00
fe502debd1 Fix inventory sizes 2026-02-15 02:33:09 -08:00
33a58a2893 Fix box issue 2026-02-15 02:24:14 -08:00
69b25aacb9 Overhaul item and inventory and clean up bits and pieces 2026-02-15 01:19:27 -08:00
366 changed files with 4523 additions and 2391 deletions

View File

@@ -5,21 +5,21 @@ using Zennysoft.Ma.Adapter.Entity;
namespace Zennysoft.Ma.Adapter;
public interface IEquipmentComponent : IEntityComponent
{
public IAutoProp<EquipableItem> EquippedWeapon { get; }
public IAutoProp<IWeapon> EquippedWeapon { get; }
public IAutoProp<EquipableItem> EquippedArmor { get; }
public IAutoProp<IArmor> EquippedArmor { get; }
public IAutoProp<EquipableItem> EquippedAccessory { get; }
public IAutoProp<IAccessory> EquippedAccessory { get; }
public IAutoProp<EquipableItem> EquippedAmmo { get; }
public IAutoProp<IEquipableItem> EquippedAmmo { get; }
public void Equip(EquipableItem equipable);
public void Equip(IEquipableItem equipable);
public void Unequip(EquipableItem equipable);
public void Unequip(IEquipableItem equipable);
public bool IsItemEquipped(InventoryItem item);
public bool IsItemEquipped(IEquipableItem item);
public void UpdateEquipment(EquipableItem equipable);
public void UpdateEquipment(IEquipableItem equipable);
public bool AugmentableEquipmentExists();
@@ -35,5 +35,5 @@ public interface IEquipmentComponent : IEntityComponent
public ElementalResistanceSet ElementalResistance { get; }
public event Action<EquipableItem> EquipmentChanged;
public event Action<IEquipableItem> EquipmentChanged;
}

View File

@@ -16,6 +16,8 @@ public interface IExperiencePointsComponent : IEntityComponent
public void Gain(int baseExpGain);
public void GainUnmodified(int flateRateExpGain);
public void LevelUp();
public event Action PlayerLevelUp;

View File

@@ -13,13 +13,6 @@ public class Augment
public IAugmentType AugmentType { get; set; }
}
public interface IAugmentType
{
void Apply();
void Remove();
}
public class HPRecoverySpeedAugment : IAugmentType
{
private readonly IPlayer _player;

View File

@@ -1,28 +0,0 @@
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Zennysoft.Ma.Adapter.Entity;
namespace Zennysoft.Ma.Adapter;
[Meta, Id("equipable_item")]
public abstract partial class EquipableItem : InventoryItem
{
[Save("bonus_attack_stats")]
public virtual int BonusAttack { get; }
[Save("bonus_defense_stats")]
public virtual int BonusDefense { get; }
[Save("bonus_hp_stats")]
public virtual int BonusHP { get; }
[Save("bonus_vt_stats")]
public virtual int BonusVT { get; }
[Save("bonus_luck_stats")]
public virtual int BonusLuck { get; }
[Save("equipment_is_glued")]
public bool Glued { get; set; }
public virtual Augment? Augment { get; set; }
[Save("bonus_elemental_resist_stats")]
public virtual ElementalResistanceSet ElementalResistance { get; } = new ElementalResistanceSet(0, 0, 0, 0, 0, 0, 0);
}

View File

@@ -0,0 +1,6 @@
public interface IAugmentType
{
void Apply();
void Remove();
}

View File

@@ -1,26 +0,0 @@
using Chickensoft.Introspection;
using Chickensoft.Serialization;
using Godot;
namespace Zennysoft.Ma.Adapter;
[Meta, Id("inventory_item")]
public abstract partial class InventoryItem : Node3D
{
[Save("inventory_item_id")]
public Guid ID => Guid.NewGuid();
[Save("inventory_item_name")]
public abstract string ItemName { get; }
[Save("inventory_item_description")]
public abstract string Description { get; }
[Save("inventory_item_spawn_rate")]
public abstract float SpawnRate { get; }
[Save("inventory_item_throw_damage")]
public abstract int ThrowDamage { get; }
[Save("inventory_item_throw_speed")]
public abstract float ThrowSpeed { get; }
[Save("inventory_item_tag")]
public abstract ItemTag ItemTag { get; }
public abstract Texture2D GetTexture();
}

View File

@@ -20,7 +20,7 @@ public interface IGameRepo : IDisposable
event Action? DoubleExpTimeEnd;
event Action<InventoryItem>? RemoveItemFromInventoryEvent;
event Action<IBaseInventoryItem>? RemoveItemFromInventoryEvent;
event Action? PlayerAttack;
@@ -28,9 +28,9 @@ public interface IGameRepo : IDisposable
event Action? PlayerAttackedEnemy;
event Action<EquipableItem>? EquippedItem;
event Action<IEquipableItem>? EquippedItem;
event Action<EquipableItem>? UnequippedItem;
event Action<IEquipableItem>? UnequippedItem;
event Action<IEnemy>? EnemyDied;
@@ -48,7 +48,7 @@ public interface IGameRepo : IDisposable
public void AnnounceMessageInInventory(string message);
public void RemoveItemFromInventory(InventoryItem item);
public void RemoveItemFromInventory(IBaseInventoryItem item);
public void OnPlayerAttack();
@@ -58,9 +58,9 @@ public interface IGameRepo : IDisposable
public void GameEnded();
public void OnEquippedItem(EquipableItem item);
public void OnEquippedItem(IEquipableItem item);
public void OnUnequippedItem(EquipableItem item);
public void OnUnequippedItem(IEquipableItem item);
public void OnEnemyDied(IEnemy enemy);
@@ -75,12 +75,12 @@ public class GameRepo : IGameRepo
public event Action<string>? AnnounceMessageInInventoryEvent;
public event Action<int>? DoubleExpTimeStart;
public event Action? DoubleExpTimeEnd;
public event Action<InventoryItem>? RemoveItemFromInventoryEvent;
public event Action<IBaseInventoryItem>? RemoveItemFromInventoryEvent;
public event Action? PlayerAttack;
public event Action? PlayerAttackedWall;
public event Action? PlayerAttackedEnemy;
public event Action<EquipableItem>? EquippedItem;
public event Action<EquipableItem>? UnequippedItem;
public event Action<IEquipableItem>? EquippedItem;
public event Action<IEquipableItem>? UnequippedItem;
public event Action<IEnemy>? EnemyDied;
public IAutoProp<bool> IsPaused => _isPaused;
private readonly AutoProp<bool> _isPaused;
@@ -131,7 +131,7 @@ public class GameRepo : IGameRepo
AnnounceMessageInInventoryEvent?.Invoke(message);
}
public void RemoveItemFromInventory(InventoryItem item)
public void RemoveItemFromInventory(IBaseInventoryItem item)
{
RemoveItemFromInventoryEvent?.Invoke(item);
}
@@ -151,9 +151,9 @@ public class GameRepo : IGameRepo
CloseInventoryEvent?.Invoke();
}
public void OnEquippedItem(EquipableItem item) => EquippedItem?.Invoke(item);
public void OnEquippedItem(IEquipableItem item) => EquippedItem?.Invoke(item);
public void OnUnequippedItem(EquipableItem item) => UnequippedItem?.Invoke(item);
public void OnUnequippedItem(IEquipableItem item) => UnequippedItem?.Invoke(item);
public void OnEnemyDied(IEnemy enemy) => EnemyDied?.Invoke(enemy);

View File

@@ -0,0 +1,5 @@
using Zennysoft.Ma.Adapter;
public interface IAccessory : IEquipableItem, IAugmentableItem
{
}

View File

@@ -0,0 +1,5 @@
using Zennysoft.Ma.Adapter;
public interface IArmor : IEquipableItem, IAugmentableItem
{
}

View File

@@ -1,7 +1,5 @@
namespace Zennysoft.Ma.Adapter
public interface IAugmentItem : IBaseInventoryItem
{
public interface IAugmentItem
{
public JewelTags Augment { get; }
}
public IAugmentType Augment { get; }
}

View File

@@ -0,0 +1,7 @@
namespace Zennysoft.Ma.Adapter
{
public interface IAugmentableItem
{
public Augment? Augment { get; }
}
}

View File

@@ -0,0 +1,15 @@
using Godot;
using Zennysoft.Ma.Adapter;
public interface IBaseInventoryItem
{
public string ItemName { get; }
public string Description { get; }
public float SpawnRate { get; }
public int ThrowDamage { get; }
public float ThrowSpeed { get; }
public ItemTag ItemTag { get; }
public abstract Texture2D GetTexture();
}

View File

@@ -4,6 +4,6 @@
{
void RescueItem();
public InventoryItem Item { get; }
public IBaseInventoryItem Item { get; }
}
}

View File

@@ -0,0 +1,14 @@
using Zennysoft.Ma.Adapter.Entity;
public interface IEquipableItem : IBaseInventoryItem
{
public int BonusAttack { get; }
public int BonusDefense { get; }
public int BonusHP { get; }
public int BonusVT { get; }
public int BonusLuck { get; }
public bool Glued { get; set; }
public ElementalResistanceSet ElementalResistance { get; }
}

View File

@@ -2,17 +2,17 @@
public interface IInventory
{
public bool PickUpItem(InventoryItem item);
public bool PickUpItem(IBaseInventoryItem item);
public List<InventoryItem> Items { get; }
public List<IBaseInventoryItem> Items { get; }
public bool TryAdd(InventoryItem inventoryItem);
public bool TryAdd(IBaseInventoryItem inventoryItem);
public bool TryInsert(InventoryItem inventoryItem, int index);
public bool TryInsert(IBaseInventoryItem inventoryItem, int index);
public void Remove(InventoryItem inventoryItem);
public void Remove(IBaseInventoryItem inventoryItem);
public bool Sort(EquipableItem currentWeapon, EquipableItem currentArmor, EquipableItem currentAccessory, EquipableItem ammo);
public bool Sort(IWeapon currentWeapon, IArmor currentArmor, IAccessory currentAccessory, IEquipableItem ammo);
public bool AtCapacity();

View File

@@ -2,5 +2,5 @@
public interface IThrownItem
{
public InventoryItem ItemThatIsThrown { get; set; }
public IBaseInventoryItem ItemThatIsThrown { get; set; }
}

View File

@@ -0,0 +1,5 @@
using Zennysoft.Ma.Adapter;
public interface IWeapon : IEquipableItem, IAugmentableItem
{
}

View File

@@ -7,10 +7,10 @@ namespace Zennysoft.Ma.Adapter;
public partial class RescuedItemDatabase
{
[Save("rescued_item_list")]
public List<InventoryItem> Items { get; init; }
public List<IBaseInventoryItem> Items { get; init; }
public RescuedItemDatabase()
{
Items = new List<InventoryItem>();
Items = new List<IBaseInventoryItem>();
}
}

View File

@@ -20,15 +20,15 @@ public interface IPlayer : IKillable, ICharacterBody3D
public void TeleportPlayer((Vector3 Rotation, Vector3 Position) newTransform);
public void Equip(EquipableItem equipable);
public void Equip(IEquipableItem equipable);
public void Unequip(EquipableItem equipable);
public void Unequip(IEquipableItem equipable);
public void PlayJumpScareAnimation();
public void ApplyNewAugment(IAugmentItem jewel, EquipableItem equipableItem);
public void ApplyNewAugment(IAugmentItem jewel, IAugmentableItem equipableItem);
public void IdentifyItem(InventoryItem unidentifiedItem);
public void IdentifyItem(IBaseInventoryItem unidentifiedItem);
public IInventory Inventory { get; }
@@ -63,5 +63,5 @@ public interface IPlayer : IKillable, ICharacterBody3D
public bool AutoIdentifyItems { get; set; }
public event Action PlayerDied;
public delegate InventoryItem RerollItem(InventoryItem item);
public delegate IBaseInventoryItem RerollItem(IBaseInventoryItem item);
}

View File

@@ -38,7 +38,7 @@ public partial class InGameUILogic
Output(new Output.AnnounceMessageInInventory(message));
}
private void OnRemoveItemFromInventory(InventoryItem item) => Output(new Output.RemoveItemFromInventory(item));
private void OnRemoveItemFromInventory(IBaseInventoryItem item) => Output(new Output.RemoveItemFromInventory(item));
}
}

View File

@@ -8,7 +8,7 @@ public partial class InGameUILogic
{
public readonly record struct AnnounceMessageOnMainScreen(string Message);
public readonly record struct AnnounceMessageInInventory(string Message);
public readonly record struct RemoveItemFromInventory(InventoryItem Item);
public readonly record struct RemoveItemFromInventory(IBaseInventoryItem Item);
public readonly record struct ShowInventory;
public readonly record struct HideInventory;
}

View File

@@ -6,23 +6,23 @@ using Zennysoft.Ma.Adapter.Entity;
namespace Zennysoft.Game.Ma;
public class EquipmentComponent : IEquipmentComponent
{
public IAutoProp<EquipableItem> EquippedWeapon => _equippedWeapon;
public IAutoProp<IWeapon> EquippedWeapon => _equippedWeapon;
public IAutoProp<EquipableItem> EquippedArmor => _equippedArmor;
public IAutoProp<IArmor> EquippedArmor => _equippedArmor;
public IAutoProp<EquipableItem> EquippedAccessory => _equippedAccessory;
public IAutoProp<IAccessory> EquippedAccessory => _equippedAccessory;
public IAutoProp<EquipableItem> EquippedAmmo => _equippedAmmo;
public IAutoProp<IEquipableItem> EquippedAmmo => _equippedAmmo;
public AutoProp<EquipableItem> _equippedWeapon;
public AutoProp<IWeapon> _equippedWeapon;
public AutoProp<EquipableItem> _equippedArmor;
public AutoProp<IArmor> _equippedArmor;
public AutoProp<EquipableItem> _equippedAccessory;
public AutoProp<IAccessory> _equippedAccessory;
public AutoProp<EquipableItem> _equippedAmmo;
public AutoProp<IEquipableItem> _equippedAmmo;
public event Action<EquipableItem> EquipmentChanged;
public event Action<IEquipableItem> EquipmentChanged;
public int BonusAttack => _equippedWeapon.Value.BonusAttack + _equippedArmor.Value.BonusAttack + _equippedAccessory.Value.BonusAttack;
@@ -38,10 +38,10 @@ public class EquipmentComponent : IEquipmentComponent
public EquipmentComponent()
{
_equippedWeapon = new AutoProp<EquipableItem>(new Weapon());
_equippedArmor = new AutoProp<EquipableItem>(new Armor());
_equippedAccessory = new AutoProp<EquipableItem>(new Accessory());
_equippedAmmo = new AutoProp<EquipableItem>(new Ammo());
_equippedWeapon = new AutoProp<IWeapon>(new Weapon());
_equippedArmor = new AutoProp<IArmor>(new Armor());
_equippedAccessory = new AutoProp<IAccessory>(new Accessory());
_equippedAmmo = new AutoProp<IEquipableItem>(new Ammo());
}
public void Reset()
@@ -52,7 +52,7 @@ public class EquipmentComponent : IEquipmentComponent
_equippedAmmo.OnNext(new Ammo());
}
public void Equip(EquipableItem equipable)
public void Equip(IEquipableItem equipable)
{
if (equipable is Weapon weapon)
_equippedWeapon.OnNext(weapon);
@@ -65,7 +65,7 @@ public class EquipmentComponent : IEquipmentComponent
EquipmentChanged?.Invoke(equipable);
}
public void Unequip(EquipableItem equipable)
public void Unequip(IEquipableItem equipable)
{
if (equipable is Weapon weapon)
_equippedWeapon.OnNext(new Weapon());
@@ -78,15 +78,12 @@ public class EquipmentComponent : IEquipmentComponent
EquipmentChanged?.Invoke(equipable);
}
public bool IsItemEquipped(InventoryItem item)
public bool IsItemEquipped(IEquipableItem item)
{
if (item is not EquipableItem)
return false;
return item == _equippedWeapon.Value || item == _equippedArmor.Value || item == _equippedAccessory.Value || item == _equippedAmmo.Value;
}
public void UpdateEquipment(EquipableItem equipable) => EquipmentChanged?.Invoke(equipable);
public void UpdateEquipment(IEquipableItem equipable) => EquipmentChanged?.Invoke(equipable);
public bool AugmentableEquipmentExists()
{

View File

@@ -51,6 +51,16 @@ public class ExperiencePointsComponent : IExperiencePointsComponent
var cappedAmount = Math.Min(baseExpGain + _currentExp.Value, _expToNextLevel.Value);
_currentExp.OnNext(cappedAmount);
}
public void GainUnmodified(int flatRateExp)
{
var newCurrentExpTotal = flatRateExp + _currentExp.Value;
while (flatRateExp + _currentExp.Value >= _expToNextLevel.Value)
LevelUp();
var cappedAmount = Math.Min(flatRateExp + _currentExp.Value, _expToNextLevel.Value);
_currentExp.OnNext(cappedAmount);
}
public void ModifyExpGainRate(double newRate) => _expGainRate.OnNext(newRate);
public void LevelUp()

View File

@@ -146,7 +146,7 @@ public partial class App : Node, IApp
})
.Handle((in AppLogic.Output.SetupGameScene _) =>
{
LoadingScreen.Show();
LoadingScreen.ShowLoadingScreen();
LoadGame(GAME_SCENE_PATH);
})
.Handle((in AppLogic.Output.ShowMainMenu _) =>
@@ -155,7 +155,7 @@ public partial class App : Node, IApp
})
.Handle((in AppLogic.Output.CloseGame _) =>
{
LoadingScreen.Hide();
LoadingScreen.HideLoadingScreen();
_game.GameExitRequested -= GameExitRequested;
MainMenu.StartGameButton.GrabFocus();
_game.CallDeferred(MethodName.QueueFree, []);
@@ -166,13 +166,13 @@ public partial class App : Node, IApp
})
.Handle((in AppLogic.Output.EnemyViewerOpened _) =>
{
LoadingScreen.Show();
LoadingScreen.ShowLoadingScreen();
MainMenu.Hide();
LoadEnemyViewer(ENEMY_VIEWER_PATH);
})
.Handle((in AppLogic.Output.EnemyViewerExited _) =>
{
LoadingScreen.Hide();
LoadingScreen.HideLoadingScreen();
if (_enemyViewer != null && _enemyViewer is DataViewer enemyViewer)
enemyViewer.CallDeferred(MethodName.QueueFree);
MainMenu.Show();
@@ -203,24 +203,22 @@ public partial class App : Node, IApp
_game = scene as IGame;
_game.GameLoaded += OnGameLoaded;
_game.GameExitRequested += GameExitRequested;
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
CallDeferred(MethodName.AddChild, scene);
}
private void OnGameLoaded() => LoadingScreen.Hide();
private void OnGameLoaded() => LoadingScreen.HideLoadingScreen();
private async void LoadEnemyViewer(string sceneName)
{
var scene = await LoadSceneInternal(sceneName);
_enemyViewer = scene as IDataViewer;
await ToSignal(GetTree().CreateTimer(0.8f), "timeout");
CallDeferred(MethodName.AddChild, scene);
LoadingScreen.Hide();
LoadingScreen.HideLoadingScreen();
}
private async Task<Node> LoadSceneInternal(string sceneName)
{
LoadingScreen.Show();
LoadingScreen.ShowLoadingScreen();
LoadingScreen.ProgressBar.Value = 0;
var sceneLoader = new SceneLoader();
CallDeferred(MethodName.AddChild, sceneLoader);

View File

@@ -10,9 +10,16 @@
process_mode = 3
script = ExtResource("1_rt73h")
[node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 1)
[node name="MainMenu" parent="." instance=ExtResource("2_1uiag")]
unique_name_in_owner = true
visible = false
[node name="OptionsMenu" parent="." instance=ExtResource("2_v0mgf")]
unique_name_in_owner = true
@@ -24,5 +31,6 @@ visible = false
[node name="LoadingScreen" parent="." instance=ExtResource("3_3st5l")]
unique_name_in_owner = true
visible = false
top_level = true
z_index = 999

View File

@@ -39,6 +39,7 @@ bus = &"SFX"
[node name="MoveSound" type="AudioStreamPlayer" parent="UI"]
unique_name_in_owner = true
stream = ExtResource("6_r16t0")
max_polyphony = 5
bus = &"SFX"
[node name="SelectSound" type="AudioStreamPlayer" parent="UI"]

View File

@@ -109,7 +109,6 @@ _acquireTargetTime = 2.0
unique_name_in_owner = true
avoidance_enabled = true
radius = 1.0
debug_enabled = true
[node name="SFX" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.0617, 0)

View File

@@ -7,7 +7,6 @@ using Chickensoft.SaveFileBuilder;
using Godot;
using System;
using System.Text.Json;
using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Adapter;
using System.IO;
using System.Threading.Tasks;
@@ -158,9 +157,7 @@ public partial class Game : Node3D, IGame
GameState.Set(_player);
GameState.Set(_map);
GameState.Set(InGameUI);
GameRepo.Resume();
InGameUI.Show();
HandleGameLogic();
GameState.Start();
this.Provide();
@@ -189,6 +186,8 @@ public partial class Game : Node3D, IGame
GameRepo.IsPaused.Sync += IsPaused_Sync;
InGameUI.PlayerInfoUI.Activate();
InGameUI.Show();
GameRepo.Resume();
}
private void GameRepo_EnemyDied(IEnemy obj)
@@ -210,14 +209,13 @@ public partial class Game : Node3D, IGame
_effectService = new EffectService(this, _player, _map);
_player.Activate();
await _map.LoadFloor();
GameLoaded?.Invoke();
}
public async Task Save() => await SaveFile.Save();
public void FloorExitReached() => GameState.Input(new GameState.Input.FloorExitEntered());
public async Task UseItem(InventoryItem item)
public async Task UseItem(IBaseInventoryItem item)
{
if (item.ItemTag == ItemTag.MysteryItem)
_effectService.RerollItem(item);
@@ -234,13 +232,10 @@ public partial class Game : Node3D, IGame
EnactEffectItemEffects(effectItem);
break;
}
await ToSignal(GetTree().CreateTimer(0.3f), "timeout");
RemoveItemOrSubtractFromItemCount(item);
}
public void DropItem(InventoryItem item)
public void DropItem(IBaseInventoryItem item)
{
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
var dropped = droppedScene.Instantiate<DroppedItem>();
@@ -250,7 +245,7 @@ public partial class Game : Node3D, IGame
_player.Inventory.Remove(item);
}
public void SetItem(InventoryItem item)
public void SetItem(IBaseInventoryItem item)
{
var setScene = GD.Load<PackedScene>("res://src/items/misc/SetItem.tscn");
var setItem = setScene.Instantiate<SetItem>();
@@ -259,7 +254,7 @@ public partial class Game : Node3D, IGame
_player.Inventory.Remove(item);
}
public void ThrowItem(InventoryItem item)
public void ThrowItem(IBaseInventoryItem item)
{
var thrownScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
var thrown = thrownScene.Instantiate<ThrownItem>();
@@ -399,7 +394,10 @@ public partial class Game : Node3D, IGame
InGameUI.InventoryMenu.SetProcessInput(false);
}
private async void LoadLevel() => await _map.LoadFloor();
private async void LoadLevel()
{
await _map.LoadFloor();
}
private void FloorClearMenu_GoToNextFloor() => GameState.Input(new GameState.Input.LoadNextFloor());
@@ -420,7 +418,6 @@ public partial class Game : Node3D, IGame
private void UseTeleportPrompt_TeleportToNextFloor()
{
//_player.LookUp();
GameState.Input(new GameState.Input.UseTeleport());
}
@@ -459,10 +456,10 @@ public partial class Game : Node3D, IGame
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<ConsumableItem>());
break;
case ItemTag.DropTo1HPAndGainRareItem:
_effectService.DropTo1HPAndGainRareItem<InventoryItem>();
_effectService.DropTo1HPAndGainRareItem<IBaseInventoryItem>();
break;
case ItemTag.TradeAllRandomItems:
var newInventory = _effectService.TradeAllRandomItems<InventoryItem>(boxItem);
var newInventory = _effectService.TradeAllRandomItems(boxItem);
_player.Inventory.Items.Clear();
_player.Inventory.TryAdd(boxItem);
foreach (var item in newInventory)
@@ -472,7 +469,7 @@ public partial class Game : Node3D, IGame
_effectService.GetUnobtainedItem();
break;
case ItemTag.ContainsBasicItem:
_effectService.GetBasicItem<InventoryItem>();
_effectService.GetBasicItem<IBaseInventoryItem>();
break;
case ItemTag.UnequipAllItems:
_player.EquipmentComponent.Unequip(_player.EquipmentComponent.EquippedWeapon.Value);
@@ -567,7 +564,7 @@ public partial class Game : Node3D, IGame
}
}
private void RemoveItemOrSubtractFromItemCount(InventoryItem item)
private void RemoveItemOrSubtractFromItemCount(IBaseInventoryItem item)
{
if (item is IStackable stackableItem && stackableItem.Count.Value > 1)
stackableItem.SetCount(stackableItem.Count.Value - 1);
@@ -589,6 +586,8 @@ public partial class Game : Node3D, IGame
private void OnFloorLoadFinished()
{
LoadNextLevel.Hide();
GameLoaded?.Invoke();
_map.FadeIn();
}
private void OnQuit() => GameExitRequested?.Invoke();

View File

@@ -11,11 +11,11 @@ process_mode = 3
script = ExtResource("1_ytcii")
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
custom_minimum_size = Vector2(1440, 1080)
custom_minimum_size = Vector2(1456, 1080)
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -480.0
offset_right = -464.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
@@ -23,7 +23,7 @@ stretch = true
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
handle_input_locally = false
audio_listener_enable_3d = true
size = Vector2i(1440, 1080)
size = Vector2i(1456, 1080)
render_target_update_mode = 4
[node name="PauseContainer" type="Node3D" parent="SubViewportContainer/SubViewport"]

View File

@@ -18,13 +18,13 @@ public interface IGame : IProvide<IGame>, IProvide<IGameRepo>, IProvide<IPlayer>
public IDungeonFloor CurrentFloor { get; }
public Task UseItem(InventoryItem item);
public Task UseItem(IBaseInventoryItem item);
public void DropItem(InventoryItem item);
public void DropItem(IBaseInventoryItem item);
public void SetItem(InventoryItem item);
public void SetItem(IBaseInventoryItem item);
public void ThrowItem(InventoryItem item);
public void ThrowItem(IBaseInventoryItem item);
public void FloorExitReached();

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -172,7 +172,11 @@ public class EffectService
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
}
public void RaiseLevel() => _player.LevelUp();
public void RaiseLevel()
{
var expToNextLevel = _player.ExperiencePointsComponent.ExpToNextLevel.Value - _player.ExperiencePointsComponent.CurrentExp.Value;
_player.ExperiencePointsComponent.GainUnmodified(expToNextLevel);
}
public void TeleportToRandomRoom(IEnemy enemy)
{
@@ -228,14 +232,14 @@ public class EffectService
_player.TakeDamage(new AttackData(damage, ElementType.None, true, true));
}
public void RerollItem(InventoryItem itemToReroll)
public void RerollItem(IBaseInventoryItem itemToReroll)
{
var itemReroller = new ItemReroller(ItemDatabase.Instance);
itemReroller.RerollItem(itemToReroll, _player.Inventory);
}
public T GetRandomItemOfType<T>(T itemToExclude = null)
where T : InventoryItem => ItemDatabase.Instance.PickItem(itemToExclude);
public T GetRandomItemOfType<T>(params T[] itemsToExclude)
where T : IBaseInventoryItem => ItemDatabase.Instance.PickItem(itemsToExclude);
public void RandomSpell()
{
@@ -243,38 +247,33 @@ public class EffectService
}
public void DropTo1HPAndGainRareItem<T>()
where T : InventoryItem
where T : IBaseInventoryItem
{
_player.HealthComponent.SetCurrentHealth(1);
_player.Inventory.TryAdd(ItemDatabase.Instance.PickRareItem<T>());
}
public void TradeRandomItem<T>(BoxItem box)
where T : InventoryItem
where T : IBaseInventoryItem
{
var tradableItems = _player.Inventory.Items.OfType<T>().Where(x => x != box).ToList();
var tradableItems = _player.Inventory.Items.OfType<T>().ToList();
var rng = new RandomNumberGenerator();
rng.Randomize();
var randomIndex = rng.RandiRange(0, tradableItems.Count - 1);
var randomItem = tradableItems[randomIndex];
if (randomItem is EquipableItem equipableItem)
{
if (_player.EquipmentComponent.IsItemEquipped(equipableItem))
if (randomItem is IEquipableItem equipableItem && _player.EquipmentComponent.IsItemEquipped(equipableItem))
_player.Unequip(equipableItem);
}
_player.Inventory.Remove(randomItem);
GetRandomItemOfType<T>();
}
public IEnumerable<InventoryItem> TradeAllRandomItems<T>(BoxItem box)
where T : InventoryItem
public IEnumerable<IBaseInventoryItem> TradeAllRandomItems(BoxItem box)
{
var newInventory = new List<InventoryItem>();
var items = _player.Inventory.Items.OfType<T>().Where(x => x != box).ToList();
var newInventory = new List<IBaseInventoryItem>();
var items = _player.Inventory.Items.ToList();
foreach (var item in items)
newInventory.Add(GetRandomItemOfType<T>());
newInventory.Add(GetRandomItemOfType<IBaseInventoryItem>());
return newInventory;
}
@@ -294,7 +293,7 @@ public class EffectService
}
public void GetBasicItem<T>()
where T : InventoryItem
where T : IBaseInventoryItem
{
_player.Inventory.TryAdd(ItemDatabase.Instance.PickBasicItem<T>());
}

View File

@@ -27,9 +27,9 @@ public partial class Inventory : Node, IInventory
}
[Save("inventory_items")]
public List<InventoryItem> Items { get; private set; }
public List<IBaseInventoryItem> Items { get; private set; }
public bool PickUpItem(InventoryItem item)
public bool PickUpItem(IBaseInventoryItem item)
{
var isAdded = TryAdd(item);
if (isAdded)
@@ -43,7 +43,7 @@ public partial class Inventory : Node, IInventory
return isAdded;
}
public bool TryAdd(InventoryItem inventoryItem)
public bool TryAdd(IBaseInventoryItem inventoryItem)
{
if (Items.Count >= _maxInventorySize)
return false;
@@ -55,7 +55,7 @@ public partial class Inventory : Node, IInventory
public bool AtCapacity() => Items.Count >= _maxInventorySize;
public bool TryInsert(InventoryItem inventoryItem, int index)
public bool TryInsert(IBaseInventoryItem inventoryItem, int index)
{
if (Items.Count >= _maxInventorySize || index >= _maxInventorySize || index < 0)
return false;
@@ -65,20 +65,20 @@ public partial class Inventory : Node, IInventory
return true;
}
public void Remove(InventoryItem inventoryItem)
public void Remove(IBaseInventoryItem inventoryItem)
{
Items.Remove(inventoryItem);
InventoryChanged?.Invoke();
}
public bool Sort(EquipableItem currentWeapon, EquipableItem currentArmor, EquipableItem currentAccessory, EquipableItem currentAmmo)
public bool Sort(IWeapon currentWeapon, IArmor currentArmor, IAccessory currentAccessory, IEquipableItem currentAmmo)
{
var initialList = Items;
var equippedWeapon = Items.OfType<Weapon>().Where(x => x == currentWeapon);
var equippedArmor = Items.OfType<Armor>().Where(x => x == currentArmor);
var equippedAccessory = Items.OfType<Accessory>().Where(x => x == currentAccessory);
var equippedAmmo = Items.OfType<Ammo>().Where(x => x == currentAmmo);
var equippedItems = new List<InventoryItem>();
var equippedItems = new List<IBaseInventoryItem>();
equippedItems.AddRange(equippedWeapon);
equippedItems.AddRange(equippedArmor);
equippedItems.AddRange(equippedAccessory);
@@ -96,12 +96,12 @@ public partial class Inventory : Node, IInventory
Items = [.. equippedItems, .. weapons, .. armor, .. accessories, .. ammo, .. consumables, .. throwables, .. effectItems, .. jewelItems, .. setItems];
var stackableItems = Items.OfType<IStackable>();
var itemsToStack = stackableItems.GroupBy(x => ((InventoryItem)x).ItemName).Where(x => x.Count() > 1);
var itemsToStack = stackableItems.GroupBy(x => ((IBaseInventoryItem)x).ItemName).Where(x => x.Count() > 1);
foreach (var itemStack in itemsToStack)
{
var firstItem = itemStack.First();
firstItem.SetCount(itemStack.Sum(x => x.Count.Value));
var itemsToRemove = itemStack.Except([firstItem]).Cast<InventoryItem>();
var itemsToRemove = itemStack.Except([firstItem]).Cast<IBaseInventoryItem>();
foreach (var item in itemsToRemove)
Remove(item);
}

View File

@@ -14,37 +14,37 @@ public class ItemDatabase
public static ItemDatabase Instance { get { return lazy.Value; } }
public ImmutableList<InventoryItem> Items { get; set; }
public ImmutableList<IBaseInventoryItem> Items { get; set; }
public T PickItem<T>(T itemToExclude = null)
where T : InventoryItem
public T PickItem<T>(params T[] itemsToExclude)
where T : IBaseInventoryItem
{
var itemsToSelectFrom = Items.OfType<T>();
return PickItemInternal(itemsToSelectFrom, itemToExclude);
return PickItemInternal(itemsToSelectFrom, itemsToExclude);
}
public T PickRareItem<T>(T itemToExclude = null)
where T : InventoryItem
public T PickRareItem<T>(params T[] itemsToExclude)
where T : IBaseInventoryItem
{
var getRareItems = Items.OfType<T>().Where(x => x.SpawnRate < 0.1f);
return PickItemInternal(getRareItems, itemToExclude);
return PickItemInternal(getRareItems, itemsToExclude);
}
public T PickBasicItem<T>(T itemToExclude = null)
where T : InventoryItem
public T PickBasicItem<T>(params T[] itemsToExclude)
where T : IBaseInventoryItem
{
var getBasicItems = Items.OfType<T>().Where(x => x.SpawnRate > 0.5f);
return PickItemInternal(getBasicItems, itemToExclude);
return PickItemInternal(getBasicItems, itemsToExclude);
}
private T PickItemInternal<T>(IEnumerable<T> itemsToSelectFrom, T itemToExclude = null)
where T : InventoryItem
private T PickItemInternal<T>(IEnumerable<T> itemsToSelectFrom, params T[] itemsToExclude)
where T : IBaseInventoryItem
{
var rng = new RandomNumberGenerator();
rng.Randomize();
if (itemToExclude is not null)
itemsToSelectFrom = [.. itemsToSelectFrom.Where(x => x.ItemName != itemToExclude.ItemName)];
if (itemsToExclude.Any())
itemsToSelectFrom.Except(itemsToExclude);
var weights = itemsToSelectFrom.Select(x => x.SpawnRate).ToArray();
var selectedItem = itemsToSelectFrom.ToArray()[rng.RandWeighted(weights)];
@@ -54,7 +54,7 @@ public class ItemDatabase
private ItemDatabase()
{
var database = new List<InventoryItem>();
var database = new List<IBaseInventoryItem>();
var armorResources = DirAccess.GetFilesAt("res://src/items/armor/resources/");
var weaponResources = DirAccess.GetFilesAt("res://src/items/weapons/resources/");
var accessoryResources = DirAccess.GetFilesAt("res://src/items/accessory/resources/");

View File

@@ -12,7 +12,7 @@ public class ItemReroller
}
public T RerollItem<T>(T itemToReroll, IInventory inventory, bool insertIntoInventory = true)
where T : InventoryItem
where T : IBaseInventoryItem
{
var currentIndex = inventory.Items.IndexOf(itemToReroll);
@@ -27,7 +27,7 @@ public class ItemReroller
return rolledItem;
}
public InventoryItem RerollItemToAny(InventoryItem itemToReroll, IInventory inventory, bool insertIntoInventory = true)
public IBaseInventoryItem RerollItemToAny(IBaseInventoryItem itemToReroll, IInventory inventory, bool insertIntoInventory = true)
{
var currentIndex = inventory.Items.IndexOf(itemToReroll);

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Some files were not shown because too many files have changed in this diff Show More