Added Furnance and smelting
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user