Start refactoring UI concerns away from game and into UI logic class
This commit is contained in:
@@ -42,8 +42,6 @@ public partial class GameLogic
|
||||
|
||||
public readonly record struct SaveGame;
|
||||
|
||||
public readonly record struct AnnounceMessage(string Message);
|
||||
|
||||
public readonly record struct DoubleExpTimeStart(int lengthOfTimeInSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ public partial class GameLogic
|
||||
gameRepo.IsPaused.Sync += OnIsPaused;
|
||||
gameRepo.OpenInventory += OnOpenInventory;
|
||||
gameRepo.CloseInventory += OnCloseInventory;
|
||||
gameRepo.AnnounceMessage += OnAnnounceMessage;
|
||||
gameRepo.DoubleExpTimeStart += OnDoubleExpTimeStart;
|
||||
});
|
||||
OnDetach(() =>
|
||||
@@ -25,7 +24,6 @@ public partial class GameLogic
|
||||
gameRepo.IsPaused.Sync -= OnIsPaused;
|
||||
gameRepo.OpenInventory -= OnOpenInventory;
|
||||
gameRepo.CloseInventory -= OnCloseInventory;
|
||||
gameRepo.AnnounceMessage -= OnAnnounceMessage;
|
||||
gameRepo.DoubleExpTimeStart -= OnDoubleExpTimeStart;
|
||||
});
|
||||
}
|
||||
@@ -34,8 +32,6 @@ public partial class GameLogic
|
||||
|
||||
private void OnCloseInventory() => Output(new Output.CloseInventory());
|
||||
|
||||
private void OnAnnounceMessage(string message) => Output(new Output.AnnounceMessage(message));
|
||||
|
||||
private void OnDoubleExpTimeStart(int lengthOfTimeInSeconds) => Output(new Output.DoubleExpTimeStart(lengthOfTimeInSeconds));
|
||||
|
||||
public void OnIsPaused(bool isPaused) => Output(new Output.SetPauseMode(isPaused));
|
||||
|
||||
@@ -27,6 +27,8 @@ public interface IGameRepo : IDisposable
|
||||
|
||||
public void EndDoubleExp();
|
||||
|
||||
public void AnnounceMessageOnMainScreen(string message);
|
||||
|
||||
public double ExpRate { get; }
|
||||
}
|
||||
|
||||
@@ -67,17 +69,22 @@ public class GameRepo : IGameRepo
|
||||
public void StartDoubleEXP(TimeSpan lengthOfEffect)
|
||||
{
|
||||
CloseInventory?.Invoke();
|
||||
AnnounceMessage?.Invoke("Experience points temporarily doubled.");
|
||||
AnnounceMessageOnMainScreen("Experience points temporarily doubled.");
|
||||
DoubleExpTimeStart?.Invoke(lengthOfEffect.Seconds);
|
||||
ExpRate = 2;
|
||||
}
|
||||
|
||||
public void EndDoubleExp()
|
||||
{
|
||||
AnnounceMessage?.Invoke("Experience points effect wore off.");
|
||||
AnnounceMessageOnMainScreen("Experience points effect wore off.");
|
||||
ExpRate = 1;
|
||||
}
|
||||
|
||||
public void AnnounceMessageOnMainScreen(string message)
|
||||
{
|
||||
AnnounceMessage?.Invoke(message);
|
||||
}
|
||||
|
||||
public void OnGameEnded()
|
||||
{
|
||||
Pause();
|
||||
|
||||
Reference in New Issue
Block a user