CutePet/Assets/Scripts/CreateLev/TipPanel.cs

91 lines
2.3 KiB
C#
Raw Normal View History

2024-10-25 11:10:04 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TipPanel : MonoBehaviour
{
public Button btnClose;
public Button btnContine;
public Text txtUpload;
public Text txtInfo;
// Start is called before the first frame update
void Start()
{
btnClose.onClick.AddListener(() =>
{
this.gameObject.SetActive(false);
});
btnContine.onClick.AddListener(() =>
{
this.gameObject.SetActive(false);
});
}
// Update is called once per frame
void Update()
{
}
public void UpdatePanel(IsSuccessMsg msg)
{
if (msg.success)
{
txtUpload.text = "<22>ϴ<EFBFBD><CFB4>ɹ<EFBFBD>";
txtInfo.text = msg.msg;
}
else
{
txtUpload.text = "<22>ϴ<EFBFBD>ʧ<EFBFBD><CAA7>";
Debug.Log(msg.msg);
int j = msg.msg.IndexOf("<22><>");
int i = int.Parse(msg.msg.Substring(1, j-1));
string str = ConvertToChineseNumber(i);
txtInfo.text = "<22><>" + str + "<22>ػ<EFBFBD>û<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD>" + str + "<22>عؿ<D8B9><D8BF><EFBFBD>";
}
}
string ConvertToChineseNumber(int number)
{
string[] chineseDigits = { "<22><>", "һ", "<22><>", "<22><>", "<22><>", "<22><>", "<22><>", "<22><>", "<22><>", "<22><>" };
string[] chineseUnits = { "", "ʮ", "<22><>", "ǧ", "<22><>" };
string result = "";
int unitIndex = 0;
if (number == 0) return chineseDigits[0]; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>ֱ<EFBFBD>ӷ<EFBFBD><D3B7>ء<EFBFBD><D8A1>
while (number > 0)
{
int digit = number % 10; // ȡ<><C8A1><EFBFBD><EFBFBD>һλ<D2BB><CEBB><EFBFBD><EFBFBD>
if (digit > 0 || unitIndex == 0) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD>д<EFBFBD>еġ<D0B5><C4A1><EFBFBD><EFBFBD>١<EFBFBD><D9A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʮ<EFBFBD><CAAE>
{
result = chineseDigits[digit] + chineseUnits[unitIndex] + result;
}
else if (digit == 0 && result.Length > 0 && result[0] != '<EFBFBD><EFBFBD>') // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
result = "<22><>" + result;
}
number /= 10; // ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һλ<D2BB><CEBB><EFBFBD><EFBFBD>
unitIndex++;
}
// <20><><EFBFBD><EFBFBD><E2B4A6>ʮ<EFBFBD><CAAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><CAAE>"<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"һʮ<D2BB><CAAE>"
if (result.StartsWith("һʮ"))
{
result = result.Substring(1);
}
// <20>Ƴ<EFBFBD><C6B3><EFBFBD><EFBFBD><EFBFBD>ĩβ<C4A9>Ķ<EFBFBD><C4B6><EFBFBD>
if (result.EndsWith("<22><>"))
{
result = result.TrimEnd('<EFBFBD><EFBFBD>');
}
return result;
}
}