| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class GameLaunch : MonoBehaviour
- {
- /// <summary>
- /// 进度加载
- /// </summary>
- [SerializeField]
- private AsyncLoad m_asyncLoad;
- [Header("是否开启进度加载")]
- [SerializeField]
- private bool m_isOpenAsyncLoad;
- private void Start()
- {
- InitStartupData();
- }
- /// <summary>
- /// 初始化启动数据
- /// </summary>
- private void InitStartupData()
- {
- string[] args = Environment.GetCommandLineArgs();
- if (args.Length < 2)
- {
- return;
- }
- //模拟数据
- //string simulationData = "b4d71ce589ed0ab52b945a7e42fd6499d00c58b7/PC_电缆熔接头制作/1/12345678910/47.92.0.243:15158/Exam/PC_电缆熔接头制作/这是总平台参数";
- //string[] tmpArgs = simulationData.Split('/');
- string[] tmpArgs = args[1].Decrypt("chivatech").Split('/');
- // 文件各种:手机号/课程名/模式/地址
- string tmpPhoneNumber = "";
- string tmpCourseName = "";
- string tmpLoadScene = "";
- string tmpMode = "";
- UserProxy userProxy = DAL.Instance.Get<UserProxy>();
- if (String.IsNullOrEmpty(tmpArgs[2]))
- userProxy.userInfo.userName = "Chiva";
- else
- userProxy.userInfo.userName = tmpArgs[2];
- if (String.IsNullOrEmpty(tmpArgs[3]))
- userProxy.userInfo.phoneNumber = "40008013900";
- else
- userProxy.userInfo.phoneNumber = tmpArgs[3];
- Debug.Log(tmpArgs.Length + "-asd-" + args[1]);
- if (tmpArgs.Length < 4)
- {
- #region 电专平台接口解析
- // 文件各种:手机号/课程名/模式/地址
- tmpPhoneNumber = tmpArgs[0];
- tmpCourseName = tmpArgs[1];
- tmpMode = tmpArgs[2];
- //if (tmpArgs.Length > 3)
- //{
- // string tmpAddress = tmpArgs[3];
- // //GrpcChannelContronller.Instance.StartClient(tmpAddress);
- // GetInfoaboutSpecifiedUser(tmpPhoneNumber);
- //}
- #endregion
- }
- else
- {
- #region 通用平台接口解析
- tmpPhoneNumber = tmpArgs[5];
- tmpMode = tmpArgs[2];
- GrpcChannelContronller.Instance.StartClient(tmpArgs[4]);
- tmpCourseName = tmpArgs[1];
- GlobalConfig.m_SelectDevice = tmpCourseName;
- tmpLoadScene = tmpArgs[6];
- switch (tmpArgs[5])
- {
- case "Learn":
- tmpMode = "学习";
- break;
- case "Practice":
- tmpMode = "练习";
- break;
- case "Exam":
- tmpMode = "考核";
- break;
- default:
- tmpMode = "学习";
- break;
- }
- Debug.Log(tmpCourseName + " --" + tmpMode);
- #endregion
- }
- //自由模式场景进自由练考模式
- if (tmpCourseName.Contains("Free"))
- {
- SetOperationMode(tmpMode, true);
- }
- else
- {
- SetOperationMode(tmpMode);
- }
- GlobalConfig.m_SelectDevice = tmpCourseName;
- if (!string.IsNullOrEmpty(tmpLoadScene))
- {
- m_asyncLoad.Init(tmpLoadScene, m_isOpenAsyncLoad);
- }
- else
- {
- Debug.Log($"ERROR:请检查是否存在 {tmpLoadScene} 课程");
- }
- }
- /// <summary>
- /// 获取指定用户信息
- /// </summary>
- /// <param name="_phoneNumber"></param>
- private void GetInfoaboutSpecifiedUser(string _phoneNumber)
- {
- UserProxy userProxy = DAL.Instance.Get<UserProxy>();
- SearchInfoResponse tmpResponse = GrpcChannelContronller.Instance.client.StudentInfoSearch(new SearchRequest()
- {
- PhoneNumber = _phoneNumber
- });
- if (tmpResponse.Result)
- {
- userProxy.userInfo.userName = tmpResponse.StudentInfos[0].Name;
- userProxy.userInfo.phoneNumber = _phoneNumber;
- }
- }
- /// <summary>
- /// 设置操作模式
- /// </summary>
- /// <param name="_mode"></param>
- private void SetOperationMode(string _mode, bool freeMode = false)
- {
- switch (_mode)
- {
- case "学习":
- GlobalData.m_CurrentOperationMode = OperationMode.Learn;
- break;
- case "练习":
- if (freeMode)
- {
- GlobalData.m_CurrentOperationMode = OperationMode.FreeParctice;
- }
- else
- {
- GlobalData.m_CurrentOperationMode = OperationMode.Practice;
- }
- break;
- case "考核":
- if (freeMode)
- {
- GlobalData.m_CurrentOperationMode = OperationMode.FreeExam;
- }
- else
- {
- GlobalData.m_CurrentOperationMode = OperationMode.Exam;
- }
- break;
- }
- }
- }
|