Refactoring game logic
This commit is contained in:
@@ -80,8 +80,6 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
private EffectService _effectService;
|
||||
|
||||
private double _expRate = 1;
|
||||
|
||||
public void Setup()
|
||||
{
|
||||
_container = new SimpleInjector.Container();
|
||||
@@ -194,13 +192,15 @@ public partial class Game : Node3D, IGame
|
||||
.Handle((in GameLogic.Output.ShowFloorClearMenu _) => { FloorClearMenu.Show(); FloorClearMenu.FadeIn(); })
|
||||
.Handle((in GameLogic.Output.ExitFloorClearMenu _) => { FloorClearMenu.FadeOut(); })
|
||||
.Handle((in GameLogic.Output.OpenInventory _) => { InGameUI.ShowInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(true); })
|
||||
.Handle((in GameLogic.Output.HideInventory _) => { InGameUI.HideInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.CloseInventory _) => { InGameUI.HideInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowMiniMap _) => { InGameUI.ShowMiniMap(); })
|
||||
.Handle((in GameLogic.Output.HideMiniMap _) => { InGameUI.HideMiniMap(); })
|
||||
.Handle((in GameLogic.Output.ShowAskForTeleport _) => { GameRepo.Pause(); InGameUI.UseTeleportPrompt.FadeIn(); InGameUI.SetProcessInput(true); })
|
||||
.Handle((in GameLogic.Output.HideAskForTeleport _) => { GameRepo.Resume(); InGameUI.UseTeleportPrompt.FadeOut(); InGameUI.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowLostScreen _) => { DeathMenu.Show(); DeathMenu.FadeIn(); })
|
||||
.Handle((in GameLogic.Output.ExitLostScreen _) => { DeathMenu.FadeOut(); })
|
||||
.Handle((in GameLogic.Output.AnnounceMessage output) => { AnnounceMessageOnMainScreen(output.Message); })
|
||||
.Handle((in GameLogic.Output.DoubleExpTimeStart output) => { DoubleEXPTimer.WaitTime = output.lengthOfTimeInSeconds; DoubleEXPTimer.Start(); })
|
||||
.Handle((in GameLogic.Output.SaveGame _) =>
|
||||
{
|
||||
SaveFile.Save();
|
||||
@@ -284,9 +284,6 @@ public partial class Game : Node3D, IGame
|
||||
{
|
||||
switch (effectItem.UsableItemTag)
|
||||
{
|
||||
case UsableItemTag.DoubleEXP:
|
||||
DoubleEXP(TimeSpan.FromSeconds(30));
|
||||
break;
|
||||
case UsableItemTag.TeleportAllEnemiesToRoom:
|
||||
_effectService.TeleportEnemiesToCurrentRoom();
|
||||
break;
|
||||
@@ -324,6 +321,9 @@ public partial class Game : Node3D, IGame
|
||||
}
|
||||
if (item is ThrowableItem throwableItem)
|
||||
{
|
||||
if (throwableItem.ThrowableItemTag == ThrowableItemTag.DoubleExp)
|
||||
GameRepo.StartDoubleEXP(TimeSpan.FromSeconds(30));
|
||||
|
||||
if (throwableItem.HealHPAmount > 0)
|
||||
Player.HealHP(throwableItem.HealHPAmount);
|
||||
if (throwableItem.HealVTAmount > 0)
|
||||
@@ -373,7 +373,7 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
public void EnemyDefeated(Vector3 defeatedLocation, EnemyStatResource resource)
|
||||
{
|
||||
Player.GainExp(resource.ExpFromDefeat * _expRate);
|
||||
Player.GainExp(resource.ExpFromDefeat * GameRepo.ExpRate);
|
||||
}
|
||||
|
||||
private void DropRestorative(Vector3 vector)
|
||||
@@ -441,19 +441,9 @@ public partial class Game : Node3D, IGame
|
||||
GetTree().Paused = isPaused;
|
||||
}
|
||||
|
||||
public async void DoubleEXP(TimeSpan lengthOfEffect)
|
||||
{
|
||||
ToggleInventory();
|
||||
AnnounceMessageOnMainScreen("Experience points temporarily doubled.");
|
||||
DoubleEXPTimer.Start(lengthOfEffect.Seconds);
|
||||
_expRate = 2;
|
||||
}
|
||||
|
||||
private void DoubleEXPTimer_Timeout()
|
||||
{
|
||||
DoubleEXPTimer.Stop();
|
||||
_expRate = 1;
|
||||
AnnounceMessageOnMainScreen("Experience points effect wore off.");
|
||||
GameRepo.EndDoubleExp();
|
||||
}
|
||||
|
||||
private void InventoryMenu_CloseInventory() => GameLogic.Input(new GameLogic.Input.CloseInventory());
|
||||
|
||||
Reference in New Issue
Block a user