GameLaunch.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class GameLaunch : MonoBehaviour
  7. {
  8. /// <summary>
  9. /// 进度加载
  10. /// </summary>
  11. [SerializeField]
  12. private AsyncLoad m_asyncLoad;
  13. [Header("是否开启进度加载")]
  14. [SerializeField]
  15. private bool m_isOpenAsyncLoad;
  16. private void Start()
  17. {
  18. InitStartupData();
  19. }
  20. /// <summary>
  21. /// 初始化启动数据
  22. /// </summary>
  23. private void InitStartupData()
  24. {
  25. string[] args = Environment.GetCommandLineArgs();
  26. if (args.Length < 2)
  27. {
  28. return;
  29. }
  30. //模拟数据
  31. //string simulationData = "b4d71ce589ed0ab52b945a7e42fd6499d00c58b7/PC_电缆熔接头制作/1/12345678910/47.92.0.243:15158/Exam/PC_电缆熔接头制作/这是总平台参数";
  32. //string[] tmpArgs = simulationData.Split('/');
  33. string[] tmpArgs = args[1].Decrypt("chivatech").Split('/');
  34. // 文件各种:手机号/课程名/模式/地址
  35. string tmpPhoneNumber = "";
  36. string tmpCourseName = "";
  37. string tmpLoadScene = "";
  38. string tmpMode = "";
  39. UserProxy userProxy = DAL.Instance.Get<UserProxy>();
  40. if (String.IsNullOrEmpty(tmpArgs[2]))
  41. userProxy.userInfo.userName = "Chiva";
  42. else
  43. userProxy.userInfo.userName = tmpArgs[2];
  44. if (String.IsNullOrEmpty(tmpArgs[3]))
  45. userProxy.userInfo.phoneNumber = "40008013900";
  46. else
  47. userProxy.userInfo.phoneNumber = tmpArgs[3];
  48. Debug.Log(tmpArgs.Length + "-asd-" + args[1]);
  49. if (tmpArgs.Length < 4)
  50. {
  51. #region 电专平台接口解析
  52. // 文件各种:手机号/课程名/模式/地址
  53. tmpPhoneNumber = tmpArgs[0];
  54. tmpCourseName = tmpArgs[1];
  55. tmpMode = tmpArgs[2];
  56. //if (tmpArgs.Length > 3)
  57. //{
  58. // string tmpAddress = tmpArgs[3];
  59. // //GrpcChannelContronller.Instance.StartClient(tmpAddress);
  60. // GetInfoaboutSpecifiedUser(tmpPhoneNumber);
  61. //}
  62. #endregion
  63. }
  64. else
  65. {
  66. #region 通用平台接口解析
  67. tmpPhoneNumber = tmpArgs[5];
  68. tmpMode = tmpArgs[2];
  69. GrpcChannelContronller.Instance.StartClient(tmpArgs[4]);
  70. tmpCourseName = tmpArgs[1];
  71. GlobalConfig.m_SelectDevice = tmpCourseName;
  72. tmpLoadScene = tmpArgs[6];
  73. switch (tmpArgs[5])
  74. {
  75. case "Learn":
  76. tmpMode = "学习";
  77. break;
  78. case "Practice":
  79. tmpMode = "练习";
  80. break;
  81. case "Exam":
  82. tmpMode = "考核";
  83. break;
  84. default:
  85. tmpMode = "学习";
  86. break;
  87. }
  88. Debug.Log(tmpCourseName + " --" + tmpMode);
  89. #endregion
  90. }
  91. //自由模式场景进自由练考模式
  92. if (tmpCourseName.Contains("Free"))
  93. {
  94. SetOperationMode(tmpMode, true);
  95. }
  96. else
  97. {
  98. SetOperationMode(tmpMode);
  99. }
  100. GlobalConfig.m_SelectDevice = tmpCourseName;
  101. if (!string.IsNullOrEmpty(tmpLoadScene))
  102. {
  103. m_asyncLoad.Init(tmpLoadScene, m_isOpenAsyncLoad);
  104. }
  105. else
  106. {
  107. Debug.Log($"ERROR:请检查是否存在 {tmpLoadScene} 课程");
  108. }
  109. }
  110. /// <summary>
  111. /// 获取指定用户信息
  112. /// </summary>
  113. /// <param name="_phoneNumber"></param>
  114. private void GetInfoaboutSpecifiedUser(string _phoneNumber)
  115. {
  116. UserProxy userProxy = DAL.Instance.Get<UserProxy>();
  117. SearchInfoResponse tmpResponse = GrpcChannelContronller.Instance.client.StudentInfoSearch(new SearchRequest()
  118. {
  119. PhoneNumber = _phoneNumber
  120. });
  121. if (tmpResponse.Result)
  122. {
  123. userProxy.userInfo.userName = tmpResponse.StudentInfos[0].Name;
  124. userProxy.userInfo.phoneNumber = _phoneNumber;
  125. }
  126. }
  127. /// <summary>
  128. /// 设置操作模式
  129. /// </summary>
  130. /// <param name="_mode"></param>
  131. private void SetOperationMode(string _mode, bool freeMode = false)
  132. {
  133. switch (_mode)
  134. {
  135. case "学习":
  136. GlobalData.m_CurrentOperationMode = OperationMode.Learn;
  137. break;
  138. case "练习":
  139. if (freeMode)
  140. {
  141. GlobalData.m_CurrentOperationMode = OperationMode.FreeParctice;
  142. }
  143. else
  144. {
  145. GlobalData.m_CurrentOperationMode = OperationMode.Practice;
  146. }
  147. break;
  148. case "考核":
  149. if (freeMode)
  150. {
  151. GlobalData.m_CurrentOperationMode = OperationMode.FreeExam;
  152. }
  153. else
  154. {
  155. GlobalData.m_CurrentOperationMode = OperationMode.Exam;
  156. }
  157. break;
  158. }
  159. }
  160. }