Rework game over logic and game initialization
This commit is contained in:
@@ -2,7 +2,6 @@ using Chickensoft.AutoInject;
|
||||
using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using Godot;
|
||||
using Zennysoft.Ma.Adapter;
|
||||
|
||||
namespace Zennysoft.Game.Ma;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ public interface IFloorClearMenu : IControl
|
||||
{
|
||||
event FloorClearMenu.GoToNextFloorEventHandler GoToNextFloor;
|
||||
|
||||
event FloorClearMenu.SaveAndExitEventHandler SaveAndExit;
|
||||
event FloorClearMenu.ExitEventHandler Exit;
|
||||
|
||||
event FloorClearMenu.TransitionCompletedEventHandler TransitionCompleted;
|
||||
|
||||
@@ -27,7 +27,7 @@ public partial class FloorClearMenu : Control, IFloorClearMenu
|
||||
|
||||
[Node] public Button ContinueButton { get; set; } = default!;
|
||||
|
||||
[Node] public Button SaveAndExitButton { get; set; } = default!;
|
||||
[Node] public Button ExitButton { get; set; } = default!;
|
||||
|
||||
public void FadeIn() => AnimationPlayer.Play("fade_in");
|
||||
|
||||
@@ -38,27 +38,27 @@ public partial class FloorClearMenu : Control, IFloorClearMenu
|
||||
[Signal]
|
||||
public delegate void GoToNextFloorEventHandler();
|
||||
[Signal]
|
||||
public delegate void SaveAndExitEventHandler();
|
||||
public delegate void ExitEventHandler();
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
AnimationPlayer.AnimationFinished += AnimationPlayer_AnimationFinished;
|
||||
ContinueButton.Pressed += ContinueButton_Pressed;
|
||||
SaveAndExitButton.Pressed += SaveAndExitButton_Pressed;
|
||||
ExitButton.Pressed += ExitButton_Pressed;
|
||||
}
|
||||
|
||||
private void SaveAndExitButton_Pressed()
|
||||
private void ExitButton_Pressed()
|
||||
{
|
||||
ContinueButton.Disabled = true;
|
||||
SaveAndExitButton.Disabled = true;
|
||||
ExitButton.Disabled = true;
|
||||
FadeOut();
|
||||
EmitSignal(SignalName.SaveAndExit);
|
||||
EmitSignal(SignalName.Exit);
|
||||
}
|
||||
|
||||
private void ContinueButton_Pressed()
|
||||
{
|
||||
ContinueButton.Disabled = true;
|
||||
SaveAndExitButton.Disabled = true;
|
||||
ExitButton.Disabled = true;
|
||||
EmitSignal(SignalName.GoToNextFloor);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public partial class FloorClearMenu : Control, IFloorClearMenu
|
||||
if (animName == "fade_in")
|
||||
{
|
||||
ContinueButton.Disabled = false;
|
||||
SaveAndExitButton.Disabled = false;
|
||||
ExitButton.Disabled = false;
|
||||
ContinueButton.CallDeferred(MethodName.GrabFocus);
|
||||
}
|
||||
if (animName == "fade_out")
|
||||
|
||||
@@ -109,7 +109,7 @@ layout_mode = 2
|
||||
focus_neighbor_left = NodePath(".")
|
||||
focus_neighbor_top = NodePath(".")
|
||||
focus_neighbor_right = NodePath(".")
|
||||
focus_neighbor_bottom = NodePath("../SaveAndExitButton")
|
||||
focus_neighbor_bottom = NodePath("../ExitButton")
|
||||
theme_override_colors/font_color = Color(0.737255, 0.705882, 0.690196, 1)
|
||||
theme_override_colors/font_focus_color = Color(1, 0.94902, 0, 1)
|
||||
theme_override_fonts/font = ExtResource("2_xk0dh")
|
||||
@@ -120,7 +120,7 @@ button_mask = 0
|
||||
text = "Continue"
|
||||
flat = true
|
||||
|
||||
[node name="SaveAndExitButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
||||
[node name="ExitButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 50)
|
||||
layout_mode = 2
|
||||
@@ -135,5 +135,5 @@ theme_override_font_sizes/font_size = 36
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_cyd1c")
|
||||
theme_override_styles/normal = SubResource("StyleBoxEmpty_4bdva")
|
||||
button_mask = 0
|
||||
text = "Save and Exit"
|
||||
text = "Exit Tower"
|
||||
flat = true
|
||||
|
||||
@@ -28,8 +28,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
|
||||
[Dependency] public IPlayer Player => this.DependOn<IPlayer>();
|
||||
|
||||
[Dependency] public IMap _map => this.DependOn<IMap>();
|
||||
|
||||
private InventoryPageNumber _currentPageNumber = InventoryPageNumber.FirstPage;
|
||||
|
||||
private string ITEM_SLOT_SCENE = "res://src/ui/inventory_menu/ItemSlot.tscn";
|
||||
@@ -62,11 +60,24 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
[Node] public AnimationPlayer AnimationPlayer { get; set; } = default!;
|
||||
#endregion
|
||||
|
||||
public void OnReady()
|
||||
public InventoryMenu()
|
||||
{
|
||||
SetProcessInput(false);
|
||||
SetProcess(false);
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
UseButton.Pressed += UseButtonPressed;
|
||||
ThrowButton.Pressed += ThrowButtonPressed;
|
||||
DropButton.Pressed += DropButtonPressed;
|
||||
Player.AttackComponent.CurrentAttack.Sync += AttackSync;
|
||||
Player.AttackComponent.MaximumAttack.Sync += AttackSync;
|
||||
Player.EquipmentComponent.EquippedWeapon.Sync += BonusSync;
|
||||
Player.EquipmentComponent.EquippedArmor.Sync += BonusSync;
|
||||
Player.EquipmentComponent.EquippedAccessory.Sync += BonusSync;
|
||||
Player.DefenseComponent.CurrentDefense.Sync += DefenseSync;
|
||||
Player.DefenseComponent.MaximumDefense.Sync += DefenseSync;
|
||||
}
|
||||
|
||||
public void OnExitTree()
|
||||
@@ -80,18 +91,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
Player.DefenseComponent.MaximumDefense.Sync -= DefenseSync;
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
{
|
||||
SetProcessInput(false);
|
||||
Player.AttackComponent.CurrentAttack.Sync += AttackSync;
|
||||
Player.AttackComponent.MaximumAttack.Sync += AttackSync;
|
||||
Player.EquipmentComponent.EquippedWeapon.Sync += BonusSync;
|
||||
Player.EquipmentComponent.EquippedArmor.Sync += BonusSync;
|
||||
Player.EquipmentComponent.EquippedAccessory.Sync += BonusSync;
|
||||
Player.DefenseComponent.CurrentDefense.Sync += DefenseSync;
|
||||
Player.DefenseComponent.MaximumDefense.Sync += DefenseSync;
|
||||
}
|
||||
|
||||
public async Task DisplayMessage(string message)
|
||||
{
|
||||
SetProcessInput(false);
|
||||
@@ -125,8 +124,6 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
var inventory = Player.Inventory;
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiCancel))
|
||||
{
|
||||
if (UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus())
|
||||
@@ -145,8 +142,12 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
if (ItemSlots.Length == 0 || UseButton.HasFocus() || DropButton.HasFocus() || ThrowButton.HasFocus())
|
||||
return;
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiRight) && _currentPageNumber == InventoryPageNumber.FirstPage && inventory.Items.Count > _itemsPerPage)
|
||||
ChangeInventoryPage(InventoryPageNumber.SecondPage);
|
||||
if (@event.IsActionPressed(GameInputs.UiRight) && _currentPageNumber == InventoryPageNumber.FirstPage)
|
||||
{
|
||||
var inventory = Player.Inventory;
|
||||
if (inventory.Items.Count > _itemsPerPage)
|
||||
ChangeInventoryPage(InventoryPageNumber.SecondPage);
|
||||
}
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.UiLeft) && _currentPageNumber == InventoryPageNumber.SecondPage)
|
||||
ChangeInventoryPage(InventoryPageNumber.FirstPage);
|
||||
@@ -186,6 +187,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
|
||||
if (@event.IsActionPressed(GameInputs.InventorySort))
|
||||
{
|
||||
var inventory = Player.Inventory;
|
||||
inventory.Sort(Player.EquipmentComponent.EquippedWeapon.Value, Player.EquipmentComponent.EquippedArmor.Value, Player.EquipmentComponent.EquippedAccessory.Value);
|
||||
if (_currentIndex > inventory.Items.Count - 1)
|
||||
_currentIndex = inventory.Items.Count - 1;
|
||||
@@ -357,7 +359,7 @@ public partial class InventoryMenu : Control, IInventoryMenu
|
||||
else
|
||||
{
|
||||
ItemEffectLabel.Text = $"{equippableItem.GetType().Name} equipped.";
|
||||
Player.EquipmentComponent.Equip(equippableItem);
|
||||
Player.Equip(equippableItem);
|
||||
itemSlot.SetEquippedSelectedItemStyle();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public partial class PauseDebugMenu : Control, IDebugMenu
|
||||
{
|
||||
LoadNextFloorButton.Pressed += LoadNextFloorButton_Pressed;
|
||||
|
||||
_itemDatabase = new ItemDatabase();
|
||||
_itemDatabase = ItemDatabase.Instance;
|
||||
_spawnableItems = _itemDatabase.Items;
|
||||
|
||||
_spawnableEnemies =
|
||||
|
||||
Reference in New Issue
Block a user