Files
trail-into-darkness/Assets/Code/GameState/UI/AdventureView.cs
2026-04-12 19:14:37 +02:00

61 lines
2.4 KiB
C#

using Jovian.Calendar;
using Nox.Core;
namespace Nox.Game.UI {
public class AdventureView : IMenuView {
private readonly GameDataState gameDataState;
private readonly GuiReferences guiReferences;
private readonly InputSystem_Actions inputActions;
private readonly AdventureData adventureData;
private readonly AdventureSettings adventureSettings;
private readonly WorldClock worldClock;
private int currentDay;
private int previousTime;
public AdventureView(GameDataState gameDataState,
GuiReferences guiReferences,
InputSystem_Actions inputActions,
AdventureData adventureData,
AdventureSettings adventureSettings,
WorldClock worldClock) {
this.gameDataState = gameDataState;
this.guiReferences = guiReferences;
this.inputActions = inputActions;
this.adventureData = adventureData;
this.adventureSettings = adventureSettings;
this.worldClock = worldClock;
}
private void InvokePauseMenu() {
gameDataState.ChangePlayMode(PlayMode.PauseMenu);
}
public void Initialize() {
guiReferences.pauseMenuButton.onClick.AddListener(InvokePauseMenu);
guiReferences.dayText.text = $"{worldClock.FullStringNamed()}";
previousTime = -1;
guiReferences.suppliesBar.fillAmount = (float)adventureData.suppliesAvailable / adventureSettings.maxSupplies;
guiReferences.suppliesText.text = $"{adventureData.suppliesAvailable}/{adventureSettings.maxSupplies}";
}
public void Show() {
throw new System.NotImplementedException();
}
public void Hide() {
throw new System.NotImplementedException();
}
public void Tick() {
var time = worldClock.Now.minute;
if (time != previousTime) {
previousTime = time;
}
guiReferences.dayText.text = $"{worldClock.FullStringNamed()}";
if(currentDay != adventureData.currentDay) {
currentDay = adventureData.currentDay;
guiReferences.suppliesBar.fillAmount = (float)adventureData.suppliesAvailable / adventureSettings.maxSupplies;
guiReferences.suppliesText.text = $"{adventureData.suppliesAvailable}/{adventureSettings.maxSupplies}";
}
}
}
}