Compare commits
No commits in common. "0c4f2b20fdd439ae539a7b50a15dd3639542572c" and "e13aef6ad4d947f9a2b6bd0c523d96a2b824e689" have entirely different histories.
0c4f2b20fd
...
e13aef6ad4
@ -1,9 +1,12 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using QFramework;
|
using QFramework;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.SocialPlatforms.Impl;
|
||||||
using XMLTool;
|
using XMLTool;
|
||||||
|
|
||||||
public class ScoreController : MonoSingleton<ScoreController>
|
public class ScoreController : MonoSingleton<ScoreController>
|
||||||
|
|||||||
@ -1,10 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Events;
|
using UnityEngine.Events;
|
||||||
using UnityEngine.Networking;
|
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class DateManager : MonoBehaviour
|
public class DateManager : MonoBehaviour
|
||||||
@ -21,14 +19,10 @@ public class DateManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Application.Quit();
|
Application.Quit();
|
||||||
});
|
});
|
||||||
#if UNITY_WEBGL
|
UpdateTime(ShowTip, ShowTip, () =>
|
||||||
StartCoroutine(WebUpdateTime());
|
|
||||||
#else
|
|
||||||
UpdateTime(DecryptFileReader.ReadAndDecryptData("Timer.txt"), ShowTip, ShowTip, () =>
|
|
||||||
{
|
{
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
});
|
});
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowTip(string str)
|
public void ShowTip(string str)
|
||||||
@ -38,35 +32,14 @@ public class DateManager : MonoBehaviour
|
|||||||
text.text = str;
|
text.text = str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerator WebUpdateTime()
|
|
||||||
{
|
|
||||||
string path = Path.Combine(Application.streamingAssetsPath, "Timer.txt");
|
|
||||||
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);
|
|
||||||
UpdateTime(datas, ShowTip, ShowTip, () =>
|
|
||||||
{
|
|
||||||
gameObject.SetActive(false);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError(request.error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新系统时间
|
/// 更新系统时间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateTime(string datas, UnityAction<string> error = null, UnityAction<string> timeOut = null, UnityAction updateTimer = null)
|
public void UpdateTime(UnityAction<string> error = null, UnityAction<string> timeOut = null, UnityAction updateTimer = null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
string datas = DecryptFileReader.ReadAndDecryptData("Timer.txt");
|
||||||
EndTimer = datas.Split('|')[0];
|
EndTimer = datas.Split('|')[0];
|
||||||
RecordData = datas.Split('|')[1];
|
RecordData = datas.Split('|')[1];
|
||||||
//第一次获取获取系统时间
|
//第一次获取获取系统时间
|
||||||
@ -81,13 +54,11 @@ public class DateManager : MonoBehaviour
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if !UNITY_WEBGL
|
|
||||||
//把上一次存储得系统时间更新到最新
|
//把上一次存储得系统时间更新到最新
|
||||||
string timer = "Timer.txt";
|
string timer = "Timer.txt";
|
||||||
RecordData = Data;
|
RecordData = Data;
|
||||||
string strMerge = EndTimer + "|" + RecordData;
|
string strMerge = EndTimer + "|" + RecordData;
|
||||||
EncryptFileCreator.EncryptAndSaveData(strMerge, timer);
|
EncryptFileCreator.EncryptAndSaveData(strMerge, timer);
|
||||||
#endif
|
|
||||||
updateTimer?.Invoke();
|
updateTimer?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,12 +14,6 @@ public class DecryptFileReader
|
|||||||
if (File.Exists(filePath)) return "";
|
if (File.Exists(filePath)) return "";
|
||||||
// 读取加密文件
|
// 读取加密文件
|
||||||
byte[] encryptedData = File.ReadAllBytes(fullPath);
|
byte[] encryptedData = File.ReadAllBytes(fullPath);
|
||||||
return ReadAndDecryptData(encryptedData);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static string ReadAndDecryptData(byte[] encryptedData)
|
|
||||||
{
|
|
||||||
|
|
||||||
// 创建AES解密器
|
// 创建AES解密器
|
||||||
using (Aes aesAlg = Aes.Create())
|
using (Aes aesAlg = Aes.Create())
|
||||||
|
|||||||
@ -1,9 +1,7 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using static LYTWebGLHelper;
|
|
||||||
|
|
||||||
namespace QFramework.Example
|
namespace QFramework.Example
|
||||||
{
|
{
|
||||||
@ -86,9 +84,9 @@ namespace QFramework.Example
|
|||||||
onlyCur = mData.onlyCurModule;
|
onlyCur = mData.onlyCurModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<string> stepNames = new List<string>();
|
||||||
List<Expstepvtwolist> datas = new List<Expstepvtwolist>();
|
List<int> maxScore = new List<int>();
|
||||||
int seq = 0;
|
List<int> scores = new List<int>();
|
||||||
if (onlyCur)
|
if (onlyCur)
|
||||||
{
|
{
|
||||||
foreach (var item in ScoreController.Instance.GetCurScoreData())
|
foreach (var item in ScoreController.Instance.GetCurScoreData())
|
||||||
@ -100,16 +98,9 @@ namespace QFramework.Example
|
|||||||
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
||||||
sum += float.Parse(item.Value.sum);
|
sum += float.Parse(item.Value.sum);
|
||||||
score += item.Value.value;
|
score += item.Value.value;
|
||||||
datas.Add(new Expstepvtwolist()
|
stepNames.Add(item.Value.step + item.Value.name);
|
||||||
{
|
maxScore.Add(int.Parse(item.Value.sum));
|
||||||
ExpStepName = item.Value.step + item.Value.name,
|
scores.Add((int)item.Value.value);
|
||||||
maxScore = int.Parse(item.Value.sum),
|
|
||||||
score = (int)item.Value.value,
|
|
||||||
startTime = item.Value.time,
|
|
||||||
endTime = item.Value.time,
|
|
||||||
seq = seq,
|
|
||||||
});
|
|
||||||
seq++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -125,16 +116,9 @@ namespace QFramework.Example
|
|||||||
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
obj.transform.Find("Score").GetComponent<TextMeshProUGUI>().text = item.Value.value.ToString();
|
||||||
sum += float.Parse(item.Value.sum);
|
sum += float.Parse(item.Value.sum);
|
||||||
score += item.Value.value;
|
score += item.Value.value;
|
||||||
datas.Add(new Expstepvtwolist()
|
stepNames.Add(item.Value.step + item.Value.name);
|
||||||
{
|
maxScore.Add((int)float.Parse(item.Value.sum));
|
||||||
ExpStepName = item.Value.step + item.Value.name,
|
scores.Add((int)item.Value.value);
|
||||||
maxScore = int.Parse(item.Value.sum),
|
|
||||||
score = (int)item.Value.value,
|
|
||||||
startTime = item.Value.time,
|
|
||||||
endTime = item.Value.time,
|
|
||||||
seq = seq
|
|
||||||
});
|
|
||||||
seq++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,10 +127,9 @@ namespace QFramework.Example
|
|||||||
this.Score.text = score.ToString();
|
this.Score.text = score.ToString();
|
||||||
this.Sum.text = sum.ToString();
|
this.Sum.text = sum.ToString();
|
||||||
|
|
||||||
#if UNITY_WEBGL
|
//#if UNITY_WEBGL
|
||||||
|
// LYTWebGLHelper.Instance.UpLoadData((int)score, stepNames, maxScore, scores);
|
||||||
LYTWebGLHelper.Instance.UpLoadData((int)score, datas.ToArray());
|
//#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnShow()
|
protected override void OnShow()
|
||||||
|
|||||||
@ -1 +0,0 @@
|
|||||||
ILBJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>05<EFBFBD>
<0A><>l<EFBFBD><6C>F<03>)<29>#<1E><>BȲ<42><17>Uv<55>}]<5D>u.<2E><>\G<>
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 9b4029b9b6235264f8d2594721eb300a
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -69,7 +69,7 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
labData.PARA = datas[4];
|
labData.PARA = datas[4];
|
||||||
labData.PARA2 = datas[5];
|
labData.PARA2 = datas[5];
|
||||||
}
|
}
|
||||||
uploadUrl = Path.Combine(labData.HOST, "public/Exp/AddScore/");
|
uploadUrl = Path.Combine(labData.HOST, "host/public/Exp/AddScore/");
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Decrypts encrypted text given a RSA private key file path.给定路径的 RSA 私钥文件解
|
/// Decrypts encrypted text given a RSA private key file path.给定路径的 RSA 私钥文件解
|
||||||
@ -104,12 +104,8 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void UpLoadData(int totalScore, Expstepvtwolist[] datas)
|
public void UpLoadData(int totalScore, List<string> stepNames, List<int> maxScore, List<int> score)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(labData.GUID))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var data = new UploadData();
|
var data = new UploadData();
|
||||||
data.GUID = labData.GUID;
|
data.GUID = labData.GUID;
|
||||||
int expId = 0;
|
int expId = 0;
|
||||||
@ -117,17 +113,17 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
data.ExpID = expId;
|
data.ExpID = expId;
|
||||||
data.score = totalScore;
|
data.score = totalScore;
|
||||||
data.flag = true;
|
data.flag = true;
|
||||||
//var list = new List<Expstepvtwolist>();
|
|
||||||
//for (int i = 0; i < stepNames.Count; i++)
|
var list = new List<Expstepvtwolist>();
|
||||||
//{
|
for (int i = 0; i < stepNames.Count; i++)
|
||||||
// var step = new Expstepvtwolist();
|
{
|
||||||
// step.ExpStepName = stepNames[i];
|
var step = new Expstepvtwolist();
|
||||||
// step.maxScore = maxScore[i];
|
step.ExpStepName = stepNames[i];
|
||||||
// step.score = score[i];
|
step.maxScore = maxScore[i];
|
||||||
// step.seq = i + 1;
|
step.score = score[i];
|
||||||
// list.Add(step);
|
list.Add(step);
|
||||||
//}
|
}
|
||||||
data.ExpStepVTwoList = datas;
|
data.ExpStepVTwoList = list.ToArray();
|
||||||
|
|
||||||
StartCoroutine(SendScore(JsonConvert.SerializeObject(data)));
|
StartCoroutine(SendScore(JsonConvert.SerializeObject(data)));
|
||||||
}
|
}
|
||||||
@ -189,9 +185,9 @@ public class LYTWebGLHelper : MonoSingleton<LYTWebGLHelper>
|
|||||||
// 实验步骤状态
|
// 实验步骤状态
|
||||||
public string StepState = "";
|
public string StepState = "";
|
||||||
// 实验步骤开始时间
|
// 实验步骤开始时间
|
||||||
public string startTime;
|
public DateTime startTime = default;
|
||||||
// 实验步骤结束时间
|
// 实验步骤结束时间
|
||||||
public string endTime;
|
public DateTime endTime = default;
|
||||||
// 实验步骤合理用时:单位秒
|
// 实验步骤合理用时:单位秒
|
||||||
public int expectTime = 0;
|
public int expectTime = 0;
|
||||||
// 实验步骤满分:0 ~100,百分制
|
// 实验步骤满分:0 ~100,百分制
|
||||||
|
|||||||
23
Assets/WebPlatform/WebTest.cs
Normal file
23
Assets/WebPlatform/WebTest.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class WebTest : MonoBehaviour
|
||||||
|
{
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
List<string> stepNames = new List<string>() { "µÚÒ»²½", "µÚ¶þ²½", "µÚÈý²½" };
|
||||||
|
List<int> maxScore = new List<int>() { 10, 20, 30 };
|
||||||
|
List<int> score = new List<int>() { 5, 10, 15 };
|
||||||
|
LYTWebGLHelper.Instance.UpLoadData(60, stepNames, maxScore, score);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/WebPlatform/WebTest.cs.meta
Normal file
11
Assets/WebPlatform/WebTest.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 08f51ad357b70604492d4c3e95ce1e27
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
x
Reference in New Issue
Block a user