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

55 lines
1.7 KiB
C#
Raw Normal View History

2024-12-15 01:39:39 +00:00
using CodeStage.AntiCheat.ObscuredTypes;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class StatChangeUI : MonoBehaviourSingletonTemplate<StatChangeUI>
{
public GameObject go_child;
public TextMeshProUGUI label_statchange;
Dictionary<eStat, ObscuredDouble> dic_StatValue_Before = new Dictionary<eStat, ObscuredDouble>();
private void Start()
{
Off();
}
public void Set(bool before, Dictionary<eStat, ObscuredDouble> dic)
{
if (before)
{
dic_StatValue_Before.Clear();
foreach (var item in dic)
dic_StatValue_Before.Add(item.Key, item.Value);
}
else
{
label_statchange.text = "";
foreach (var item in dic)
{
var v_before = dic_StatValue_Before[item.Key];
var v_after = dic[item.Key];
if (v_after > v_before)
label_statchange.text += $"<color=green>{MyText.Get_StatNameValueText(item.Key, v_before)} >> {MyText.Get_StatValueText(item.Key, v_after)}\n";
else if (v_after < v_before)
label_statchange.text += $"<color=red>{MyText.Get_StatNameValueText(item.Key, v_before)} >> {MyText.Get_StatValueText(item.Key, v_after)}\n";
}
if (!string.IsNullOrEmpty(label_statchange.text))
{
go_child.SetActive(true);
if (IsInvoking("Off")) CancelInvoke();
Invoke("Off", 5f);
}
else
Off();
}
}
void Off()
{
go_child.SetActive(false);
}
}