Project_WL/Assets/Script/UI/Common/ArrowUI.cs

70 lines
1.9 KiB
C#
Raw Permalink Normal View History

2024-12-15 01:39:39 +00:00
using CodeStage.AntiCheat.ObscuredTypes;
using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ArrowUI : MonoBehaviour
{
public Image[] images_unit; // 0 1, 1 10, 2 100
public TextMeshProUGUI label_count;
ObscuredInt m_TotalAmount, m_MaxCount;
2025-01-23 20:50:53 +00:00
int m_Unit, m_UnitIndex = 0, m_MinValue;
2024-12-15 01:39:39 +00:00
Action<int> m_Act;
2025-01-23 20:50:53 +00:00
public void Set(Action<int> _act, int _maxCount, bool _setMax = true, int _minvalue = 0)
2024-12-15 01:39:39 +00:00
{
m_Act = _act;
m_MaxCount = _maxCount;
m_MaxCount.RandomizeCryptoKey();
2025-01-23 20:50:53 +00:00
m_MinValue = _minvalue;
2024-12-15 01:39:39 +00:00
OnClick_Unit(m_UnitIndex);
if (_setMax) OnClick_RightMax();
else OnClick_LeftMax();
}
void Set_Label()
{
m_TotalAmount.RandomizeCryptoKey();
label_count.text = DSUtil.GetThousandCommaText(m_TotalAmount);
m_Act?.Invoke(m_TotalAmount);
}
public void OnClick_LeftMax()
{
2025-01-23 20:50:53 +00:00
m_TotalAmount = m_MinValue;
2024-12-15 01:39:39 +00:00
Set_Label();
}
public void OnClick_Left()
{
m_TotalAmount -= m_Unit;
2025-01-23 20:50:53 +00:00
if (m_TotalAmount < m_MinValue)
m_TotalAmount = m_MinValue;
2024-12-15 01:39:39 +00:00
Set_Label();
}
public void OnClick_Right()
{
m_TotalAmount += m_Unit;
if (m_TotalAmount > m_MaxCount) m_TotalAmount = m_MaxCount;
Set_Label();
}
public void OnClick_RightMax()
{
m_TotalAmount = m_MaxCount;
Set_Label();
}
public int Get_TotalCount() { return m_TotalAmount; }
public void OnClick_Unit(int _index)
{
m_UnitIndex = _index;
for (int i = 0; i < images_unit.Length; i++)
images_unit[i].color = new Color32(105, 125, 149, 255);
images_unit[_index].color = new Color32(24, 193, 203, 255);
if (m_UnitIndex == 0) m_Unit = 1;
else if (m_UnitIndex == 1) m_Unit = 10;
else m_Unit = 100;
}
}