GameLaunch.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. SetOperationMode(tmpMode);
  46. GlobalConfig.m_SelectDevice = tmpCourseName;
  47. if (!string.IsNullOrEmpty(tmpCourseName))
  48. {
  49. m_asyncLoad.Init(tmpCourseName, m_isOpenAsyncLoad);
  50. }
  51. else
  52. {
  53. Debug.Log($"ERROR:请检查是否存在 {tmpCourseName} 课程");
  54. }
  55. }
  56. /// <summary>
  57. /// 获取指定用户信息
  58. /// </summary>
  59. /// <param name="_phoneNumber"></param>
  60. private void GetInfoaboutSpecifiedUser(string _phoneNumber)
  61. {
  62. UserProxy userProxy = DAL.Instance.Get<UserProxy>();
  63. SearchInfoResponse tmpResponse = GrpcChannelContronller.Instance.client.StudentInfoSearch(new SearchRequest()
  64. {
  65. PhoneNumber = _phoneNumber
  66. });
  67. if (tmpResponse.Result)
  68. {
  69. userProxy.userInfo.userName = tmpResponse.StudentInfos[0].Name;
  70. userProxy.userInfo.phoneNumber = _phoneNumber;
  71. }
  72. }
  73. /// <summary>
  74. /// 设置操作模式
  75. /// </summary>
  76. /// <param name="_mode"></param>
  77. private void SetOperationMode(string _mode)
  78. {
  79. switch (_mode)
  80. {
  81. case "学习":
  82. GlobalData.m_CurrentOperationMode = OperationMode.Learn;
  83. break;
  84. case "练习":
  85. GlobalData.m_CurrentOperationMode = OperationMode.Practice;
  86. break;
  87. case "考核":
  88. GlobalData.m_CurrentOperationMode = OperationMode.Exam;
  89. break;
  90. }
  91. }
  92. }