This commit is contained in:
parent
731a39f598
commit
ce4bd14983
|
|
@ -230,7 +230,32 @@ namespace MotionFramework.Scripts.Runtime.Engine.Engine.Network.WebRequest
|
||||||
return request.downloadHandler.text;
|
return request.downloadHandler.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Ìá½»JSONÊý¾Ý±íµ¥
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="url"></param>
|
||||||
|
/// <param name="jsonData"></param>
|
||||||
|
/// <param name="onProgress"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async UniTask<string> PostJsonAsync(string url, string jsonData, Action<float> onProgress = null, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
using (UnityWebRequest request = new UnityWebRequest(url, UnityWebRequest.kHttpVerbPOST))
|
||||||
|
{
|
||||||
|
byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonData);
|
||||||
|
request.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
||||||
|
request.downloadHandler = new DownloadHandlerBuffer();
|
||||||
|
request.SetRequestHeader("Content-Type", "application/json");
|
||||||
|
|
||||||
|
await SendRequestWithProgress(request, onProgress, cancellationToken);
|
||||||
|
if (request.result == UnityWebRequest.Result.ConnectionError || request.result == UnityWebRequest.Result.ProtocolError)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Òì³££º {request.error}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return request.downloadHandler.text;
|
||||||
|
}
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ½ø¶È
|
/// ½ø¶È
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -581,10 +581,30 @@ PrefabInstance:
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 1418789607}
|
addedObject: {fileID: 1418789607}
|
||||||
m_AddedComponents:
|
m_AddedComponents:
|
||||||
|
- targetCorrespondingSourceObject: {fileID: 6026879024415736155, guid: fa12b84946083d14cb4447029910be28, type: 3}
|
||||||
|
insertIndex: -1
|
||||||
|
addedObject: {fileID: 248632706}
|
||||||
- targetCorrespondingSourceObject: {fileID: 8362301506298638284, guid: fa12b84946083d14cb4447029910be28, type: 3}
|
- targetCorrespondingSourceObject: {fileID: 8362301506298638284, guid: fa12b84946083d14cb4447029910be28, type: 3}
|
||||||
insertIndex: -1
|
insertIndex: -1
|
||||||
addedObject: {fileID: 18767237}
|
addedObject: {fileID: 18767237}
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: fa12b84946083d14cb4447029910be28, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: fa12b84946083d14cb4447029910be28, type: 3}
|
||||||
|
--- !u!1 &248632703 stripped
|
||||||
|
GameObject:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 6026879024415736155, guid: fa12b84946083d14cb4447029910be28, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 191666367}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
--- !u!114 &248632706
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 248632703}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: d32e156afe2d4df78e71bd2fa58cce6b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &421131203
|
--- !u!1 &421131203
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5412a6a06cb4a22449ce9a97230cf70e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class APIs
|
||||||
|
{
|
||||||
|
private static string ip = "http://172.16.1.127:9206";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 虚拟仿真考试提交分数
|
||||||
|
/// </summary>
|
||||||
|
public static string SimulationScore = ip + "/pro/score/simulationScore";
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fc40ff633e445a44f847f7452e0e2ddc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace DefaultNamespace.Dto
|
||||||
|
{
|
||||||
|
public class SubmitScoreStep
|
||||||
|
{
|
||||||
|
public string stepName { get; set; }
|
||||||
|
public string testPoint { get; set; }
|
||||||
|
public int score { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SubmitScoreData
|
||||||
|
{
|
||||||
|
public string userName { get; set; }
|
||||||
|
public string userId { get; set; }
|
||||||
|
public int examId { get; set; }
|
||||||
|
public int classId { get; set; }
|
||||||
|
public string userTime { get; set; }
|
||||||
|
public List<SubmitScoreStep> stepList { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c2f1e6b74cdc4049852e8e52afa57e7d
|
||||||
|
timeCreated: 1719470950
|
||||||
|
|
@ -4,8 +4,28 @@ using DefaultNamespace;
|
||||||
using MotionFramework;
|
using MotionFramework;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
||||||
|
public class ParsedData
|
||||||
|
{
|
||||||
|
public string SceneName { get; set; }
|
||||||
|
public int SceneModel { get; set; }
|
||||||
|
public int ExamId { get; set; }
|
||||||
|
public string UserId { get; set; }
|
||||||
|
public string Username { get; set; }
|
||||||
|
public string Token { get; set; }
|
||||||
|
public int UserTime { get; set; }
|
||||||
|
public int ClassId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 0 场景名,1 练习或者考试,2 examId ,3 userId,4 userName,5 token,6 userTime,7 classId
|
||||||
|
/// 2024-06-14 15:04:12#'sxfz://;lyht,0,examId,userId,username,token,90,classId;/'|
|
||||||
|
/// </summary>
|
||||||
public class InfoDataManager : ModuleSingleton<InfoDataManager>, IModule
|
public class InfoDataManager : ModuleSingleton<InfoDataManager>, IModule
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private ParsedData _parsedData;
|
||||||
private void ParseFileContent(string content)
|
private void ParseFileContent(string content)
|
||||||
{
|
{
|
||||||
// 首先按照 # 进行分割,获取日期和数据部分
|
// 首先按照 # 进行分割,获取日期和数据部分
|
||||||
|
|
@ -45,31 +65,39 @@ public class InfoDataManager : ModuleSingleton<InfoDataManager>, IModule
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
string code = dataElements[0];
|
_parsedData.SceneName = dataElements[0];
|
||||||
string value1 = dataElements[1];
|
_parsedData.SceneModel = int.Parse(dataElements[1]);
|
||||||
string value2 = dataElements[2];
|
_parsedData.ExamId = int.Parse(dataElements[2]);
|
||||||
string userId = dataElements[3];
|
_parsedData.UserId = dataElements[2];
|
||||||
string username = dataElements[4];
|
_parsedData.Username = dataElements[4];
|
||||||
string token = dataElements[5];
|
_parsedData.Token = dataElements[5];
|
||||||
string value3 = dataElements[6];
|
_parsedData.UserTime = int.Parse(dataElements[6]);
|
||||||
|
_parsedData.ClassId = int.Parse(dataElements[7]);
|
||||||
|
|
||||||
Debug.Log("Code: " + code);
|
Debug.Log("场景名: " + _parsedData.SceneName);
|
||||||
Debug.Log("Value 1: " + value1);
|
Debug.Log("场景模式: " + _parsedData.SceneModel);
|
||||||
Debug.Log("Value 2: " + value2);
|
Debug.Log("考试ID: " + _parsedData.ExamId);
|
||||||
Debug.Log("User ID: " + userId);
|
Debug.Log("User ID: " + _parsedData.UserId);
|
||||||
Debug.Log("Username: " + username);
|
Debug.Log("Username: " + _parsedData.Username);
|
||||||
Debug.Log("Token: " + token);
|
Debug.Log("Token: " + _parsedData.Token);
|
||||||
Debug.Log("Value 3: " + value3);
|
Debug.Log("时间: " + _parsedData.UserTime);
|
||||||
|
Debug.Log("班级ID: " + _parsedData.ClassId);
|
||||||
|
|
||||||
|
|
||||||
|
MotionEngine.GetModule<DataConfigManager>().SetProcessMode(_parsedData.SceneModel);
|
||||||
MotionEngine.GetModule<DataConfigManager>().SetProcessMode(int.Parse(value1));
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ParsedData GetParsedData()
|
||||||
|
{
|
||||||
|
return _parsedData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnCreate(object createParam)
|
public void OnCreate(object createParam)
|
||||||
{
|
{
|
||||||
|
_parsedData = new ParsedData();
|
||||||
|
|
||||||
|
|
||||||
string content = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/info.ini");
|
string content = System.IO.File.ReadAllText(Application.streamingAssetsPath + "/info.ini");
|
||||||
ParseFileContent(content);
|
ParseFileContent(content);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ namespace DefaultNamespace.ProcessMode
|
||||||
private int _currentActionGameIndex; // 当前动作索引,确保动作顺序
|
private int _currentActionGameIndex; // 当前动作索引,确保动作顺序
|
||||||
private Dictionary<int, List<string>> _incorrectClicksPerStep; // 每个步骤的错误点击记录
|
private Dictionary<int, List<string>> _incorrectClicksPerStep; // 每个步骤的错误点击记录
|
||||||
private SceneStepData _sceneStepData;
|
private SceneStepData _sceneStepData;
|
||||||
|
private List<SubmitScoreStep> _submitScoreSteps = new List<SubmitScoreStep>();
|
||||||
|
|
||||||
public AnimationProcess CurrentProcess => _processes[_currentMode.ToString()];
|
public AnimationProcess CurrentProcess => _processes[_currentMode.ToString()];
|
||||||
|
|
||||||
|
|
@ -200,6 +201,7 @@ namespace DefaultNamespace.ProcessMode
|
||||||
|
|
||||||
if (_currentStepIndex == _processes[_currentMode.ToString()].Steps.Count)
|
if (_currentStepIndex == _processes[_currentMode.ToString()].Steps.Count)
|
||||||
{
|
{
|
||||||
|
Debug.Log(CalculateTotalScore());
|
||||||
OnCompleteEvent?.Invoke(CalculateTotalScore());
|
OnCompleteEvent?.Invoke(CalculateTotalScore());
|
||||||
Debug.Log("全部完成了!!!!");
|
Debug.Log("全部完成了!!!!");
|
||||||
}
|
}
|
||||||
|
|
@ -400,6 +402,7 @@ namespace DefaultNamespace.ProcessMode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 计算总分
|
/// 计算总分
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -408,15 +411,31 @@ namespace DefaultNamespace.ProcessMode
|
||||||
float totalScore = 0;
|
float totalScore = 0;
|
||||||
foreach (var step in _processes[_currentMode.ToString()].Steps)
|
foreach (var step in _processes[_currentMode.ToString()].Steps)
|
||||||
{
|
{
|
||||||
|
SubmitScoreStep sub = new SubmitScoreStep();
|
||||||
|
|
||||||
int stepIndex = _processes[_currentMode.ToString()].Steps.IndexOf(step);
|
int stepIndex = _processes[_currentMode.ToString()].Steps.IndexOf(step);
|
||||||
if (_incorrectClicksPerStep.TryGetValue(stepIndex, out var value))
|
if (_incorrectClicksPerStep.TryGetValue(stepIndex, out var value))
|
||||||
{
|
{
|
||||||
|
float sco = step.Score / step.Actions[0].TargetObjects.Count;
|
||||||
|
Debug.Log("每个物体的分数--->" + sco);
|
||||||
|
float zong = step.Score - sco * value.Count;
|
||||||
|
totalScore += zong;
|
||||||
|
Debug.Log("扣的分数--->" + (step.Score - sco * value.Count));
|
||||||
Debug.Log($"步骤 {stepIndex + 1} 错误点击的物体: {string.Join(", ", value)}");
|
Debug.Log($"步骤 {stepIndex + 1} 错误点击的物体: {string.Join(", ", value)}");
|
||||||
|
sub.score = (int)zong;
|
||||||
|
sub.stepName = step.StepDescription;
|
||||||
|
sub.testPoint = step.Actions[0].Description;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
totalScore += step.Score; // 每个步骤满分为10
|
totalScore += step.Score; // 每个步骤满分为10
|
||||||
|
sub.score = (int)step.Score;
|
||||||
|
sub.stepName = step.StepDescription;
|
||||||
|
sub.testPoint = step.Actions[0].Description;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
_submitScoreSteps.Add(sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"总分: {totalScore}");
|
Debug.Log($"总分: {totalScore}");
|
||||||
|
|
@ -584,5 +603,10 @@ namespace DefaultNamespace.ProcessMode
|
||||||
{
|
{
|
||||||
return _currentMode;
|
return _currentMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<SubmitScoreStep> GetSubmitScoreStepList()
|
||||||
|
{
|
||||||
|
return _submitScoreSteps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,53 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DefaultNamespace.Dto;
|
||||||
|
using DefaultNamespace.ProcessMode;
|
||||||
|
using MotionFramework;
|
||||||
|
using MotionFramework.Scripts.Runtime.Engine.Engine.Network.WebRequest;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace DefaultNamespace
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 提交分数
|
||||||
|
/// </summary>
|
||||||
|
public class SubmitScoreComponent : MonoBehaviour
|
||||||
|
{
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
// Submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Submit()
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||||
|
|
||||||
|
ParsedData parsedData = MotionEngine.GetModule<InfoDataManager>().GetParsedData();
|
||||||
|
|
||||||
|
|
||||||
|
SubmitScoreData sub = new SubmitScoreData();
|
||||||
|
sub.userName = parsedData.SceneName;
|
||||||
|
sub.userId = parsedData.UserId;
|
||||||
|
sub.examId = parsedData.ExamId;
|
||||||
|
sub.classId = parsedData.ClassId;
|
||||||
|
sub.userTime = "111";
|
||||||
|
sub.stepList = MotionEngine.GetModule<AnimationProcessManager>().GetSubmitScoreStepList();
|
||||||
|
|
||||||
|
string js = JsonConvert.SerializeObject(sub);
|
||||||
|
|
||||||
|
Debug.Log(js);
|
||||||
|
string json = await MotionEngine.GetModule<WebRequestManager>().PostJsonAsync(APIs.SimulationScore, js, (ste) => { });
|
||||||
|
Debug.Log(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnGUI()
|
||||||
|
{
|
||||||
|
if (GUI.Button(new Rect(100, 100, 100, 100), ""))
|
||||||
|
{
|
||||||
|
Submit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d32e156afe2d4df78e71bd2fa58cce6b
|
||||||
|
timeCreated: 1719470113
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"description": "领取工器具及仪器设备",
|
"description": "领取工器具及仪器设备",
|
||||||
"score": 0,
|
"score": 30,
|
||||||
"isSequential": false,
|
"isSequential": false,
|
||||||
"targetObjects": [
|
"targetObjects": [
|
||||||
"螺丝刀",
|
"螺丝刀",
|
||||||
|
|
@ -145,7 +145,7 @@
|
||||||
"score": 3.11,
|
"score": 3.11,
|
||||||
"actions": [
|
"actions": [
|
||||||
{
|
{
|
||||||
"description": ",更换集中器",
|
"description": "更换集中器",
|
||||||
"score": 0,
|
"score": 0,
|
||||||
"isSequential": false,
|
"isSequential": false,
|
||||||
"targetObjects": [
|
"targetObjects": [
|
||||||
|
|
@ -192,7 +192,7 @@
|
||||||
"JZQ_螺丝004",
|
"JZQ_螺丝004",
|
||||||
"JZQ_螺丝0044",
|
"JZQ_螺丝0044",
|
||||||
"JZQ_螺丝006",
|
"JZQ_螺丝006",
|
||||||
"JZQ_螺丝007"
|
"JZQ_螺丝005"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -250,14 +250,10 @@
|
||||||
"isSequential": false,
|
"isSequential": false,
|
||||||
"targetObjects": [
|
"targetObjects": [
|
||||||
"JZQ_螺丝001",
|
"JZQ_螺丝001",
|
||||||
"JZQ_螺丝0011",
|
|
||||||
"JZQ_螺丝002",
|
"JZQ_螺丝002",
|
||||||
"JZQ_螺丝0022",
|
|
||||||
"JZQ_螺丝003",
|
"JZQ_螺丝003",
|
||||||
"JZQ_螺丝0033",
|
|
||||||
"JZQ_螺丝004",
|
"JZQ_螺丝004",
|
||||||
"JZQ_螺丝0044",
|
"JZQ_螺丝007",
|
||||||
"JZQ_螺丝005",
|
|
||||||
"JZQ_螺丝006"
|
"JZQ_螺丝006"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -346,19 +342,6 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},{
|
|
||||||
"stepDescription": "加装封印",
|
|
||||||
"score": 1.4,
|
|
||||||
"actions": [
|
|
||||||
{
|
|
||||||
"description": "加装封印",
|
|
||||||
"score": 0,
|
|
||||||
"isSequential": false,
|
|
||||||
"targetObjects": [
|
|
||||||
"电柜门封印box碰撞"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
2024-06-14 15:04:12#'sxfz://;lyht,0,18,userId,username,token,90;/'|
|
2024-06-14 15:04:12#'sxfz://;lyht,0,333,444,555,666,777,888;/'|
|
||||||
|
|
@ -780,4 +780,4 @@ PlayerSettings:
|
||||||
hmiLoadingImage: {fileID: 0}
|
hmiLoadingImage: {fileID: 0}
|
||||||
platformRequiresReadableAssets: 0
|
platformRequiresReadableAssets: 0
|
||||||
virtualTexturingSupportEnabled: 0
|
virtualTexturingSupportEnabled: 0
|
||||||
insecureHttpOption: 0
|
insecureHttpOption: 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue