Restore Pause functionality
This commit is contained in:
@@ -221,8 +221,6 @@ public partial class Game : Node3D, IGame
|
|||||||
InGameUI.UseTeleportPrompt.TeleportToNextFloor += UseTeleportPrompt_TeleportToNextFloor;
|
InGameUI.UseTeleportPrompt.TeleportToNextFloor += UseTeleportPrompt_TeleportToNextFloor;
|
||||||
InGameUI.UseTeleportPrompt.CloseTeleportPrompt += UseTeleportPrompt_CloseTeleportPrompt;
|
InGameUI.UseTeleportPrompt.CloseTeleportPrompt += UseTeleportPrompt_CloseTeleportPrompt;
|
||||||
|
|
||||||
Player.Inventory.InventoryAtCapacity += PlayerInventory_InventoryAtCapacity;
|
|
||||||
Player.Inventory.PickedUpItem += Inventory_PickedUpItem;
|
|
||||||
FloorClearMenu.GoToNextFloor += FloorClearMenu_GoToNextFloor;
|
FloorClearMenu.GoToNextFloor += FloorClearMenu_GoToNextFloor;
|
||||||
FloorClearMenu.SaveAndExit += FloorClearMenu_SaveAndExit;
|
FloorClearMenu.SaveAndExit += FloorClearMenu_SaveAndExit;
|
||||||
FloorClearMenu.TransitionCompleted += FloorClearMenu_TransitionCompleted;
|
FloorClearMenu.TransitionCompleted += FloorClearMenu_TransitionCompleted;
|
||||||
@@ -244,6 +242,14 @@ public partial class Game : Node3D, IGame
|
|||||||
SaveFile.Load();
|
SaveFile.Load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void TogglePause()
|
||||||
|
{
|
||||||
|
if (GameLogic.Value is Paused)
|
||||||
|
GameLogic.Input(new GameLogic.Input.UnpauseGame());
|
||||||
|
else
|
||||||
|
GameLogic.Input(new GameLogic.Input.PauseGame());
|
||||||
|
}
|
||||||
|
|
||||||
public void ToggleInventory()
|
public void ToggleInventory()
|
||||||
{
|
{
|
||||||
if (GameLogic.Value is InventoryOpened)
|
if (GameLogic.Value is InventoryOpened)
|
||||||
@@ -263,11 +269,6 @@ public partial class Game : Node3D, IGame
|
|||||||
GameEventDepot.OnTeleportEntered();
|
GameEventDepot.OnTeleportEntered();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Inventory_PickedUpItem(string pickedUpItemName)
|
|
||||||
{
|
|
||||||
InGameUI.PlayerInfoUI.DisplayMessage($"{pickedUpItemName} picked up.");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UseItem(InventoryItem item)
|
public void UseItem(InventoryItem item)
|
||||||
{
|
{
|
||||||
if (item is ConsumableItem consumableItem)
|
if (item is ConsumableItem consumableItem)
|
||||||
@@ -447,7 +448,7 @@ public partial class Game : Node3D, IGame
|
|||||||
public async void DoubleEXP(TimeSpan lengthOfEffect)
|
public async void DoubleEXP(TimeSpan lengthOfEffect)
|
||||||
{
|
{
|
||||||
ToggleInventory();
|
ToggleInventory();
|
||||||
InGameUI.PlayerInfoUI.DisplayMessage("Experience points temporarily doubled.");
|
AnnounceMessageOnMainScreen("Experience points temporarily doubled.");
|
||||||
DoubleEXPTimer.Start(lengthOfEffect.Seconds);
|
DoubleEXPTimer.Start(lengthOfEffect.Seconds);
|
||||||
GameRepo.EXPRate = 2;
|
GameRepo.EXPRate = 2;
|
||||||
}
|
}
|
||||||
@@ -456,12 +457,7 @@ public partial class Game : Node3D, IGame
|
|||||||
{
|
{
|
||||||
DoubleEXPTimer.Stop();
|
DoubleEXPTimer.Stop();
|
||||||
GameRepo.EXPRate = 1;
|
GameRepo.EXPRate = 1;
|
||||||
InGameUI.PlayerInfoUI.DisplayMessage("Experience points effect wore off.");
|
AnnounceMessageOnMainScreen("Experience points effect wore off.");
|
||||||
}
|
|
||||||
|
|
||||||
private void PlayerInventory_InventoryAtCapacity(string rejectedItem)
|
|
||||||
{
|
|
||||||
InGameUI.PlayerInfoUI.DisplayMessage($"Could not pick up {rejectedItem}.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InventoryMenu_CloseInventory() => GameLogic.Input(new GameLogic.Input.CloseInventory());
|
private void InventoryMenu_CloseInventory() => GameLogic.Input(new GameLogic.Input.CloseInventory());
|
||||||
|
|||||||
@@ -40,4 +40,6 @@ public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvid
|
|||||||
public void Save();
|
public void Save();
|
||||||
|
|
||||||
public void Load();
|
public void Load();
|
||||||
|
|
||||||
|
public void TogglePause();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,9 @@ public interface IInventory : INode
|
|||||||
public void Remove(InventoryItem inventoryItem);
|
public void Remove(InventoryItem inventoryItem);
|
||||||
|
|
||||||
public void Sort();
|
public void Sort();
|
||||||
|
|
||||||
event Inventory.InventoryAtCapacityEventHandler InventoryAtCapacity;
|
|
||||||
|
|
||||||
event Inventory.PickedUpItemEventHandler PickedUpItem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Meta, Id("inventory")]
|
[Meta(typeof(IAutoNode)), Id("inventory")]
|
||||||
public partial class Inventory : Node, IInventory
|
public partial class Inventory : Node, IInventory
|
||||||
{
|
{
|
||||||
public override void _Notification(int what) => this.Notify(what);
|
public override void _Notification(int what) => this.Notify(what);
|
||||||
@@ -31,11 +27,6 @@ public partial class Inventory : Node, IInventory
|
|||||||
// TODO: Constants class with export
|
// TODO: Constants class with export
|
||||||
private const int _maxInventorySize = 20;
|
private const int _maxInventorySize = 20;
|
||||||
|
|
||||||
[Signal]
|
|
||||||
public delegate void InventoryAtCapacityEventHandler(string rejectedItemName);
|
|
||||||
[Signal]
|
|
||||||
public delegate void PickedUpItemEventHandler(string pickedUpItemName);
|
|
||||||
|
|
||||||
public Inventory()
|
public Inventory()
|
||||||
{
|
{
|
||||||
Items = [];
|
Items = [];
|
||||||
@@ -47,13 +38,9 @@ public partial class Inventory : Node, IInventory
|
|||||||
public bool TryAdd(InventoryItem inventoryItem)
|
public bool TryAdd(InventoryItem inventoryItem)
|
||||||
{
|
{
|
||||||
if (Items.Count >= _maxInventorySize)
|
if (Items.Count >= _maxInventorySize)
|
||||||
{
|
|
||||||
EmitSignal(SignalName.InventoryAtCapacity, inventoryItem.ItemName);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
Items.Add(inventoryItem);
|
Items.Add(inventoryItem);
|
||||||
EmitSignal(SignalName.PickedUpItem, inventoryItem.ItemName);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,23 +6,8 @@ using System;
|
|||||||
|
|
||||||
namespace GameJamDungeon;
|
namespace GameJamDungeon;
|
||||||
|
|
||||||
public interface IInventoryItem : INode3D
|
|
||||||
{
|
|
||||||
public Guid ID { get; }
|
|
||||||
|
|
||||||
string ItemName { get; }
|
|
||||||
|
|
||||||
string Description { get; }
|
|
||||||
|
|
||||||
float SpawnRate { get; }
|
|
||||||
|
|
||||||
double ThrowDamage { get; }
|
|
||||||
|
|
||||||
float ThrowSpeed { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
[Meta]
|
[Meta]
|
||||||
public abstract partial class InventoryItem : Node3D, IInventoryItem
|
public abstract partial class InventoryItem : Node3D
|
||||||
{
|
{
|
||||||
[Save("inventory_item_id")]
|
[Save("inventory_item_id")]
|
||||||
public Guid ID => Guid.NewGuid();
|
public Guid ID => Guid.NewGuid();
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ public partial class ItemDatabase : Node
|
|||||||
[Export]
|
[Export]
|
||||||
public PackedScene ConsumableItemScene { get; set; }
|
public PackedScene ConsumableItemScene { get; set; }
|
||||||
|
|
||||||
public IInventoryItem[] Initialize()
|
public InventoryItem[] Initialize()
|
||||||
{
|
{
|
||||||
var database = new List<IInventoryItem>();
|
var database = new List<InventoryItem>();
|
||||||
var armorResources = DirAccess.GetFilesAt("res://src/items/armor/resources/");
|
var armorResources = DirAccess.GetFilesAt("res://src/items/armor/resources/");
|
||||||
var weaponResources = DirAccess.GetFilesAt("res://src/items/weapons/resources/");
|
var weaponResources = DirAccess.GetFilesAt("res://src/items/weapons/resources/");
|
||||||
var accessoryResources = DirAccess.GetFilesAt("res://src/items/accessory/resources/");
|
var accessoryResources = DirAccess.GetFilesAt("res://src/items/accessory/resources/");
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ namespace GameJamDungeon;
|
|||||||
[Meta, Id("armor")]
|
[Meta, Id("armor")]
|
||||||
public partial class Armor : EquipableItem
|
public partial class Armor : EquipableItem
|
||||||
{
|
{
|
||||||
public override InventoryItemStats ItemStats { get => _armorStats; set => _armorStats = (ArmorStats)value; }
|
[Export]
|
||||||
|
|
||||||
private ArmorStats _armorStats { get; set; } = new ArmorStats();
|
private ArmorStats _armorStats { get; set; } = new ArmorStats();
|
||||||
|
|
||||||
public override string ItemName => _armorStats.Name;
|
public override string ItemName => _armorStats.Name;
|
||||||
@@ -25,4 +24,6 @@ public partial class Armor : EquipableItem
|
|||||||
public void IncreaseArmorDefense(int bonus) => _armorStats.Defense += bonus;
|
public void IncreaseArmorDefense(int bonus) => _armorStats.Defense += bonus;
|
||||||
|
|
||||||
public override ItemTag ItemTag => _armorStats.ItemTag;
|
public override ItemTag ItemTag => _armorStats.ItemTag;
|
||||||
|
|
||||||
|
public override InventoryItemStats ItemStats { get => _armorStats; set => _armorStats = (ArmorStats)value; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem
|
|||||||
AddCollisionExceptionWith((Node)Player);
|
AddCollisionExceptionWith((Node)Player);
|
||||||
GlobalPosition = Player.CurrentPosition + Vector3.Up;
|
GlobalPosition = Player.CurrentPosition + Vector3.Up;
|
||||||
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * 5.0f);
|
ApplyCentralImpulse(-Player.CurrentBasis.Z.Normalized() * 5.0f);
|
||||||
await ToSignal(GetTree().CreateTimer(1.5), "timeout");
|
await ToSignal(GetTree().CreateTimer(1), "timeout");
|
||||||
RemoveCollisionExceptionWith((Node)Player);
|
RemoveCollisionExceptionWith((Node)Player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem
|
|||||||
{
|
{
|
||||||
if (body is IPlayer player)
|
if (body is IPlayer player)
|
||||||
{
|
{
|
||||||
var isAdded = Player.Inventory.TryAdd(Item);
|
var isAdded = player.Inventory.TryAdd(Item);
|
||||||
if (isAdded)
|
if (isAdded)
|
||||||
QueueFree();
|
QueueFree();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,6 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
public delegate void InventoryButtonPressedEventHandler();
|
public delegate void InventoryButtonPressedEventHandler();
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void MinimapButtonHeldEventHandler();
|
public delegate void MinimapButtonHeldEventHandler();
|
||||||
[Signal]
|
|
||||||
public delegate void PauseButtonPressedEventHandler();
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Exports
|
#region Exports
|
||||||
@@ -224,7 +222,12 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
{
|
{
|
||||||
var isAdded = Inventory.TryAdd(inventoryItem);
|
var isAdded = Inventory.TryAdd(inventoryItem);
|
||||||
if (isAdded)
|
if (isAdded)
|
||||||
|
{
|
||||||
|
Game.AnnounceMessageOnMainScreen($"{inventoryItem.ItemName} picked up.");
|
||||||
inventoryItem.QueueFree();
|
inventoryItem.QueueFree();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Game.AnnounceMessageOnMainScreen($"Could not pick up {inventoryItem.ItemName}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +255,7 @@ public partial class Player : CharacterBody3D, IPlayer
|
|||||||
|
|
||||||
public void PlayerPause()
|
public void PlayerPause()
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.PauseButtonPressed);
|
Game.TogglePause();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IDungeonRoom GetCurrentRoom()
|
public IDungeonRoom GetCurrentRoom()
|
||||||
|
|||||||
Reference in New Issue
Block a user