using System.Collections; using System.Collections.Generic; using Invector.vCharacterController; using TMPro; using UnityEngine; namespace Beyond { public class AttributesWindowController : MonoBehaviour { [SerializeField] private TMP_Text title, value; [SerializeField] private TMP_Text currentDescription, maturityDescription, healthDescription, faithDescription, staminaDescription, brightnessDescription; [SerializeField] private TMP_Text maturityValue, healthValue, faithValue, staminaValue, brightnessValue; [SerializeField] private CanvasGroup maturitySelectorGroup, healthSelectorGroup, faithSelectorGroup, staminaSelectorGroup, focusSelectorGroup, currentSelectorGroup; [SerializeField] private vThirdPersonController thirdPersonController; private float notSelectedAlpha = 0.9f; public void OpenAttributes() { SetProperValues(); SetMaturity(); } public void SetProperValues() { PlayerAttribute attribute = Player.Instance.GetAttribute("Maturity"); float value = attribute.AttributeCurrentValue; float maxValue = attribute.AttributeMaxValue; maturityValue.text = (int)value + "/" + maxValue; attribute = Player.Instance.GetAttribute("BrightnessPoints"); value = attribute.AttributeCurrentValue; maxValue = attribute.AttributeMaxValue; brightnessValue.text = (int)value + "/" + maxValue; attribute = Player.Instance.GetAttribute("Faith"); value = attribute.AttributeCurrentValue; maxValue = attribute.AttributeMaxValue; faithValue.text = (int)value + "/" + maxValue; healthValue.text = (int)thirdPersonController.currentHealth + "/" + thirdPersonController.maxHealth; staminaValue.text = (int)thirdPersonController.currentStamina + "/" + (int)thirdPersonController.maxStamina; } public void SetMaturity() { SetNewSelectorGroup(maturitySelectorGroup); SetNewDescription(maturityDescription); title.text = "Maturity"; value.text = maturityValue.text; } public void SetNewSelectorGroup(CanvasGroup newGroup) { if (currentSelectorGroup) { currentSelectorGroup.alpha = notSelectedAlpha; } currentSelectorGroup = newGroup; currentSelectorGroup.alpha = 1f; } private void SetNewDescription(TMP_Text newDescription) { if (currentDescription) { currentDescription.gameObject.SetActive(false); } currentDescription = newDescription; currentDescription.gameObject.SetActive(true); } public void SetHealth() { SetNewSelectorGroup(healthSelectorGroup); SetNewDescription(healthDescription); title.text = "Health"; value.text = healthValue.text; } public void SetFaith() { SetNewSelectorGroup(faithSelectorGroup); SetNewDescription(faithDescription); title.text = "Faith"; value.text = faithValue.text; } public void SetStamina() { SetNewSelectorGroup(staminaSelectorGroup); SetNewDescription(staminaDescription); title.text = "Stamina"; value.text = staminaValue.text; } public void SetFocus() { SetNewSelectorGroup(focusSelectorGroup); SetNewDescription(brightnessDescription); title.text = "Brightness"; value.text = brightnessValue.text; } public void CloseAttributes() { } } }