GameLaunch.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 = "11111111111/10kV真空断路器及开关柜例行检修/练习/47.92.0.243:15156";
  32. //string[] tmpArgs = simulationData.Split('/');
  33. //截断
  34. string[] tmpArgs = args[1].Split('/');
  35. // 文件各种:手机号/课程名/模式/地址
  36. string tmpPhoneNumber = tmpArgs[0];
  37. string tmpCourseName = tmpArgs[1];
  38. string tmpMode = tmpArgs[2];
  39. if (tmpArgs.Length > 3)
  40. {
  41. string tmpAddress = tmpArgs[3];
  42. GrpcChannelContronller.Instance.StartClient(tmpAddress);
  43. GetInfoaboutSpecifiedUser(tmpPhoneNumber);
  44. }
  45. //自由模式场景进自由练考模式
  46. if (tmpCourseName.Contains("Free"))
  47. {
  48. SetOperationMode(tmpMode, true);
  49. }
  50. else
  51. {
  52. SetOperationMode(tmpMode);
  53. }
  54. GlobalConfig.m_SelectDevice = tmpCourseName;
  55. if (!string.IsNullOrEmpty(tmpCourseName))
  56. {
  57. m_asyncLoad.Init(tmpCourseName, m_isOpenAsyncLoad);
  58. }
  59. else
  60. {
  61. Debug.Log($"ERROR:请检查是否存在 {tmpCourseName} 课程");
  62. }
  63. }
  64. /// <summary>
  65. /// 获取指定用户信息
  66. /// </summary>
  67. /// <param name="_phoneNumber"></param>
  68. private void GetInfoaboutSpecifiedUser(string _phoneNumber)
  69. {
  70. UserProxy userProxy = DAL.Instance.Get<UserProxy>();
  71. SearchInfoResponse tmpResponse = GrpcChannelContronller.Instance.client.StudentInfoSearch(new SearchRequest()
  72. {
  73. PhoneNumber = _phoneNumber
  74. });
  75. if (tmpResponse.Result)
  76. {
  77. userProxy.userInfo.userName = tmpResponse.StudentInfos[0].Name;
  78. userProxy.userInfo.phoneNumber = _phoneNumber;
  79. }
  80. }
  81. /// <summary>
  82. /// 设置操作模式
  83. /// </summary>
  84. /// <param name="_mode"></param>
  85. private void SetOperationMode(string _mode, bool freeMode = false)
  86. {
  87. switch (_mode)
  88. {
  89. case "学习":
  90. GlobalData.m_CurrentOperationMode = OperationMode.Learn;
  91. break;
  92. case "练习":
  93. if(freeMode)
  94. {
  95. GlobalData.m_CurrentOperationMode = OperationMode.FreeParctice;
  96. }
  97. else
  98. {
  99. GlobalData.m_CurrentOperationMode = OperationMode.Practice;
  100. }
  101. break;
  102. case "考核":
  103. if (freeMode)
  104. {
  105. GlobalData.m_CurrentOperationMode = OperationMode.FreeExam;
  106. }
  107. else
  108. {
  109. GlobalData.m_CurrentOperationMode = OperationMode.Exam;
  110. }
  111. break;
  112. }
  113. }
  114. }