2023-03-28 13:16:30 -04:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2023-04-07 13:27:43 -04:00
|
|
|
using UnityEngine.UI;
|
2023-03-28 13:16:30 -04:00
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
public class StatChangeInt : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private TextMeshProUGUI RemainingPoints;
|
|
|
|
[SerializeField] private TextMeshProUGUI EditingBox;
|
|
|
|
[SerializeField] private bool Adding;
|
|
|
|
[SerializeField] private GameObject CantChangeBox;
|
|
|
|
[SerializeField] private GameObject ChangeBoxParent;
|
2023-04-07 13:27:43 -04:00
|
|
|
[SerializeField] private Button MyButton;
|
|
|
|
[SerializeField] private List<Button> RightButtons;
|
|
|
|
[SerializeField] private List<Button> LeftButtons;
|
|
|
|
[SerializeField] private Button ThisLeftButton;
|
|
|
|
[SerializeField] private bool AddingDisabled = false;
|
|
|
|
|
2023-03-28 13:16:30 -04:00
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ChangeValue() {
|
|
|
|
int i = int.Parse(EditingBox.text);
|
|
|
|
int j = int.Parse(RemainingPoints.text);
|
|
|
|
if (Adding) {
|
2023-04-07 13:27:43 -04:00
|
|
|
if (EditingBox.text == "0") {
|
|
|
|
ThisLeftButton.interactable = true;
|
|
|
|
}
|
|
|
|
i += 1;
|
|
|
|
j -= 1;
|
|
|
|
RemainingPoints.text = j.ToString();
|
|
|
|
EditingBox.text = i.ToString();
|
|
|
|
|
2023-03-28 13:16:30 -04:00
|
|
|
if (RemainingPoints.text == "0") {
|
2023-04-07 13:27:43 -04:00
|
|
|
for (int k = 0; k < RightButtons.Count; k++) {
|
|
|
|
Button TheButton = RightButtons[k].GetComponent<Button>();
|
|
|
|
TheButton.interactable = false;
|
|
|
|
StatChangeInt ST = RightButtons[k].GetComponent<StatChangeInt>();
|
|
|
|
ST.AddingDisabled = true;
|
|
|
|
}
|
|
|
|
for (int k = 0; k < LeftButtons.Count; k++) {
|
|
|
|
StatChangeInt ST = LeftButtons[k].GetComponent<StatChangeInt>();
|
|
|
|
ST.AddingDisabled = true;
|
|
|
|
}
|
2023-03-28 13:16:30 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (EditingBox.text == "0") {
|
|
|
|
CantChangeBox.SetActive(true);
|
|
|
|
ChangeBoxParent.SetActive(true);
|
2023-04-07 13:27:43 -04:00
|
|
|
MyButton.interactable = false;
|
2023-03-28 13:16:30 -04:00
|
|
|
} else {
|
|
|
|
i -= 1;
|
|
|
|
j += 1;
|
|
|
|
RemainingPoints.text = j.ToString();
|
|
|
|
EditingBox.text = i.ToString();
|
2023-04-07 13:27:43 -04:00
|
|
|
if (EditingBox.text == "0") {
|
|
|
|
MyButton.interactable = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (AddingDisabled == true) {
|
|
|
|
for (int k = 0; k < RightButtons.Count; k++) {
|
|
|
|
Button TheButton = RightButtons[k].GetComponent<Button>();
|
|
|
|
TheButton.interactable = true;
|
|
|
|
StatChangeInt ST = RightButtons[k].GetComponent<StatChangeInt>();
|
|
|
|
ST.AddingDisabled = false;
|
|
|
|
}
|
|
|
|
for (int k = 0; k < LeftButtons.Count; k++) {
|
|
|
|
StatChangeInt ST = LeftButtons[k].GetComponent<StatChangeInt>();
|
|
|
|
ST.AddingDisabled = false;
|
|
|
|
}
|
2023-03-28 13:16:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|