2025-01-02 12:15:45 +08:00
|
|
|
|
using CG.UTility;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
2025-01-02 19:36:17 +08:00
|
|
|
|
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
#endif
|
2025-01-02 12:15:45 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
|
|
*Create By CG
|
|
|
|
|
|
*Function <EFBFBD><EFBFBD>װ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
namespace ZXK.LouDiXvMuNiu
|
|
|
|
|
|
{
|
2025-01-02 19:36:17 +08:00
|
|
|
|
public class DataNiuHandler
|
2025-01-02 12:15:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
public BindablePropertyRef<NiuData> CurNiuHandler = new BindablePropertyRef<NiuData>()
|
|
|
|
|
|
{
|
|
|
|
|
|
Value = new NiuData()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private List<NiuData> _niuDataArray = new List<NiuData>();
|
|
|
|
|
|
public List<NiuData> NiuDataArray { get => _niuDataArray; }
|
|
|
|
|
|
|
|
|
|
|
|
private Dictionary<string, List<NiuData>> _niuStepTypeDic = new Dictionary<string, List<NiuData>>();
|
|
|
|
|
|
public Dictionary<string, List<NiuData>> NiuStepTypeDic { get => _niuStepTypeDic; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD>˷<EFBFBD><CBB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
/// [ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>[<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>÷<EFBFBD>]]
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private Dictionary<string, Dictionary<string, float>> _examScore = new Dictionary<string, Dictionary<string, float>>();
|
|
|
|
|
|
|
|
|
|
|
|
public DataNiuHandler()
|
|
|
|
|
|
{
|
|
|
|
|
|
InitAppData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void InitAppData()
|
|
|
|
|
|
{
|
2025-01-04 19:56:41 +08:00
|
|
|
|
//#if UNITY_EDITOR || UNITY_STANDALONE_WIN
|
|
|
|
|
|
// string[] excelList = Directory.GetFiles(Application.streamingAssetsPath + ConstCtrl.EXCEL_PATH, "*.xlsx");
|
|
|
|
|
|
// ExcelUtility excel = new ExcelUtility(excelList[0]);
|
|
|
|
|
|
// excel.ConvertToJson(Application.streamingAssetsPath + ConstCtrl.JSON_PATH + Path.GetFileNameWithoutExtension(excelList[0]) + ".txt", new UTF8Encoding(false));
|
|
|
|
|
|
//#endif
|
2025-01-02 19:36:17 +08:00
|
|
|
|
string Niupath = Application.streamingAssetsPath + ConstCtrl.JSON_PATH + "NiuData.txt";
|
2025-01-02 12:15:45 +08:00
|
|
|
|
TxtFileHandle.ReadAllTxt(Niupath, (string vul) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
_niuDataArray = JsonConvert.DeserializeObject<List<NiuData>>(vul);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < _niuDataArray.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(_niuDataArray[i].TaskName)) continue;
|
|
|
|
|
|
if (_niuStepTypeDic.ContainsKey(_niuDataArray[i].ModuleName))
|
|
|
|
|
|
{
|
|
|
|
|
|
_niuStepTypeDic[_niuDataArray[i].ModuleName].Add(_niuDataArray[i]);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
List<NiuData> temp = new List<NiuData>();
|
|
|
|
|
|
temp.Add(_niuDataArray[i]);
|
|
|
|
|
|
_niuStepTypeDic.Add(_niuDataArray[i].ModuleName, temp);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-03 12:00:33 +08:00
|
|
|
|
public NiuData GetNextStep(NiuData curStep=null)
|
2025-01-02 12:15:45 +08:00
|
|
|
|
{
|
2025-01-03 12:00:33 +08:00
|
|
|
|
if (curStep == null) curStep = CurNiuHandler.Value;
|
2025-01-02 12:15:45 +08:00
|
|
|
|
List<NiuData> tempData = GameManager.Instance._DataNiuHandler.NiuStepTypeDic[GameManager.Instance._CurModelType];
|
|
|
|
|
|
for (int i = 0; i < tempData.Count; i++)
|
|
|
|
|
|
{
|
2025-01-03 12:00:33 +08:00
|
|
|
|
if (tempData[i].id == curStep.id + 1)
|
2025-01-02 12:15:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
return tempData[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public NiuData GetNextStep(int nextID)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<NiuData> tempData = GameManager.Instance._DataNiuHandler.NiuStepTypeDic[GameManager.Instance._CurModelType];
|
|
|
|
|
|
for (int i = 0; i < tempData.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (tempData[i].id == nextID)
|
|
|
|
|
|
{
|
|
|
|
|
|
return tempData[i];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD>ݳɼ<DDB3><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7>سɼ<D8B3>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns>[ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD><C6A3>ܳɼ<DCB3><C9BC><EFBFBD>ʵ<EFBFBD>ʳɼ<CAB3>]</returns>
|
|
|
|
|
|
public Queue<string[]> GetExamScore()
|
|
|
|
|
|
{
|
|
|
|
|
|
Queue<string[]> scoreFinish = new Queue<string[]>();
|
|
|
|
|
|
|
|
|
|
|
|
NiuData curstep = null;
|
|
|
|
|
|
NiuData nextstep = null;
|
|
|
|
|
|
float curStepChildTotalScore = 0;
|
|
|
|
|
|
float realityScore = 0;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < _niuDataArray.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(_niuDataArray[i].TaskName)) continue;
|
|
|
|
|
|
curstep = _niuDataArray[i];
|
|
|
|
|
|
if (i == _niuDataArray.Count - 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
nextstep = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
nextstep = _niuDataArray[i + 1];
|
|
|
|
|
|
}
|
|
|
|
|
|
curStepChildTotalScore += curstep.Score;
|
|
|
|
|
|
if (nextstep == null || !nextstep.ThreeTaskName.Equals(curstep.ThreeTaskName))
|
|
|
|
|
|
{
|
|
|
|
|
|
realityScore = 0;
|
|
|
|
|
|
if (_examScore.ContainsKey(curstep.ModuleName) && _examScore[curstep.ModuleName].ContainsKey(curstep.ThreeTaskName))
|
|
|
|
|
|
{
|
|
|
|
|
|
realityScore = _examScore[curstep.ModuleName][curstep.ThreeTaskName];
|
|
|
|
|
|
}
|
|
|
|
|
|
scoreFinish.Enqueue(new string[] { curstep.ModuleName, curstep.ThreeTaskName, curStepChildTotalScore.ToString(), realityScore.ToString() });
|
|
|
|
|
|
curStepChildTotalScore = 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return scoreFinish;
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>÷<EFBFBD>
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="bigStepName">ģ<><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
|
/// <param name="smallStepName"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
|
/// <param name="score"><3E><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>ɵ÷<C9B5><C3B7><EFBFBD></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public float AddScore(string bigStepName, string smallStepName, float score)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!_examScore.ContainsKey(bigStepName))
|
|
|
|
|
|
{
|
|
|
|
|
|
_examScore.Add(bigStepName, new Dictionary<string, float>());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!_examScore[bigStepName].ContainsKey(smallStepName))
|
|
|
|
|
|
{
|
|
|
|
|
|
_examScore[bigStepName].Add(smallStepName, 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
_examScore[bigStepName][smallStepName] += score;
|
|
|
|
|
|
return _examScore[bigStepName][smallStepName];
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|