LodingPanelManager.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class LodingPanelManager : MonoBehaviour
  6. {
  7. // Start is called before the first frame update
  8. public GameObject[] enemyAndFirendlyImage;//选中框集合
  9. public GameObject[] CheckBoxCheck;// √集合
  10. public PosCommunication posC;
  11. public Game3DInputField button3DKey;
  12. private string userInputName;
  13. private string playerAction;
  14. public GameObject showGameObj;
  15. private int index;
  16. public GameObject gameManagerObj;
  17. public GameObject loginEffict, ChangeUImg;
  18. public AudioSource backgroundMusic;
  19. public TestGetVoice voice;
  20. void Start()
  21. {
  22. Invoke("StartEffict", 3f);
  23. button3DKey.text = string.Empty;
  24. string ip = PlayerPrefs.GetString("ip");//读取本地保存的IP
  25. if (ip != string.Empty)
  26. {
  27. button3DKey.text = ip;
  28. }
  29. }
  30. /// <summary>
  31. /// 打开特效
  32. /// </summary>
  33. public void StartEffict()
  34. {
  35. backgroundMusic.Play();
  36. loginEffict.gameObject.SetActive(true);
  37. Invoke("OpenScence3", 8f);
  38. }
  39. public void OpenScence3()
  40. {
  41. // ChangeUImg.SetActive(true);
  42. // showGameObj.transform.GetChild(0).gameObject.GetComponent<Animator>().SetBool("M2", true);
  43. userInputName = "TCCCCCCCCCC";
  44. playerAction = "PlayerUser";
  45. UserClickUserTypeOfWorkIcon("FriendlyForcesTypeOfWork1");//默认选择陆战编队
  46. UserClickUserTypeOfWorkIcon("LodingButton");//默认选择陆战编队
  47. }
  48. // Update is called once per frame
  49. void Update()
  50. {
  51. }
  52. public void UserClickUserTypeOfWorkIcon(string TypeOfWork)
  53. {
  54. switch (TypeOfWork)
  55. {
  56. //case "EnemyTypeOfWork1":
  57. // posC.player_typeOfWork = TypeOfWork;
  58. // ChangeBjImage(0);
  59. // break;
  60. //case "EnemyTypeOfWork2":
  61. // posC.player_typeOfWork = TypeOfWork;
  62. // ChangeBjImage(2);
  63. // break;
  64. //case "EnemyTanke":
  65. // posC.player_typeOfWork = TypeOfWork;
  66. // ChangeBjImage(1);
  67. // break;
  68. case "FriendlyForcesTypeOfWork1":
  69. posC.player_typeOfWork = TypeOfWork;
  70. ChangeBjImage(0);
  71. break;
  72. case "FriendlyForcesTypeOfWork2":
  73. posC.player_typeOfWork = TypeOfWork;
  74. ChangeBjImage(2);
  75. break;
  76. case "FriendlyForcesTank":
  77. posC.player_typeOfWork = TypeOfWork;
  78. ChangeBjImage(1);
  79. break;
  80. case "LodingButton":
  81. userInputName = button3DKey.text;
  82. PlayerPrefs.SetString("ip", userInputName);
  83. //posC.player_name_InputName = userInputName;
  84. posC.playerAction = playerAction;
  85. posC.player_ID = UnityEngine.Random.Range(0, 1000000000).ToString(); //随机下标
  86. posC.player_name_InputName = "FriendlyForcesTypeOfWork1" + "," + posC.player_ID;
  87. this.gameObject.SetActive(false);
  88. // showGameObj.SetActive(true);
  89. gameManagerObj.SetActive(true);
  90. showGameObj.gameObject.SetActive(true);
  91. showGameObj.gameObject.transform.position = GameManager.instacne.scence3followPos.transform.position;
  92. showGameObj.gameObject.transform.eulerAngles = GameManager.instacne.scence3followPos.transform.eulerAngles;
  93. GameManager.instacne.scenesName = "scenes3";
  94. loginEffict.gameObject.SetActive(false);
  95. // 初始化语音识别
  96. voice.Initialize = true;
  97. break;
  98. }
  99. }
  100. private void ChangeBjImage(int index)
  101. {
  102. for (int i = 0; i < enemyAndFirendlyImage.Length; i++)
  103. {
  104. if (i == index)
  105. {
  106. enemyAndFirendlyImage[i].GetComponent<MeshRenderer>().material.color = new Color(43f / 255f, 161f / 255f, 33f / 255f);
  107. CheckBoxCheck[i].gameObject.SetActive(true);
  108. }
  109. else
  110. {
  111. enemyAndFirendlyImage[i].GetComponent<MeshRenderer>().material.color = new Color(64f / 255f, 64f / 255f, 64f / 255f);
  112. CheckBoxCheck[i].gameObject.SetActive(false);
  113. }
  114. }
  115. }
  116. }