ServerData.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class ServerData
  5. {
  6. public string serverName;//服务器的名字
  7. public string ipStr;//服务器地址
  8. public int port;//端口号
  9. public ServerType serverType;// 学校自己的服务器 还是
  10. }
  11. public enum ServerType
  12. {
  13. Public,
  14. Private,
  15. }
  16. public class GameServerInfo
  17. {
  18. private static GameServerInfo _instance;
  19. public static GameServerInfo Instance
  20. {
  21. get
  22. {
  23. if (_instance == null)
  24. {
  25. _instance = new GameServerInfo();
  26. }
  27. return _instance;
  28. }
  29. }
  30. public ServerData CurServer;
  31. public List<ServerData> servers;
  32. private GameServerInfo()
  33. {
  34. servers = new List<ServerData>();
  35. }
  36. //初始化服务器列表
  37. public void InitServerInfo()
  38. {
  39. servers.Clear();//先清空原有的服务器数据
  40. }
  41. public void AddServer(string serverName, string ipStr, int port, ServerType serverType)
  42. {
  43. ServerData data = new ServerData();
  44. data.serverName = serverName;
  45. data.serverType = serverType;
  46. data.ipStr = ipStr;
  47. data.port = port;
  48. servers.Add(data);
  49. }
  50. }