ViewManager.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class ViewManager : MonoBehaviour
  6. {
  7. public static int LOGINROOM_VIEW = 0;
  8. public static int SETNAME_VIEW = 1;
  9. public static int BASESET_VIEW = 2;
  10. public static int ROOM_VIEW = 3;
  11. public GameObject[] ViewList;
  12. public static ViewManager Instance;
  13. public GameObject Tusi;
  14. public Text TusiText;
  15. void Start()
  16. {
  17. Instance = this;
  18. ShowView(LOGINROOM_VIEW);
  19. }
  20. void Update()
  21. {
  22. LoginManager.Instance.InputUserName();
  23. LoginManager.Instance.InputUserName1();
  24. }
  25. public void ShowView(int index)
  26. {
  27. for (int i = 0; i < ViewList.Length; i++)
  28. {
  29. if (i == index)
  30. {
  31. ViewList[i].SetActive(true);
  32. }
  33. else
  34. {
  35. ViewList[i].SetActive(false);
  36. }
  37. }
  38. }
  39. public void ShowTuSi(string action, string msg="")
  40. {
  41. switch (action)
  42. {
  43. case "PassError":
  44. Tusi.SetActive(true);
  45. TusiText.text = msg;
  46. Invoke("CloseTusi", 2f);
  47. break;
  48. case "ServerException":
  49. Tusi.SetActive(true);
  50. TusiText.text = "服务器异常";
  51. Invoke("CloseTusi", 2f);
  52. break;
  53. case "JoinRoom":
  54. Tusi.SetActive(true);
  55. TusiText.text = msg + "已经加入了房间";
  56. Invoke("CloseTusi", 2f);
  57. break;
  58. case "LeaveRoom":
  59. Tusi.SetActive(true);
  60. TusiText.text = msg + "已经退出了房间";
  61. Invoke("CloseTusi", 2f);
  62. break;
  63. }
  64. }
  65. public void CloseTusi()
  66. {
  67. Tusi.SetActive(false);
  68. }
  69. }