123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using ChivaXR.Op;
- using System.Text.RegularExpressions;
- using ChivaXR;
- using I2.Loc;
- public class ScoreInfoItem : MonoBehaviour
- {
- /// <summary>
- /// 底图
- /// </summary>
- public GameObject m_BaseMap;
-
- /// <summary>
- /// 步骤id
- /// </summary>
- public Text stepIdText;
- /// <summary>
- /// 步骤描述
- /// </summary>
- public Text stepDescriptText;
- /// <summary>
- /// 得分情况
- /// </summary>
- public Text scoreSituationText;
- public ExamProcessElement examProcessElement;
- public void Awake()
- {
- if (m_BaseMap == null)
- {
- m_BaseMap = transform.Find("LowestLayer").gameObject;
- }
- if (stepIdText == null) stepIdText = transform.Find("StepID").GetComponent<Text>();
- if (stepDescriptText == null) stepDescriptText = transform.Find("StepDesctript").GetComponent<Text>();
- if (scoreSituationText == null) scoreSituationText = transform.Find("ScoreSituation").GetComponent<Text>();
- }
- public void InitData(ExamProcessElement _examProcessElement)
- {
- examProcessElement = _examProcessElement;
- SetBasicMapEffect(_examProcessElement.id);
-
- stepIdText.text = _examProcessElement.id.ToString("000");
- stepDescriptText.text = GetSimpleStepDescript(_examProcessElement.elementDescript.ToString());
- if (_examProcessElement.finish == true && _examProcessElement.result == true)
- {
- scoreSituationText.text = "<color=#23DC8C>+" + _examProcessElement.scores + "</color>";
- }
- else
- {
- scoreSituationText.text = "<color=#EF2A0B>-" + _examProcessElement.scores + "</color>";
- }
- }
- /// <summary>
- /// 设置底图效果,奇偶变换
- /// </summary>
- /// <param name="_id"></param>
- private void SetBasicMapEffect(int _id)
- {
- if (_id % 2 == 1)
- {
- m_BaseMap.SetActive(true);
- }
- else
- {
- m_BaseMap.SetActive(false);
- }
- }
-
- /// <summary>
- /// 获取操作步骤信息
- /// </summary>
- /// <param name="descript"></param>
- /// <returns></returns>
- private string GetSimpleStepDescript(string descript)
- {
- int tmpCurrentId = ProcessManagement.Instance.currentStepID;
- StepListProxy tmpStepListProxy = DAL.Instance.Get<StepListProxy>();
- OperationStepDataInfo tmpOperationStepDataInfo = tmpStepListProxy.GetOperationStepDataInfoById(examProcessElement.id);
- if (tmpOperationStepDataInfo != null)
- {
- #region 多语言
- if(LocalizationConfig.localization)
- {
- LocalizedString SubTitle = examProcessElement.id + "stepName";
- return SubTitle;
- }
- #endregion
- return tmpOperationStepDataInfo.stepName;
- }
- // string tmpStr = LengthOfJudgment(descript);
- //string tmpStr1 = Regex.Split(tmpStr, @"^\d+").Length > 1 ? Regex.Split(tmpStr, @"^\d+")[1] : tmpStr;
- return string.Empty;
- //return tmpStr1.Split('-')[1];
- }
- /// <summary>
- /// 长度判断
- /// </summary>
- /// <param name="_data"></param>
- /// <returns></returns>
- private string LengthOfJudgment(string _data)
- {
- if (string.IsNullOrEmpty(_data))
- {
- return "";
- }
- string result = _data.Split('_').Length <= 2 ? (_data.Split('_').Length > 1 ? _data.Split('_')[1] : _data) : _data.Split('_')[_data.Split('_').Length - 1];
- return result;
- }
- }
|