Files
Ultimate-Fishing-Simulator-…/Assets/Scripts/Assembly-CSharp/UI_ActionCounter.cs
2026-03-04 09:37:33 +08:00

60 lines
1.1 KiB
C#

using Obvious.Soap;
using UnityEngine;
using UnityEngine.UI;
public class UI_ActionCounter : MonoBehaviour
{
public FloatVariable actionCounter;
public FloatVariable throwDistance;
public FloatVariable maxCastPower;
[SerializeField]
private GameObject counterObject;
[SerializeField]
private Image barImage;
public float fadeDuration = 0.2f;
private void Start()
{
counterObject.SetActive(value: false);
}
private void Awake()
{
actionCounter.OnValueChanged += ActionCounterOnOnValueChanged;
throwDistance.OnValueChanged += ThrowDistanceOnOnValueChanged;
}
private void OnDestroy()
{
actionCounter.OnValueChanged -= ActionCounterOnOnValueChanged;
throwDistance.OnValueChanged -= ThrowDistanceOnOnValueChanged;
}
private void ThrowDistanceOnOnValueChanged(float obj)
{
barImage.fillAmount = obj / maxCastPower.Value;
}
private void ShowMetersText(bool show, bool instant = false)
{
if (show)
{
counterObject.SetActive(value: true);
}
else
{
counterObject.SetActive(value: false);
}
}
private void ActionCounterOnOnValueChanged(float value)
{
ShowMetersText(value > 0f);
}
}