ErrorCodeController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. namespace GFGGame
  3. {
  4. public class ErrorCodeController
  5. {
  6. //返回结果为true时,表示可以在错误提示后继续处理后续逻辑
  7. public static bool Handler(int errorCode)
  8. {
  9. switch (errorCode)
  10. {
  11. case ET.ErrorCode.ERR_NetWorkError:
  12. {
  13. AlertSystem.Show("网络异常,也有可能是服务器异常,请稍后再试!")
  14. .SetRightButton(true, "好的", (object data) =>
  15. {
  16. });
  17. }
  18. break;
  19. case ET.ErrorCode.ERR_ClientVersionError:
  20. {
  21. AlertSystem.Show("客户端版本错误,请联系研发获取最新版本!")
  22. .SetLeftButton(true, "知道了", (data) =>
  23. {
  24. Application.Quit();
  25. });
  26. return false;
  27. }
  28. case ET.ErrorCode.Err_LoginCountFull:
  29. {
  30. AlertSystem.Show("游戏已爆满,请稍后再试!")
  31. .SetLeftButton(true, "好的", (data) =>
  32. {
  33. });
  34. }
  35. break;
  36. case ET.ErrorCode.Err_ServerMaintain:
  37. {
  38. AlertSystem.Show("服务器维护中,请稍后再试!")
  39. .SetLeftButton(true, "好的", (data) =>
  40. {
  41. });
  42. }
  43. break;
  44. case ET.ErrorCode.ERR_AntiAddiction:
  45. {
  46. string promptStr = "您属于未成年人,已被纳入防沉迷系统,当前为非游戏时间,本游戏将无法为未成年人用户提供游戏服务。";
  47. AlertSystem.Show(promptStr)
  48. .SetRightButton(true, "休息一下", (object data) =>
  49. {
  50. Application.Quit();
  51. });
  52. return false;
  53. }
  54. default:
  55. if (ErrorCodeCfgArray.Instance.GetCfg(errorCode) != null)
  56. {
  57. PromptController.Instance.ShowFloatTextPrompt(ErrorCodeCfgArray.Instance.GetCfg(errorCode).tips);
  58. ET.Log.Debug("errorCode" + errorCode.ToString());
  59. }
  60. else
  61. {
  62. PromptController.Instance.ShowFloatTextPrompt("errorCode " + errorCode.ToString());
  63. ET.Log.Error("errorCode" + errorCode.ToString());
  64. }
  65. break;
  66. }
  67. return true;
  68. }
  69. }
  70. }