Drop item
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
@startuml AppLogic
|
@startuml AppLogic
|
||||||
state "AppLogic State" as GameJamDungeon_AppLogic_State {
|
state "AppLogic State" as GameJamDungeon_AppLogic_State {
|
||||||
|
state "SetupGameScene" as GameJamDungeon_AppLogic_State_SetupGameScene
|
||||||
|
state "InGame" as GameJamDungeon_AppLogic_State_InGame
|
||||||
state "LoadingScreen" as GameJamDungeon_AppLogic_State_LoadingScreen
|
state "LoadingScreen" as GameJamDungeon_AppLogic_State_LoadingScreen
|
||||||
state "MainMenu" as GameJamDungeon_AppLogic_State_MainMenu
|
state "MainMenu" as GameJamDungeon_AppLogic_State_MainMenu
|
||||||
state "InGame" as GameJamDungeon_AppLogic_State_InGame
|
|
||||||
state "SetupGameScene" as GameJamDungeon_AppLogic_State_SetupGameScene
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GameJamDungeon_AppLogic_State_InGame --> GameJamDungeon_AppLogic_State_MainMenu : GameOver
|
GameJamDungeon_AppLogic_State_InGame --> GameJamDungeon_AppLogic_State_MainMenu : GameOver
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ public partial class InGameAudioLogic
|
|||||||
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
|
gameEventDepot.DungeonAThemeAreaEntered += OnDungeonAThemeEntered;
|
||||||
gameEventDepot.MenuScrolled += OnMenuScrolled;
|
gameEventDepot.MenuScrolled += OnMenuScrolled;
|
||||||
gameEventDepot.MenuBackedOut += OnMenuBackedOut;
|
gameEventDepot.MenuBackedOut += OnMenuBackedOut;
|
||||||
gameEventDepot.EquippedItem += OnEquippedItem;
|
gameEventDepot.EquippedWeapon += OnEquippedItem;
|
||||||
|
gameEventDepot.EquippedArmor += OnEquippedItem;
|
||||||
|
gameEventDepot.EquippedAccessory += OnEquippedItem;
|
||||||
gameEventDepot.InventorySorted += OnInventorySorted;
|
gameEventDepot.InventorySorted += OnInventorySorted;
|
||||||
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
|
gameEventDepot.HealingItemConsumed += OnHealingItemConsumed;
|
||||||
gameEventDepot.RestorativePickedUp += OnRestorativePickedUp;
|
gameEventDepot.RestorativePickedUp += OnRestorativePickedUp;
|
||||||
@@ -32,7 +34,9 @@ public partial class InGameAudioLogic
|
|||||||
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
|
gameEventDepot.DungeonAThemeAreaEntered -= OnDungeonAThemeEntered;
|
||||||
gameEventDepot.MenuScrolled -= OnMenuScrolled;
|
gameEventDepot.MenuScrolled -= OnMenuScrolled;
|
||||||
gameEventDepot.MenuBackedOut -= OnMenuBackedOut;
|
gameEventDepot.MenuBackedOut -= OnMenuBackedOut;
|
||||||
gameEventDepot.EquippedItem -= OnEquippedItem;
|
gameEventDepot.EquippedWeapon -= OnEquippedItem;
|
||||||
|
gameEventDepot.EquippedArmor -= OnEquippedItem;
|
||||||
|
gameEventDepot.EquippedAccessory -= OnEquippedItem;
|
||||||
gameEventDepot.InventorySorted -= OnInventorySorted;
|
gameEventDepot.InventorySorted -= OnInventorySorted;
|
||||||
gameEventDepot.TeleportEntered -= OnTeleportEntered;
|
gameEventDepot.TeleportEntered -= OnTeleportEntered;
|
||||||
});
|
});
|
||||||
@@ -46,7 +50,7 @@ public partial class InGameAudioLogic
|
|||||||
|
|
||||||
private void OnInventorySorted() => Output(new Output.PlayInventorySortedSound());
|
private void OnInventorySorted() => Output(new Output.PlayInventorySortedSound());
|
||||||
|
|
||||||
private void OnEquippedItem() => Output(new Output.PlayEquipSound());
|
private void OnEquippedItem(IEquipableItem equipableItem) => Output(new Output.PlayEquipSound());
|
||||||
|
|
||||||
private void OnOverworldEntered() => Output(new Output.PlayOverworldMusic());
|
private void OnOverworldEntered() => Output(new Output.PlayOverworldMusic());
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
@startuml EnemyLogic
|
@startuml EnemyLogic
|
||||||
state "EnemyLogic State" as GameJamDungeon_EnemyLogic_State {
|
state "EnemyLogic State" as GameJamDungeon_EnemyLogic_State {
|
||||||
state "Defeated" as GameJamDungeon_EnemyLogic_State_Defeated
|
|
||||||
state "Alive" as GameJamDungeon_EnemyLogic_State_Alive {
|
state "Alive" as GameJamDungeon_EnemyLogic_State_Alive {
|
||||||
state "Idle" as GameJamDungeon_EnemyLogic_State_Idle
|
|
||||||
state "FollowPlayer" as GameJamDungeon_EnemyLogic_State_FollowPlayer
|
state "FollowPlayer" as GameJamDungeon_EnemyLogic_State_FollowPlayer
|
||||||
|
state "Idle" as GameJamDungeon_EnemyLogic_State_Idle
|
||||||
}
|
}
|
||||||
|
state "Defeated" as GameJamDungeon_EnemyLogic_State_Defeated
|
||||||
}
|
}
|
||||||
|
|
||||||
GameJamDungeon_EnemyLogic_State_Alive --> GameJamDungeon_EnemyLogic_State_Alive : AttackTimer
|
GameJamDungeon_EnemyLogic_State_Alive --> GameJamDungeon_EnemyLogic_State_Alive : AttackTimer
|
||||||
|
|||||||
@@ -2,17 +2,17 @@
|
|||||||
namespace GameJamDungeon;
|
namespace GameJamDungeon;
|
||||||
|
|
||||||
using Chickensoft.AutoInject;
|
using Chickensoft.AutoInject;
|
||||||
using Chickensoft.Collections;
|
|
||||||
using Chickensoft.GodotNodeInterfaces;
|
using Chickensoft.GodotNodeInterfaces;
|
||||||
using Chickensoft.Introspection;
|
using Chickensoft.Introspection;
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
|
||||||
|
|
||||||
public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, INode3D
|
public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, INode3D
|
||||||
{
|
{
|
||||||
event Game.StatRaisedAlertEventHandler StatRaisedAlert;
|
event Game.StatRaisedAlertEventHandler StatRaisedAlert;
|
||||||
|
|
||||||
public IPlayer Player { get; }
|
public IPlayer Player { get; }
|
||||||
|
|
||||||
|
public void DropItem(IInventoryItem item);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
@@ -130,12 +130,19 @@ public partial class Game : Node3D, IGame
|
|||||||
Player.MinimapButtonHeld += Player_MinimapButtonHeld;
|
Player.MinimapButtonHeld += Player_MinimapButtonHeld;
|
||||||
Player.PauseButtonPressed += Player_PauseButtonPressed;
|
Player.PauseButtonPressed += Player_PauseButtonPressed;
|
||||||
|
|
||||||
GameRepo.PlayerData.Inventory.EquippedItem += Inventory_EquippedItem;
|
|
||||||
|
|
||||||
GameEventDepot.EnemyDefeated += OnEnemyDefeated;
|
GameEventDepot.EnemyDefeated += OnEnemyDefeated;
|
||||||
GameEventDepot.RestorativePickedUp += GameEventDepot_RestorativePickedUp;
|
GameEventDepot.RestorativePickedUp += GameEventDepot_RestorativePickedUp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DropItem(IInventoryItem item)
|
||||||
|
{
|
||||||
|
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
|
||||||
|
var dropped = droppedScene.Instantiate<DroppedItem>();
|
||||||
|
dropped.Item = item;
|
||||||
|
AddChild(dropped);
|
||||||
|
dropped.Drop();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnEnemyDefeated(Vector3 vector, EnemyStatResource resource)
|
private void OnEnemyDefeated(Vector3 vector, EnemyStatResource resource)
|
||||||
{
|
{
|
||||||
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
|
var restorativeScene = GD.Load<PackedScene>("res://src/items/restorative/Restorative.tscn");
|
||||||
@@ -144,11 +151,6 @@ public partial class Game : Node3D, IGame
|
|||||||
restorative.GlobalPosition = vector;
|
restorative.GlobalPosition = vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Inventory_EquippedItem()
|
|
||||||
{
|
|
||||||
GameEventDepot.OnEquippedItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UseTeleportPrompt_CloseTeleportPrompt()
|
private void UseTeleportPrompt_CloseTeleportPrompt()
|
||||||
{
|
{
|
||||||
GameLogic.Input(new GameLogic.Input.HideAskForTeleport());
|
GameLogic.Input(new GameLogic.Input.HideAskForTeleport());
|
||||||
|
|||||||
@@ -26,11 +26,23 @@ namespace GameJamDungeon
|
|||||||
event Action? MenuBackedOut;
|
event Action? MenuBackedOut;
|
||||||
public void OnMenuBackedOut();
|
public void OnMenuBackedOut();
|
||||||
|
|
||||||
event Action? EquippedItem;
|
event Action<Weapon>? EquippedWeapon;
|
||||||
public void OnEquippedItem();
|
public void OnEquippedWeapon(Weapon equippedWeapon);
|
||||||
|
|
||||||
event Action? UnequippedItem;
|
event Action? UnequippedWeapon;
|
||||||
public void OnUnequippedItem();
|
public void OnUnequippedWeapon();
|
||||||
|
|
||||||
|
event Action<Armor>? EquippedArmor;
|
||||||
|
public void OnEquippedArmor(Armor equippedArmor);
|
||||||
|
|
||||||
|
event Action? UnequippedArmor;
|
||||||
|
public void OnUnequippedArmor();
|
||||||
|
|
||||||
|
event Action<Accessory>? EquippedAccessory;
|
||||||
|
public void OnEquippedAccessory(Accessory equippedAccessory);
|
||||||
|
|
||||||
|
event Action? UnequippedAccessory;
|
||||||
|
public void OnUnequippedAccessory();
|
||||||
|
|
||||||
event Action? InventorySorted;
|
event Action? InventorySorted;
|
||||||
public void OnInventorySorted();
|
public void OnInventorySorted();
|
||||||
@@ -57,8 +69,12 @@ namespace GameJamDungeon
|
|||||||
|
|
||||||
public event Action? MenuScrolled;
|
public event Action? MenuScrolled;
|
||||||
public event Action? MenuBackedOut;
|
public event Action? MenuBackedOut;
|
||||||
public event Action? EquippedItem;
|
public event Action<Weapon>? EquippedWeapon;
|
||||||
public event Action? UnequippedItem;
|
public event Action? UnequippedWeapon;
|
||||||
|
public event Action<Armor>? EquippedArmor;
|
||||||
|
public event Action? UnequippedArmor;
|
||||||
|
public event Action<Accessory>? EquippedAccessory;
|
||||||
|
public event Action? UnequippedAccessory;
|
||||||
public event Action? InventorySorted;
|
public event Action? InventorySorted;
|
||||||
public event Action<ConsumableItemStats>? HealingItemConsumed;
|
public event Action<ConsumableItemStats>? HealingItemConsumed;
|
||||||
public event Action<Restorative>? RestorativePickedUp;
|
public event Action<Restorative>? RestorativePickedUp;
|
||||||
@@ -74,8 +90,16 @@ namespace GameJamDungeon
|
|||||||
|
|
||||||
public void OnMenuScrolled() => MenuScrolled?.Invoke();
|
public void OnMenuScrolled() => MenuScrolled?.Invoke();
|
||||||
public void OnMenuBackedOut() => MenuBackedOut?.Invoke();
|
public void OnMenuBackedOut() => MenuBackedOut?.Invoke();
|
||||||
public void OnEquippedItem() => EquippedItem?.Invoke();
|
|
||||||
public void OnUnequippedItem() => UnequippedItem?.Invoke();
|
public void OnEquippedWeapon(Weapon equippedWeapon) => EquippedWeapon?.Invoke(equippedWeapon);
|
||||||
|
public void OnUnequippedWeapon() => UnequippedWeapon?.Invoke();
|
||||||
|
|
||||||
|
public void OnEquippedArmor(Armor equippedArmor) => EquippedArmor?.Invoke(equippedArmor);
|
||||||
|
public void OnUnequippedArmor() => UnequippedArmor?.Invoke();
|
||||||
|
|
||||||
|
public void OnEquippedAccessory(Accessory equippedAccessory) => EquippedAccessory?.Invoke(equippedAccessory);
|
||||||
|
public void OnUnequippedAccessory() => UnequippedAccessory?.Invoke();
|
||||||
|
|
||||||
public void OnInventorySorted() => InventorySorted?.Invoke();
|
public void OnInventorySorted() => InventorySorted?.Invoke();
|
||||||
public void OnHealingItemConsumed(ConsumableItemStats item) => HealingItemConsumed?.Invoke(item);
|
public void OnHealingItemConsumed(ConsumableItemStats item) => HealingItemConsumed?.Invoke(item);
|
||||||
public void OnRestorativePickedUp(Restorative restorative) => RestorativePickedUp?.Invoke(restorative);
|
public void OnRestorativePickedUp(Restorative restorative) => RestorativePickedUp?.Invoke(restorative);
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
@startuml GameLogic
|
@startuml GameLogic
|
||||||
state "GameLogic State" as GameJamDungeon_GameLogic_State {
|
state "GameLogic State" as GameJamDungeon_GameLogic_State {
|
||||||
state "Quit" as GameJamDungeon_GameLogic_State_Quit
|
state "GameStarted" as GameJamDungeon_GameLogic_State_GameStarted
|
||||||
state "Playing" as GameJamDungeon_GameLogic_State_Playing {
|
state "Playing" as GameJamDungeon_GameLogic_State_Playing {
|
||||||
state "MinimapOpen" as GameJamDungeon_GameLogic_State_MinimapOpen
|
|
||||||
state "Resuming" as GameJamDungeon_GameLogic_State_Resuming
|
|
||||||
state "AskForTeleport" as GameJamDungeon_GameLogic_State_AskForTeleport
|
state "AskForTeleport" as GameJamDungeon_GameLogic_State_AskForTeleport
|
||||||
state "Paused" as GameJamDungeon_GameLogic_State_Paused
|
|
||||||
state "FloorClearedDecisionState" as GameJamDungeon_GameLogic_State_FloorClearedDecisionState
|
state "FloorClearedDecisionState" as GameJamDungeon_GameLogic_State_FloorClearedDecisionState
|
||||||
state "InventoryOpened" as GameJamDungeon_GameLogic_State_InventoryOpened
|
state "InventoryOpened" as GameJamDungeon_GameLogic_State_InventoryOpened
|
||||||
|
state "MinimapOpen" as GameJamDungeon_GameLogic_State_MinimapOpen
|
||||||
|
state "Paused" as GameJamDungeon_GameLogic_State_Paused
|
||||||
|
state "Resuming" as GameJamDungeon_GameLogic_State_Resuming
|
||||||
}
|
}
|
||||||
state "GameStarted" as GameJamDungeon_GameLogic_State_GameStarted
|
state "Quit" as GameJamDungeon_GameLogic_State_Quit
|
||||||
}
|
}
|
||||||
|
|
||||||
GameJamDungeon_GameLogic_State_AskForTeleport --> GameJamDungeon_GameLogic_State_FloorClearedDecisionState : FloorExitReached
|
GameJamDungeon_GameLogic_State_AskForTeleport --> GameJamDungeon_GameLogic_State_FloorClearedDecisionState : FloorExitReached
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
|
|
||||||
var currentItem = ItemSlots.ElementAt(_currentIndex).Item;
|
var currentItem = ItemSlots.ElementAt(_currentIndex).Item;
|
||||||
|
|
||||||
if (currentItem is IEquipable equipable)
|
if (currentItem is IEquipableItem equipable)
|
||||||
{
|
{
|
||||||
var isEquipped = GameRepo.PlayerData.Inventory.IsEquipped(equipable);
|
var isEquipped = GameRepo.PlayerData.Inventory.IsEquipped(equipable);
|
||||||
UseButton.Text = isEquipped ? "Unequip" : "Equip";
|
UseButton.Text = isEquipped ? "Unequip" : "Equip";
|
||||||
@@ -335,14 +335,14 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
itemSlot.Item = item;
|
itemSlot.Item = item;
|
||||||
ItemsPage.AddChildEx(itemSlot);
|
ItemsPage.AddChildEx(itemSlot);
|
||||||
|
|
||||||
if (itemSlot.Item is IEquipable equipable && GameRepo.PlayerData.Inventory.IsEquipped(equipable))
|
if (itemSlot.Item is IEquipableItem equipable && GameRepo.PlayerData.Inventory.IsEquipped(equipable))
|
||||||
itemSlot.SetEquippedItemStyle();
|
itemSlot.SetEquippedItemStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ItemSlots.Any())
|
if (ItemSlots.Any())
|
||||||
{
|
{
|
||||||
ItemSlots.ElementAt(_currentIndex).SetSelectedItemStyle();
|
ItemSlots.ElementAt(_currentIndex).SetSelectedItemStyle();
|
||||||
if (ItemSlots.ElementAt(_currentIndex).Item is IEquipable equipable && GameRepo.PlayerData.Inventory.IsEquipped(equipable))
|
if (ItemSlots.ElementAt(_currentIndex).Item is IEquipableItem equipable && GameRepo.PlayerData.Inventory.IsEquipped(equipable))
|
||||||
ItemSlots.ElementAt(_currentIndex).SetEquippedSelectedItemStyle();
|
ItemSlots.ElementAt(_currentIndex).SetEquippedSelectedItemStyle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,7 +351,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
{
|
{
|
||||||
await ToSignal(GetTree().CreateTimer(0.1f), "timeout");
|
await ToSignal(GetTree().CreateTimer(0.1f), "timeout");
|
||||||
itemSlot.SetItemStyle();
|
itemSlot.SetItemStyle();
|
||||||
if (itemSlot.Item is IEquipable equipable && GameRepo.PlayerData.Inventory.IsEquipped(equipable))
|
if (itemSlot.Item is IEquipableItem equipable && GameRepo.PlayerData.Inventory.IsEquipped(equipable))
|
||||||
itemSlot.SetEquippedItemStyle();
|
itemSlot.SetEquippedItemStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,7 +366,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
private async Task EquipOrUnequipItem()
|
private async Task EquipOrUnequipItem()
|
||||||
{
|
{
|
||||||
var itemSlot = ItemSlots[_currentIndex];
|
var itemSlot = ItemSlots[_currentIndex];
|
||||||
if (itemSlot.Item is IEquipable equipableItem)
|
if (itemSlot.Item is IEquipableItem equipableItem)
|
||||||
{
|
{
|
||||||
if (GameRepo.PlayerData.Inventory.IsEquipped(equipableItem))
|
if (GameRepo.PlayerData.Inventory.IsEquipped(equipableItem))
|
||||||
{
|
{
|
||||||
@@ -392,12 +392,11 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
private async void UseButtonPressed()
|
private async void UseButtonPressed()
|
||||||
{
|
{
|
||||||
var currentItem = ItemSlots[_currentIndex].Item;
|
var currentItem = ItemSlots[_currentIndex].Item;
|
||||||
if (currentItem is IEquipable)
|
if (currentItem is IEquipableItem)
|
||||||
await EquipOrUnequipItem();
|
await EquipOrUnequipItem();
|
||||||
else if (currentItem is ConsumableItem consumable)
|
else if (currentItem is IUsableItem usable)
|
||||||
{
|
{
|
||||||
GameRepo.PlayerData.Inventory.Use(consumable);
|
usable.Use();
|
||||||
GameEventDepot.OnHealingItemConsumed(consumable.ConsumableItemInfo);
|
|
||||||
if (_currentIndex >= ItemSlots.Length - 1)
|
if (_currentIndex >= ItemSlots.Length - 1)
|
||||||
_currentIndex--;
|
_currentIndex--;
|
||||||
if (_currentIndex <= 0)
|
if (_currentIndex <= 0)
|
||||||
@@ -409,17 +408,23 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
{
|
{
|
||||||
var currentItem = ItemSlots[_currentIndex].Item;
|
var currentItem = ItemSlots[_currentIndex].Item;
|
||||||
|
|
||||||
if (_currentIndex >= ItemSlots.Length - 1)
|
if (currentItem is IThrowableItem throwable)
|
||||||
_currentIndex--;
|
{
|
||||||
if (_currentIndex <= 0)
|
throwable.Throw();
|
||||||
_currentIndex = 0;
|
|
||||||
EmitSignal(SignalName.ClosedMenu);
|
if (_currentIndex >= ItemSlots.Length - 1)
|
||||||
GameRepo.PlayerData.Inventory.Throw(currentItem);
|
_currentIndex--;
|
||||||
|
if (_currentIndex <= 0)
|
||||||
|
_currentIndex = 0;
|
||||||
|
|
||||||
|
EmitSignal(SignalName.ClosedMenu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void DropButtonPressed()
|
private async void DropButtonPressed()
|
||||||
{
|
{
|
||||||
var currentItem = ItemSlots[_currentIndex].Item;
|
var currentItem = ItemSlots[_currentIndex].Item;
|
||||||
|
Game.DropItem(currentItem);
|
||||||
|
|
||||||
if (_currentIndex >= ItemSlots.Length - 1)
|
if (_currentIndex >= ItemSlots.Length - 1)
|
||||||
_currentIndex--;
|
_currentIndex--;
|
||||||
@@ -427,7 +432,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
|||||||
_currentIndex = 0;
|
_currentIndex = 0;
|
||||||
|
|
||||||
EmitSignal(SignalName.ClosedMenu);
|
EmitSignal(SignalName.ClosedMenu);
|
||||||
GameRepo.PlayerData.Inventory.Drop(currentItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum InventoryPageNumber
|
private enum InventoryPageNumber
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public partial class ItemSlot : HBoxContainer, IItemSlot
|
|||||||
}
|
}
|
||||||
public void SetSelectedItemStyle()
|
public void SetSelectedItemStyle()
|
||||||
{
|
{
|
||||||
if (Item is IEquipable equipableItem && GameRepo.PlayerData.Inventory.IsEquipped(equipableItem))
|
if (Item is IEquipableItem equipableItem && GameRepo.PlayerData.Inventory.IsEquipped(equipableItem))
|
||||||
{
|
{
|
||||||
ItemName.LabelSettings = SelectedEquippedItemFont;
|
ItemName.LabelSettings = SelectedEquippedItemFont;
|
||||||
//EquipBonus.LabelSettings = EquippedItemFont;
|
//EquipBonus.LabelSettings = EquippedItemFont;
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
namespace GameJamDungeon
|
|
||||||
{
|
|
||||||
public interface IEquipable;
|
|
||||||
}
|
|
||||||
9
src/items/IEquipableItem.cs
Normal file
9
src/items/IEquipableItem.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace GameJamDungeon
|
||||||
|
{
|
||||||
|
public interface IEquipableItem : IInventoryItem
|
||||||
|
{
|
||||||
|
public void Equip();
|
||||||
|
|
||||||
|
public void Unequip();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,17 +21,11 @@ public interface IInventory : INode
|
|||||||
|
|
||||||
public void Remove(IInventoryItem inventoryItem);
|
public void Remove(IInventoryItem inventoryItem);
|
||||||
|
|
||||||
public void Equip(IEquipable equipable);
|
public void Equip(IEquipableItem equipable);
|
||||||
|
|
||||||
public void Unequip(IEquipable equipable);
|
public void Unequip(IEquipableItem equipable);
|
||||||
|
|
||||||
public bool IsEquipped(IEquipable equipable);
|
public bool IsEquipped(IEquipableItem equipable);
|
||||||
|
|
||||||
public void Use(IInventoryItem inventoryItem);
|
|
||||||
|
|
||||||
public void Throw(IInventoryItem inventoryItem);
|
|
||||||
|
|
||||||
public void Drop(IInventoryItem inventoryItem);
|
|
||||||
|
|
||||||
public void Sort();
|
public void Sort();
|
||||||
|
|
||||||
@@ -40,8 +34,6 @@ public interface IInventory : INode
|
|||||||
event Inventory.AccessoryUnequippedEventHandler AccessoryUnequipped;
|
event Inventory.AccessoryUnequippedEventHandler AccessoryUnequipped;
|
||||||
|
|
||||||
event Inventory.RaiseStatRequestEventHandler RaiseStatRequest;
|
event Inventory.RaiseStatRequestEventHandler RaiseStatRequest;
|
||||||
|
|
||||||
event Inventory.EquippedItemEventHandler EquippedItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Inventory : Node, IInventory
|
public partial class Inventory : Node, IInventory
|
||||||
@@ -55,8 +47,6 @@ public partial class Inventory : Node, IInventory
|
|||||||
public delegate void AccessoryUnequippedEventHandler(AccessoryStats unequippedAccessory);
|
public delegate void AccessoryUnequippedEventHandler(AccessoryStats unequippedAccessory);
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void RaiseStatRequestEventHandler(ConsumableItemStats consumableItemStats);
|
public delegate void RaiseStatRequestEventHandler(ConsumableItemStats consumableItemStats);
|
||||||
[Signal]
|
|
||||||
public delegate void EquippedItemEventHandler();
|
|
||||||
|
|
||||||
public Inventory()
|
public Inventory()
|
||||||
{
|
{
|
||||||
@@ -88,7 +78,7 @@ public partial class Inventory : Node, IInventory
|
|||||||
|
|
||||||
public void Remove(IInventoryItem inventoryItem) => Items.Remove(inventoryItem);
|
public void Remove(IInventoryItem inventoryItem) => Items.Remove(inventoryItem);
|
||||||
|
|
||||||
public void Equip(IEquipable equipable)
|
public void Equip(IEquipableItem equipable)
|
||||||
{
|
{
|
||||||
if (equipable is Weapon weapon)
|
if (equipable is Weapon weapon)
|
||||||
_equippedWeapon.OnNext(weapon);
|
_equippedWeapon.OnNext(weapon);
|
||||||
@@ -98,11 +88,9 @@ public partial class Inventory : Node, IInventory
|
|||||||
_equippedAccessory.OnNext(accessory);
|
_equippedAccessory.OnNext(accessory);
|
||||||
else
|
else
|
||||||
throw new NotImplementedException("Item type is not supported.");
|
throw new NotImplementedException("Item type is not supported.");
|
||||||
|
|
||||||
EmitSignal(SignalName.EquippedItem);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unequip(IEquipable equipable)
|
public void Unequip(IEquipableItem equipable)
|
||||||
{
|
{
|
||||||
if (equipable is Weapon weapon)
|
if (equipable is Weapon weapon)
|
||||||
{
|
{
|
||||||
@@ -121,7 +109,7 @@ public partial class Inventory : Node, IInventory
|
|||||||
throw new NotImplementedException("Item type is not supported.");
|
throw new NotImplementedException("Item type is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEquipped(IEquipable equipable)
|
public bool IsEquipped(IEquipableItem equipable)
|
||||||
{
|
{
|
||||||
if (equipable is Weapon weapon)
|
if (equipable is Weapon weapon)
|
||||||
return _equippedWeapon.Value.Equals(weapon);
|
return _equippedWeapon.Value.Equals(weapon);
|
||||||
@@ -133,27 +121,6 @@ public partial class Inventory : Node, IInventory
|
|||||||
throw new NotImplementedException("Item type is not supported.");
|
throw new NotImplementedException("Item type is not supported.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Use(IInventoryItem item)
|
|
||||||
{
|
|
||||||
if (item is ConsumableItem consumableItem)
|
|
||||||
{
|
|
||||||
EmitSignal(SignalName.RaiseStatRequest, consumableItem.ConsumableItemInfo);
|
|
||||||
Remove(consumableItem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Throw(IInventoryItem item)
|
|
||||||
{
|
|
||||||
if (item is ThrowableItem throwable)
|
|
||||||
throwable.Throw(throwable.ThrowableItemInfo);
|
|
||||||
//Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Drop(IInventoryItem item)
|
|
||||||
{
|
|
||||||
Remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Sort()
|
public void Sort()
|
||||||
{
|
{
|
||||||
var equippedWeapon = Items.OfType<Weapon>().Where(IsEquipped);
|
var equippedWeapon = Items.OfType<Weapon>().Where(IsEquipped);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Chickensoft.GodotNodeInterfaces;
|
using Chickensoft.GodotNodeInterfaces;
|
||||||
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace GameJamDungeon
|
namespace GameJamDungeon
|
||||||
@@ -6,8 +7,17 @@ namespace GameJamDungeon
|
|||||||
public interface IInventoryItem : INode3D
|
public interface IInventoryItem : INode3D
|
||||||
{
|
{
|
||||||
public Guid ID { get; }
|
public Guid ID { get; }
|
||||||
public IGameRepo GameRepo { get; }
|
|
||||||
|
|
||||||
public InventoryItemStats Info { get; }
|
public InventoryItemStats Info { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IUsableItem : IInventoryItem
|
||||||
|
{
|
||||||
|
public void Use();
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IThrowableItem : IInventoryItem
|
||||||
|
{
|
||||||
|
public void Throw();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ public partial class InventoryItemStats : Resource
|
|||||||
|
|
||||||
[Export(PropertyHint.Range, "0, 1, 0.01")]
|
[Export(PropertyHint.Range, "0, 1, 0.01")]
|
||||||
public float SpawnRate { get; set; } = 0.5f;
|
public float SpawnRate { get; set; } = 0.5f;
|
||||||
|
|
||||||
|
public float ThrowSpeed { get; set; } = 7.0f;
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,16 @@ using Chickensoft.Introspection;
|
|||||||
using GameJamDungeon;
|
using GameJamDungeon;
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class Accessory : Node3D, IInventoryItem, IEquipable
|
public partial class Accessory : Node3D, IEquipableItem, IThrowableItem
|
||||||
{
|
{
|
||||||
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>();
|
||||||
|
|
||||||
|
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||||
|
|
||||||
public InventoryItemStats Info => AccessoryStats;
|
public InventoryItemStats Info => AccessoryStats;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
@@ -30,12 +30,17 @@ public partial class Accessory : Node3D, IInventoryItem, IEquipable
|
|||||||
Pickup.BodyEntered += OnEntered;
|
Pickup.BodyEntered += OnEntered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Throw()
|
public void Equip()
|
||||||
{
|
{
|
||||||
GameRepo.PlayerData.Inventory.Remove(this);
|
GameEventDepot.OnEquippedAccessory(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Drop()
|
public void Unequip()
|
||||||
|
{
|
||||||
|
GameEventDepot.OnUnequippedAccessory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Throw()
|
||||||
{
|
{
|
||||||
GameRepo.PlayerData.Inventory.Remove(this);
|
GameRepo.PlayerData.Inventory.Remove(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class Armor : Node3D, IInventoryItem, IEquipable
|
public partial class Armor : Node3D, IEquipableItem, IThrowableItem
|
||||||
{
|
{
|
||||||
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>();
|
||||||
|
|
||||||
|
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||||
|
|
||||||
public InventoryItemStats Info => ArmorStats;
|
public InventoryItemStats Info => ArmorStats;
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
@@ -28,6 +30,16 @@ public partial class Armor : Node3D, IInventoryItem, IEquipable
|
|||||||
Pickup.BodyEntered += OnEntered;
|
Pickup.BodyEntered += OnEntered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Equip()
|
||||||
|
{
|
||||||
|
GameEventDepot.OnEquippedArmor(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unequip()
|
||||||
|
{
|
||||||
|
GameEventDepot.OnUnequippedArmor();
|
||||||
|
}
|
||||||
|
|
||||||
public void Throw()
|
public void Throw()
|
||||||
{
|
{
|
||||||
GameRepo.PlayerData.Inventory.Remove(this);
|
GameRepo.PlayerData.Inventory.Remove(this);
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class ConsumableItem : Node3D, IInventoryItem
|
public partial class ConsumableItem : Node3D, IUsableItem, IThrowableItem
|
||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
|
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||||
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||||
|
[Dependency] public IGameEventDepot GameEventDepot => this.DependOn<IGameEventDepot>();
|
||||||
|
|
||||||
public InventoryItemStats Info => ConsumableItemInfo;
|
public InventoryItemStats Info => ConsumableItemInfo;
|
||||||
|
|
||||||
@@ -22,6 +24,21 @@ public partial class ConsumableItem : Node3D, IInventoryItem
|
|||||||
|
|
||||||
public Guid ID => Guid.NewGuid();
|
public Guid ID => Guid.NewGuid();
|
||||||
|
|
||||||
|
public void Use()
|
||||||
|
{
|
||||||
|
GameEventDepot.OnHealingItemConsumed(ConsumableItemInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Throw()
|
||||||
|
{
|
||||||
|
var throwableScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
|
||||||
|
var throwable = throwableScene.Instantiate<ThrownItem>();
|
||||||
|
throwable.ThrownItemStats = ConsumableItemInfo;
|
||||||
|
Game.AddChild(throwable);
|
||||||
|
throwable.Throw();
|
||||||
|
GameRepo.PlayerData.Inventory.Remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnReady()
|
public void OnReady()
|
||||||
{
|
{
|
||||||
Sprite.Texture = ConsumableItemInfo.Texture;
|
Sprite.Texture = ConsumableItemInfo.Texture;
|
||||||
|
|||||||
45
src/items/dropped/DroppedItem.cs
Normal file
45
src/items/dropped/DroppedItem.cs
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
using Chickensoft.AutoInject;
|
||||||
|
using Chickensoft.Introspection;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
namespace GameJamDungeon
|
||||||
|
{
|
||||||
|
[Meta(typeof(IAutoNode))]
|
||||||
|
public partial class DroppedItem : RigidBody3D
|
||||||
|
{
|
||||||
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
|
[Dependency] public IGameRepo GameRepo => this.DependOn<IGameRepo>();
|
||||||
|
|
||||||
|
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||||
|
|
||||||
|
[Node] public Sprite3D Sprite { get; set; } = default!;
|
||||||
|
|
||||||
|
public IInventoryItem Item { get; set; }
|
||||||
|
|
||||||
|
public void OnResolved()
|
||||||
|
{
|
||||||
|
BodyEntered += DroppedItem_BodyEntered;
|
||||||
|
GlobalPosition = Game.Player.GlobalPosition + Vector3.Up;
|
||||||
|
Sprite.Texture = Item.Info.Texture;
|
||||||
|
AddCollisionExceptionWith((Node)Game.Player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Drop()
|
||||||
|
{
|
||||||
|
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||||
|
await ToSignal(GetTree().CreateTimer(1.5), "timeout");
|
||||||
|
RemoveCollisionExceptionWith((Node)Game.Player);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DroppedItem_BodyEntered(Node body)
|
||||||
|
{
|
||||||
|
if (body is IPlayer player)
|
||||||
|
{
|
||||||
|
var isAdded = GameRepo.PlayerData.Inventory.TryAdd(Item);
|
||||||
|
if (isAdded)
|
||||||
|
QueueFree();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/items/dropped/DroppedItem.tscn
Normal file
25
src/items/dropped/DroppedItem.tscn
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://brq11lswpqxei"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://src/items/dropped/DroppedItem.cs" id="1_67jk4"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="2_cu1v3"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_28r8g"]
|
||||||
|
|
||||||
|
[node name="DroppedItem" type="RigidBody3D"]
|
||||||
|
collision_layer = 4
|
||||||
|
axis_lock_angular_x = true
|
||||||
|
axis_lock_angular_y = true
|
||||||
|
axis_lock_angular_z = true
|
||||||
|
mass = 10.0
|
||||||
|
contact_monitor = true
|
||||||
|
max_contacts_reported = 50
|
||||||
|
script = ExtResource("1_67jk4")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
shape = SubResource("SphereShape3D_28r8g")
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
pixel_size = 0.0005
|
||||||
|
billboard = 2
|
||||||
|
texture = ExtResource("2_cu1v3")
|
||||||
@@ -5,7 +5,7 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class ThrowableItem : Node3D, IInventoryItem
|
public partial class ThrowableItem : Node3D, IThrowableItem
|
||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
@@ -32,16 +32,13 @@ public partial class ThrowableItem : Node3D, IInventoryItem
|
|||||||
Pickup.BodyEntered += OnEntered;
|
Pickup.BodyEntered += OnEntered;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Throw(ThrowableItemStats throwableItemStats)
|
public void Throw()
|
||||||
{
|
{
|
||||||
var throwableScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownGeometricDice.tscn");
|
var throwableScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
|
||||||
var throwable = throwableScene.Instantiate<ThrownItem>();
|
var throwable = throwableScene.Instantiate<ThrownItem>();
|
||||||
|
throwable.ThrownItemStats = ThrowableItemInfo;
|
||||||
Game.AddChild(throwable);
|
Game.AddChild(throwable);
|
||||||
throwable.Throw(throwableItemStats);
|
throwable.Throw();
|
||||||
}
|
|
||||||
|
|
||||||
public void Drop()
|
|
||||||
{
|
|
||||||
GameRepo.PlayerData.Inventory.Remove(this);
|
GameRepo.PlayerData.Inventory.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
[gd_scene load_steps=5 format=3 uid="uid://b1twcuneob5kt"]
|
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://src/items/thrown/ThrownItem.cs" id="1_ig3yn"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="2_ia1qk"]
|
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_s4ym5"]
|
|
||||||
size = Vector3(0.288967, 0.302734, 0.28064)
|
|
||||||
|
|
||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_vebu3"]
|
|
||||||
viewport_path = NodePath("Sprite3D/SubViewport")
|
|
||||||
|
|
||||||
[node name="Hitbox" type="RigidBody3D"]
|
|
||||||
collision_layer = 17
|
|
||||||
collision_mask = 16
|
|
||||||
mass = 0.001
|
|
||||||
gravity_scale = 0.0
|
|
||||||
contact_monitor = true
|
|
||||||
max_contacts_reported = 1
|
|
||||||
script = ExtResource("1_ig3yn")
|
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00739601, 0.0986328, 0.137878)
|
|
||||||
shape = SubResource("BoxShape3D_s4ym5")
|
|
||||||
|
|
||||||
[node name="Sprite3D" type="Sprite3D" parent="."]
|
|
||||||
billboard = 2
|
|
||||||
double_sided = false
|
|
||||||
texture = SubResource("ViewportTexture_vebu3")
|
|
||||||
|
|
||||||
[node name="SubViewport" type="SubViewport" parent="Sprite3D"]
|
|
||||||
disable_3d = true
|
|
||||||
transparent_bg = true
|
|
||||||
handle_input_locally = false
|
|
||||||
size = Vector2i(100, 100)
|
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="Sprite3D/SubViewport"]
|
|
||||||
unique_name_in_owner = true
|
|
||||||
z_index = 100
|
|
||||||
scale = Vector2(0.1, 0.1)
|
|
||||||
texture = ExtResource("2_ia1qk")
|
|
||||||
centered = false
|
|
||||||
flip_h = true
|
|
||||||
@@ -10,27 +10,55 @@ public partial class ThrownItem : RigidBody3D
|
|||||||
|
|
||||||
[Dependency] public IGame Game => this.DependOn<IGame>();
|
[Dependency] public IGame Game => this.DependOn<IGame>();
|
||||||
|
|
||||||
[Node] public Sprite2D Sprite { get; set; } = default!;
|
public InventoryItemStats ThrownItemStats;
|
||||||
|
|
||||||
private int _damage = 0;
|
[Node] public Sprite3D Sprite { get; set; } = default!;
|
||||||
|
|
||||||
public void OnResolved()
|
public void OnResolved()
|
||||||
{
|
{
|
||||||
BodyEntered += ThrownItem_BodyEntered;
|
BodyEntered += ThrownItem_BodyEntered;
|
||||||
GlobalPosition = Game.Player.GlobalPosition + Vector3.Up;
|
GlobalPosition = Game.Player.GlobalPosition + Vector3.Up;
|
||||||
|
Sprite.Texture = ThrownItemStats.Texture;
|
||||||
AddCollisionExceptionWith((Node)Game.Player);
|
AddCollisionExceptionWith((Node)Game.Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ThrownItem_BodyEntered(Node body)
|
private void ThrownItem_BodyEntered(Node body)
|
||||||
{
|
{
|
||||||
if (body is IEnemy enemy)
|
if (body is IEnemy enemy)
|
||||||
enemy.EnemyLogic.Input(new EnemyLogic.Input.HitByPlayer(_damage));
|
{
|
||||||
|
if (ThrownItemStats is ThrowableItemStats throwableItemStats)
|
||||||
|
enemy.EnemyLogic.Input(new EnemyLogic.Input.HitByPlayer(throwableItemStats.Damage));
|
||||||
|
}
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Throw(ThrowableItemStats throwableItemStats)
|
public void Throw()
|
||||||
{
|
{
|
||||||
_damage = throwableItemStats.Damage;
|
ThrowInternal((dynamic)ThrownItemStats);
|
||||||
ApplyCentralImpulse(Game.Player.GlobalBasis.Z.Normalized() * -20.0f);
|
}
|
||||||
|
|
||||||
|
private void ThrowInternal(WeaponStats weaponStats)
|
||||||
|
{
|
||||||
|
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThrowInternal(ArmorStats armorStats)
|
||||||
|
{
|
||||||
|
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThrowInternal(AccessoryStats accessoryStats)
|
||||||
|
{
|
||||||
|
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThrowInternal(ConsumableItemStats consumableItemStats)
|
||||||
|
{
|
||||||
|
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 5.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ThrowInternal(ThrowableItemStats throwableItemStats)
|
||||||
|
{
|
||||||
|
ApplyCentralImpulse(-Game.Player.GlobalBasis.Z.Normalized() * 20.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/items/thrown/ThrownItem.tscn
Normal file
26
src/items/thrown/ThrownItem.tscn
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
[gd_scene load_steps=4 format=3 uid="uid://b1twcuneob5kt"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://src/items/thrown/ThrownItem.cs" id="1_wlplc"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://mi70lolgtf3n" path="res://src/items/throwable/textures/GEOMANCER-DICE.png" id="2_alcjn"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_s4ym5"]
|
||||||
|
size = Vector3(0.288967, 0.302734, 0.28064)
|
||||||
|
|
||||||
|
[node name="Hitbox" type="RigidBody3D"]
|
||||||
|
collision_layer = 17
|
||||||
|
collision_mask = 16
|
||||||
|
mass = 0.001
|
||||||
|
gravity_scale = 0.0
|
||||||
|
contact_monitor = true
|
||||||
|
max_contacts_reported = 1
|
||||||
|
script = ExtResource("1_wlplc")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00739601, 0.0986328, 0.137878)
|
||||||
|
shape = SubResource("BoxShape3D_s4ym5")
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite3D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
pixel_size = 0.001
|
||||||
|
billboard = 2
|
||||||
|
texture = ExtResource("2_alcjn")
|
||||||
@@ -5,7 +5,7 @@ using Godot;
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
[Meta(typeof(IAutoNode))]
|
[Meta(typeof(IAutoNode))]
|
||||||
public partial class Weapon : Node3D, IInventoryItem, IEquipable
|
public partial class Weapon : Node3D, IInventoryItem, IEquipableItem
|
||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
|
|
||||||
@@ -13,6 +13,9 @@ public partial class Weapon : Node3D, IInventoryItem, IEquipable
|
|||||||
|
|
||||||
public InventoryItemStats Info => WeaponStats;
|
public InventoryItemStats Info => WeaponStats;
|
||||||
|
|
||||||
|
[Signal]
|
||||||
|
public delegate void EquippedItemEventHandler(Weapon equippedWeapon);
|
||||||
|
|
||||||
[Export]
|
[Export]
|
||||||
public WeaponStats WeaponStats { get; set; } = new WeaponStats();
|
public WeaponStats WeaponStats { get; set; } = new WeaponStats();
|
||||||
|
|
||||||
@@ -28,6 +31,16 @@ public partial class Weapon : Node3D, IInventoryItem, IEquipable
|
|||||||
Pickup.BodyEntered += OnEntered;
|
Pickup.BodyEntered += OnEntered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Equip()
|
||||||
|
{
|
||||||
|
EmitSignal(SignalName.EquippedItem, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unequip()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void Throw()
|
public void Throw()
|
||||||
{
|
{
|
||||||
GameRepo.PlayerData.Inventory.Remove(this);
|
GameRepo.PlayerData.Inventory.Remove(this);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -4,8 +4,8 @@ state "PlayerLogic State" as GameJamDungeon_PlayerLogic_State {
|
|||||||
state "Attacking" as GameJamDungeon_PlayerLogic_State_Attacking
|
state "Attacking" as GameJamDungeon_PlayerLogic_State_Attacking
|
||||||
state "Idle" as GameJamDungeon_PlayerLogic_State_Idle
|
state "Idle" as GameJamDungeon_PlayerLogic_State_Idle
|
||||||
}
|
}
|
||||||
state "Disabled" as GameJamDungeon_PlayerLogic_State_Disabled
|
|
||||||
state "Dead" as GameJamDungeon_PlayerLogic_State_Dead
|
state "Dead" as GameJamDungeon_PlayerLogic_State_Dead
|
||||||
|
state "Disabled" as GameJamDungeon_PlayerLogic_State_Disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
GameJamDungeon_PlayerLogic_State_Alive --> GameJamDungeon_PlayerLogic_State_Alive : Moved
|
GameJamDungeon_PlayerLogic_State_Alive --> GameJamDungeon_PlayerLogic_State_Alive : Moved
|
||||||
|
|||||||
Reference in New Issue
Block a user