diff --git a/Assets/Scripts/UI/Components/CircularProgress.cs b/Assets/Scripts/UI/Components/CircularProgress.cs deleted file mode 100644 index 67c592fa5..000000000 --- a/Assets/Scripts/UI/Components/CircularProgress.cs +++ /dev/null @@ -1,142 +0,0 @@ -using System.Collections.Generic; -using TMPro; -using UnityEngine; -using UnityEngine.Events; -using UnityEngine.Localization.Settings; - -namespace AibisDream -{ - public class CircularProgress : MonoBehaviour - { - [SerializeField] private int currentValue; - - [SerializeField] private int maxValue = 10; - - [SerializeField] private float startAngle; - - [SerializeField] private float endAngle; - - [SerializeField] private Transform background; - - [SerializeField] private Transform foreground; - - [SerializeField] private SpriteRenderer bgTemplate; - - [SerializeField] private SpriteRenderer fgTemplate; - - [SerializeField] private TMP_Text tmpText; - - [SerializeField] private UnityEvent onValueChanged; - - private readonly List _bgList = new(); - private readonly List _fgList = new(); - - public int CurrentValue - { - get => currentValue; - set - { - if (currentValue == value) - { - return; - } - - currentValue = value; - OnValueChanged(); - UpdateGUI(); - } - } - - private float NormalizedValue - { - get => (float)currentValue / maxValue; - set => CurrentValue = Mathf.RoundToInt(value * maxValue); - } - - void Start() - { - CreateList(_bgList, background, bgTemplate); - CreateList(_fgList, foreground, fgTemplate); - OnValueChanged(); - } - - private void OnValueChanged() - { - if (currentValue < 0) - { - currentValue = 0; - } - - if (maxValue < 0) - { - maxValue = 10; - } - - if (currentValue > maxValue) - { - currentValue = maxValue; - } - - onValueChanged?.Invoke(currentValue); - UpdateGUI(); - } - - void CreateList(List list, Transform root, SpriteRenderer template) - { - template.gameObject.SetActive(false); - float angle = (startAngle - endAngle) / maxValue; - for (int i = 0; i < maxValue; i++) - { - Transform item = CreateItem(root, template, i); - list.Add(item); - item.RotateAround(root.position, Vector3.forward, startAngle - angle * i); - } - } - - Transform CreateItem(Transform root, SpriteRenderer template, int index) - { - var obj = Instantiate(template.gameObject, root); - obj.gameObject.SetActive(true); - obj.gameObject.name = "item" + (index + 1); - - return obj.transform; - } - - private void UpdateGUI() - { - UpdateForeground(); - UpdateText(); - } - - private void UpdateForeground() - { - for (int i = 0; i < _fgList.Count; i++) - { - Transform rectTrans = _fgList[i]; - SpriteRenderer image = rectTrans.GetComponent(); - - rectTrans.gameObject.SetActive(i < currentValue); - - image.color = i < maxValue / 2 - ? Color.Lerp(Color.green, Color.yellow, 2 * i / (float)maxValue) - : Color.Lerp(Color.yellow, Color.red, 2 * (i - (float)maxValue / 2) / maxValue); - } - } - - private void UpdateText() - { - if (tmpText == null) return; - - tmpText.text = LocalizationSettings.SelectedLocale.Identifier.Code == "en" - ? $"{NormalizedValue * 25000 :0} RPM" - : $"{NormalizedValue * 25000 :0} 转"; - - Debug.Log(tmpText.text); - } - - public void OnSpeedChanged(float originSpeed, float speedScale) - { - NormalizedValue = originSpeed; - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/UI/Components/CircularProgress.cs.meta b/Assets/Scripts/UI/Components/CircularProgress.cs.meta deleted file mode 100644 index de927cdc1..000000000 --- a/Assets/Scripts/UI/Components/CircularProgress.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 88e4949dd698411281b9597c2ace4213 -timeCreated: 1755257531 \ No newline at end of file diff --git a/Assets/Scripts/UI/DialogUI/LocalizedText.cs b/Assets/Scripts/UI/DialogUI/LocalizedText.cs deleted file mode 100644 index fa80bce29..000000000 --- a/Assets/Scripts/UI/DialogUI/LocalizedText.cs +++ /dev/null @@ -1,44 +0,0 @@ -using AibisDream.Utility; -using TMPro; -using UnityEngine; -using UnityEngine.Localization.Components; - -namespace AibisDream -{ - [RequireComponent(typeof(TMP_Text))] - [RequireComponent(typeof(LocalizeStringEvent))] - public class LocalizedText : MonoBehaviour - { - private TMP_Text _text; - private LocalizeStringEvent _localizeEvent; - - public bool isLineText = true; - public string template = "{0}"; - - private void OnUpdateString(string text) - { - if (isLineText) - { - text = CommonUtil.RemoveName(text); - } - - _text.text = string.Format(template, text); - } - - public void SetLocalizedText(string table, string entry) - { - _text = GetComponent(); - _localizeEvent = GetComponent(); - - _localizeEvent.OnUpdateString.AddListener(OnUpdateString); - - _localizeEvent.SetTable(table); - _localizeEvent.SetEntry(entry); - } - - public void SetVariables() - { - - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/UI/DialogUI/LocalizedText.cs.meta b/Assets/Scripts/UI/DialogUI/LocalizedText.cs.meta deleted file mode 100644 index 37499138a..000000000 --- a/Assets/Scripts/UI/DialogUI/LocalizedText.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4c9c71a7e9c9455d955ff20b5db823a1 -timeCreated: 1746702086 \ No newline at end of file