_TheStrongestSnail/TheStrongestSnail/Assets/common/base/base.cs

73 lines
2.5 KiB
C#
Raw Normal View History

2024-11-25 23:31:50 +08:00
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
2024-11-26 02:09:38 +08:00
using System.Text.RegularExpressions;
2024-11-25 23:31:50 +08:00
using System.Threading.Tasks;
using UnityEngine;
2024-11-26 02:09:38 +08:00
using UnityEngine.SceneManagement;
2024-11-25 23:31:50 +08:00
using UnityEngine.UI;
public class Base : MonoBehaviour
{
2024-11-26 15:50:49 +08:00
public Button retbutton;
public async Task ButtonClickAnimationAsync(GameObject button,float max=1.25f)//<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD>
2024-11-25 23:31:50 +08:00
{
TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
Sequence mySequence = DOTween.Sequence();
2024-11-26 15:50:49 +08:00
mySequence.Append(button.transform.DOScale(max, 0.1f)) // <20><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-11-25 23:31:50 +08:00
.Append(button.transform.DOScale(1f, 0.2f)).OnComplete(() => {
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɺ<EFBFBD>ִ<EFBFBD>еĴ<D0B5><C4B4><EFBFBD>
tcs.SetResult(true);
}); // <20>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
await tcs.Task;
}
2024-11-26 02:09:38 +08:00
public void addEventPopUp(string Details)//<2F><><EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>
2024-11-25 23:31:50 +08:00
{
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
Canvas canvas = GetComponentInParent<Canvas>();
prefab.GetComponent<EventPopUp>().text = Details;
Instantiate(prefab, canvas.transform);
}
2024-11-26 02:09:38 +08:00
logoPanel.ServerResponse TestserverResponse;
protected Dictionary<string, string> testhead;
2024-11-26 15:50:49 +08:00
public async void testLogo()//<2F><><EFBFBD>Ե<EFBFBD>¼
2024-11-26 02:09:38 +08:00
{
LoginAndGetToken.loginbody body = new LoginAndGetToken.loginbody
{
userName = "15151658596",
password = "123456",
verifyCode = 111111
};
string loginResponse = await web.SendRequest(web.URL + "/snail/user/login", "POST", JsonUtility.ToJson(body));
logoPanel.ServerResponse response = JsonUtility.FromJson<logoPanel.ServerResponse>(loginResponse);
if (response != null && response.code == 200 && response.data != null)
{
TestserverResponse = response;
addEventPopUp("<22><><EFBFBD>Ե<EFBFBD>¼<EFBFBD>ɹ<EFBFBD>");
2024-11-26 15:50:49 +08:00
testhead = new Dictionary<string, string>
2024-11-26 02:09:38 +08:00
{
{ "Authorization", TestserverResponse.data.token }
};
}
addEventPopUp("<22><><EFBFBD>Ե<EFBFBD>¼ʧ<C2BC><CAA7>");
2024-11-26 15:50:49 +08:00
testhead = new Dictionary<string, string>();
2024-11-26 02:09:38 +08:00
}
2024-11-25 23:31:50 +08:00
2024-11-26 02:09:38 +08:00
public bool IsGreaterThanZeroDecimal(string text)//<2F>жϱ<D0B6><CFB1><EFBFBD>ΪС<CEAA><D0A1><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD><D2B4><EFBFBD>0
{
// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽƥ<CABD><C6A5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30>С<EFBFBD><D0A1>
string pattern = @"^(?!0(\.0+)?$)(\d+(\.\d+)?|\.\d+)$";
Regex regex = new Regex(pattern);
return regex.IsMatch(text);
}
2024-11-26 15:50:49 +08:00
public async void CancelOnClick(Button button)//ȡ<><C8A1><EFBFBD><EFBFBD>ť
{
await ButtonClickAnimationAsync(button.gameObject);
Destroy(gameObject);
}
2024-11-25 23:31:50 +08:00
}