68 lines
1.4 KiB
C#
68 lines
1.4 KiB
C#
using EnergyBarToolkit;
|
|
using UIWidgets;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PlayerExperienceWidget : MonoBehaviour
|
|
{
|
|
public Text levelValueText;
|
|
|
|
public EnergyBar expEnergyBar;
|
|
|
|
public FilledRendererUGUI filledRendererUGUI;
|
|
|
|
public Tooltip tooltip;
|
|
|
|
public bool withTooltip;
|
|
|
|
public bool smoothChange;
|
|
|
|
private PlayerSettingsMy playerSettings;
|
|
|
|
private void Awake()
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
if (playerSettings == null && (bool)GlobalSettings.Instance)
|
|
{
|
|
playerSettings = GlobalSettings.Instance.playerSettings;
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (!(playerSettings == null))
|
|
{
|
|
levelValueText.text = playerSettings.playersLevel.ToString();
|
|
if ((int)playerSettings.playersLevel == (int)playerSettings.maxPlayerLevel)
|
|
{
|
|
expEnergyBar.SetValueMin(0);
|
|
expEnergyBar.SetValueMax(1);
|
|
expEnergyBar.SetValueCurrent(1);
|
|
}
|
|
else
|
|
{
|
|
expEnergyBar.SetValueMin(playerSettings.GetThresholdExperience((int)playerSettings.playersLevel - 1));
|
|
expEnergyBar.SetValueMax(playerSettings.GetThresholdExperience(playerSettings.playersLevel));
|
|
expEnergyBar.SetValueCurrent(playerSettings.playersExperience);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
if ((bool)tooltip)
|
|
{
|
|
tooltip.enabled = withTooltip;
|
|
tooltip.TooltipObject.SetActive(withTooltip);
|
|
}
|
|
if ((bool)filledRendererUGUI)
|
|
{
|
|
filledRendererUGUI.effectSmoothChange = smoothChange;
|
|
}
|
|
}
|
|
}
|