131 lines
5.0 KiB
C#
131 lines
5.0 KiB
C#
using CG.UTility;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
/*******************************************************************************
|
|
*Create By CG
|
|
*Function 安装部署
|
|
*******************************************************************************/
|
|
namespace ZXK.GYJQR
|
|
{
|
|
public class DataAZBSHandler
|
|
{
|
|
public static float TotalAZBSScore = 0;
|
|
public BindablePropertyRef<AZBS> CurAZBShandler = new BindablePropertyRef<AZBS>()
|
|
{
|
|
Value = new AZBS()
|
|
};
|
|
|
|
private List<AZBS> _AZBSDataArray = new List<AZBS>();
|
|
|
|
public List<AZBS> AZBSDataArray { get =>_AZBSDataArray; set => _AZBSDataArray = value; }
|
|
#region 安装部署分数管理
|
|
public Dictionary<string, Dictionary<string, float>> _examAZBSScore = new Dictionary<string, Dictionary<string, float>>();//保存分数和当前步骤的字典
|
|
#endregion
|
|
|
|
public DataAZBSHandler()
|
|
{
|
|
InitAppData();
|
|
}
|
|
|
|
|
|
public void InitAppData()
|
|
{
|
|
string AZBSpath = Application.streamingAssetsPath+ ConstCtrl.JSON_PATH + EnumCtrl.SystemType.AZBS + ".txt";
|
|
//string AZBSdetail = TxtFileHandle.ReadAllTxt(AZBSpath);
|
|
//_AZBSDataArray = JsonConvert.DeserializeObject<List<AZBS>>(AZBSdetail);
|
|
TxtFileHandle.ReadAllTxt(AZBSpath, (string vul) =>
|
|
{
|
|
_AZBSDataArray = JsonConvert.DeserializeObject<List<AZBS>>(vul);
|
|
});
|
|
}
|
|
#region 安装部署成绩布局
|
|
/// <summary>
|
|
/// 根据成绩单布局返回成绩
|
|
/// </summary>
|
|
/// <returns>[步骤名,子步骤名,总成绩,实际成绩]</returns>
|
|
public Queue<string[]> GetExamScore()
|
|
{
|
|
Queue<string[]> scoreFinish = new Queue<string[]>();
|
|
AZBS curstep = null;
|
|
AZBS nextstep = null;
|
|
float curStepChildTotalScore = 0;
|
|
float realityScore = 0;
|
|
for (int i = 0; i < GameManager.Instance._DataAZBSHandler.AZBSDataArray.Count; i++)
|
|
{
|
|
curstep = GameManager.Instance._DataAZBSHandler.AZBSDataArray[i];
|
|
if (i == GameManager.Instance._DataAZBSHandler.AZBSDataArray.Count - 1)
|
|
{
|
|
nextstep = null;
|
|
}
|
|
else
|
|
{
|
|
nextstep = GameManager.Instance._DataAZBSHandler.AZBSDataArray[i + 1];
|
|
}
|
|
curStepChildTotalScore += curstep.score;
|
|
if (nextstep == null || !nextstep.stepNameChild.Equals(curstep.stepNameChild))
|
|
{
|
|
realityScore = 0;
|
|
if (_examAZBSScore.ContainsKey(curstep.stepName) && _examAZBSScore[curstep.stepName].ContainsKey(curstep.stepNameChild))
|
|
{
|
|
realityScore = _examAZBSScore[curstep.stepName][curstep.stepNameChild];
|
|
}
|
|
scoreFinish.Enqueue(new string[] { curstep.stepName, curstep.stepNameChild, curStepChildTotalScore.ToString(), realityScore.ToString() });
|
|
TotalAZBSScore += realityScore;
|
|
curStepChildTotalScore = 0;
|
|
}
|
|
}
|
|
return scoreFinish;
|
|
}
|
|
/// <summary>
|
|
/// 操作正确步骤后得分
|
|
/// </summary>
|
|
/// <param name="bigStepName">大步骤名字</param>
|
|
/// <param name="smallStepName">子步骤名字</param>
|
|
/// <param name="score">当前步骤可得分数</param>
|
|
/// <returns></returns>
|
|
public float AddScore(string bigStepName, string smallStepName, float score)
|
|
{
|
|
if (!_examAZBSScore.ContainsKey(bigStepName))
|
|
{
|
|
_examAZBSScore.Add(bigStepName, new Dictionary<string, float>());
|
|
}
|
|
if (!_examAZBSScore[bigStepName].ContainsKey(smallStepName))
|
|
{
|
|
_examAZBSScore[bigStepName].Add(smallStepName, 0);
|
|
}
|
|
_examAZBSScore[bigStepName][smallStepName] += score;
|
|
return _examAZBSScore[bigStepName][smallStepName];
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 为存储安装部署每个步骤中涉及物体信息存储类
|
|
/// </summary>
|
|
public class ModelData
|
|
{
|
|
[ReadOnly]
|
|
private string identityID;//唯一标识符
|
|
public bool modelShowAble;
|
|
public GameObject modelPart;//物件
|
|
public string modelTag;//物件tag值
|
|
public Quaternion startWorldEuler;//初始欧拉角数值
|
|
public Vector3 startWorldPosition;//初始位置数值;
|
|
public PathManager modePm;//pathManager组件
|
|
|
|
public ModelData(GameObject _modelPart, Quaternion _startWorldEuler, Vector3 _startWorldPosition, string _modelTag, PathManager _modePm = null)
|
|
{
|
|
identityID = Guid.NewGuid().ToString("N");
|
|
modelPart = _modelPart;
|
|
modelShowAble = _modelPart.activeSelf;
|
|
startWorldEuler = _startWorldEuler;
|
|
startWorldPosition = _startWorldPosition;
|
|
modelTag = _modelTag;
|
|
modePm = _modePm;
|
|
}
|
|
}
|
|
} |