修复bug
This commit is contained in:
parent
32cba06cf0
commit
899b00d3c7
@ -1,7 +1,10 @@
|
||||
using CG.Framework;
|
||||
using CG.UTility;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
/********************************************************************************
|
||||
*Create By CG
|
||||
*Function Ö÷ҳ״̬
|
||||
@ -17,10 +20,40 @@ namespace ZXK.LouDiXvMuNiu
|
||||
public override void EnterState()
|
||||
{
|
||||
UI_Manage.Instance.ShowPanel("HomePanel", Type.GetType("ZXK.LouDiXvMuNiu.HomePanel"), UIGroup.Main);
|
||||
|
||||
#if UNITY_WEBGL
|
||||
GameManager.Instance.StartCoroutine(LoadTimer());
|
||||
#else
|
||||
DateManager.UpdateTime(Tip, Tip, success: () =>
|
||||
{
|
||||
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
IEnumerator LoadTimer()
|
||||
{
|
||||
string path = Path.Combine(Application.streamingAssetsPath, "Timer.txt");
|
||||
Debug.LogError(path);
|
||||
using (UnityWebRequest request = new UnityWebRequest(path))
|
||||
{
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
yield return request.SendWebRequest();
|
||||
if (string.IsNullOrEmpty(request.error))
|
||||
{
|
||||
string datas = DecryptFileReader.ReadAndDecryptData(request.downloadHandler.data);
|
||||
DateManager.UpdateTime(datas,Tip, Tip, success: () =>
|
||||
{
|
||||
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError(request.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Tip(string str)
|
||||
{
|
||||
PopUpMng.PopAlert("", str, "È·¶¨", () =>
|
||||
|
||||
@ -8,10 +8,9 @@ public class DateManager
|
||||
|
||||
public static string EndTimer = "2025-07-06 00:00:00";//结束时间
|
||||
private static string RecordData;
|
||||
private void Start()
|
||||
{
|
||||
// CreatTimer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新系统时间
|
||||
@ -58,6 +57,50 @@ public class DateManager
|
||||
}
|
||||
success?.Invoke();
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新系统时间
|
||||
/// </summary>
|
||||
public static void UpdateTime(string datas, UnityAction<string> error = null, UnityAction<string> timeOut = null, UnityAction update = null, UnityAction success = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
EndTimer = datas.Split('|')[0];
|
||||
RecordData = datas.Split('|')[1];
|
||||
//第一次获取获取系统时间
|
||||
DateTime currentDateTime = DateTime.Now;
|
||||
string Data = currentDateTime.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
if (DateTime.TryParse(RecordData, out DateTime recordDateTime) && DateTime.TryParse(Data, out DateTime nowDateTime))
|
||||
{
|
||||
if (recordDateTime > nowDateTime)
|
||||
{
|
||||
Debug.Log("仿真文件被损坏,请联系管理员进行修复");
|
||||
error?.Invoke("仿真文件被损坏,请联系管理员进行修复");
|
||||
}
|
||||
else
|
||||
{
|
||||
//把上一次存储得系统时间更新到最新
|
||||
//string timer = "Timer.txt";
|
||||
//RecordData = Data;
|
||||
//string strMerge = EndTimer + "|" + RecordData;
|
||||
//EncryptFileCreator.EncryptAndSaveData(strMerge, timer);
|
||||
update?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError($"数据出错: {e.Message}");
|
||||
error?.Invoke($"数据出错: {e.Message}");
|
||||
}
|
||||
|
||||
if (JudgeExpire())
|
||||
{
|
||||
Debug.Log("请联系管理员进行升级");
|
||||
timeOut?.Invoke("请联系管理员进行升级");
|
||||
return;
|
||||
}
|
||||
success?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否到期
|
||||
|
||||
@ -14,7 +14,12 @@ public class DecryptFileReader
|
||||
if (File.Exists(filePath)) return "";
|
||||
// 读取加密文件
|
||||
byte[] encryptedData = File.ReadAllBytes(fullPath);
|
||||
return ReadAndDecryptData(encryptedData);
|
||||
}
|
||||
|
||||
|
||||
public static string ReadAndDecryptData(byte[] encryptedData)
|
||||
{
|
||||
// 创建AES解密器
|
||||
using (Aes aesAlg = Aes.Create())
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user