52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public sealed class FurnacePanelUIView : MonoBehaviour
|
|
{
|
|
[SerializeField] private TMP_Text metalText;
|
|
[SerializeField] private TMP_Text selectedRecipeText;
|
|
[SerializeField] private TMP_Text statusText;
|
|
[SerializeField] private TMP_Text remainingTimeText;
|
|
[SerializeField] private Image metalImage;
|
|
[SerializeField] private Image progressImage;
|
|
[SerializeField] private Button startButton;
|
|
|
|
public void Render(
|
|
float storedMetal,
|
|
float metalCapacity,
|
|
SmeltingRecipe selectedRecipe,
|
|
FurnaceState state,
|
|
float processProgress,
|
|
float remainingSeconds,
|
|
bool canStart)
|
|
{
|
|
if (metalText != null)
|
|
metalText.text = $"METAL {storedMetal:0.#} / {metalCapacity:0.#}";
|
|
|
|
if (metalImage != null)
|
|
metalImage.fillAmount = metalCapacity > 0f ? storedMetal / metalCapacity : 0f;
|
|
|
|
if (selectedRecipeText != null)
|
|
{
|
|
selectedRecipeText.text = selectedRecipe != null
|
|
? $"{selectedRecipe.DisplayName} | {selectedRecipe.MetalCost:0.#} metal"
|
|
: "NO RECIPE";
|
|
}
|
|
|
|
if (statusText != null)
|
|
statusText.text = state == FurnaceState.Smelting ? "SMELTING" : "READY";
|
|
|
|
if (progressImage != null)
|
|
progressImage.fillAmount = processProgress;
|
|
|
|
if (remainingTimeText != null)
|
|
remainingTimeText.text = state == FurnaceState.Smelting
|
|
? $"{remainingSeconds:0.0}s"
|
|
: string.Empty;
|
|
|
|
if (startButton != null)
|
|
startButton.interactable = canStart;
|
|
}
|
|
}
|