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