ReisenTasker/Assets/Scripts/Microgame/MarisaPotionMaker.cs
2026-09-04 11:51:28 -07:00

83 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class MarisaPotionMaker : MicroGameHandler
{
#region Statication
public static MarisaPotionMaker instance;
private void Awake()
{
if (instance != null && instance != this)
{
Destroy(gameObject);
return;
}
instance = this;
}
#endregion
public MicrogamePotion currentPotion;
public List<MicrogamePotion> requestedPotions = new();
public List<MicrogamePotion> completedPotions = new();
public List<MicrogamePotion> failedPotions = new(); //bad to have 3 lists but whatever.
public int currentPotionIndex;
[SerializeField] private TextMeshProUGUI potionRecipeTitle;
[SerializeField] private TextMeshProUGUI potionRecipeText;
public void StartPotion(MicrogamePotion potionRequested)
{
}
private void Start()
{
UpdateUI();
}
public void UpdateUI()
{
//supposed to check off every chemical once added but i'll input that later
//for now i have to initialize the ui
potionRecipeTitle.text = currentPotion.potionName;
string recipe = "";
for (int i = 0; i < currentPotion.chemicals.Length; i++)
{
recipe += $"{i+1}. {currentPotion.chemicals[i].chemicalName}\n";
}
potionRecipeText.text = recipe;
}
public void AddChemical(Chemical chemical)
{
if (currentPotion.chemicals[currentPotionIndex].chemicalName == chemical.chemicalName ) //string comparisons are bad but i don't give a fuck
{
currentPotionIndex++;
if (currentPotion.chemicals.Length <= currentPotionIndex)
{
CompletePotion(currentPotion, true);
currentPotionIndex = 0;
}
}
else
{
CompletePotion(currentPotion, false);
}
}
public void CompletePotion(MicrogamePotion potion, bool success)
{
requestedPotions.Remove(potion); //doesn't work if there's multiple of the same potion....
if (success)
{
completedPotions.Add(potion);
}
else
{
failedPotions.Add(potion);
}
}
}