ErrorCodeController.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_Cancel:
  12. return true;
  13. case ET.ErrorCode.ERR_NetWorkError:
  14. {
  15. AlertSystem.Show("网络异常,请稍后再试!")
  16. .SetRightButton(true, "好的", (object data) =>
  17. {
  18. GameController.QuitToLoginView(false);
  19. });
  20. }
  21. break;
  22. case ET.ErrorCode.ERR_ClientVersionError:
  23. {
  24. AlertSystem.Show("客户端版本错误,请联系研发获取最新版本!")
  25. .SetLeftButton(true, "知道了", (data) =>
  26. {
  27. Application.Quit();
  28. });
  29. }
  30. break;
  31. case ET.ErrorCode.ERR_RegisterCountFull:
  32. {
  33. AlertSystem.Show("游戏已爆满,暂停注册,敬请期待!")
  34. .SetLeftButton(true, "好的", (data) =>
  35. {
  36. GameController.QuitToLoginView(true);
  37. });
  38. }
  39. break;
  40. case ET.ErrorCode.Err_LoginCountFull:
  41. {
  42. AlertSystem.Show("游戏已爆满,请稍后再试!")
  43. .SetLeftButton(true, "好的", (data) =>
  44. {
  45. GameController.QuitToLoginView(true);
  46. });
  47. }
  48. break;
  49. case ET.ErrorCode.Err_ServerMaintain:
  50. {
  51. AlertSystem.Show("服务器维护中,请稍后再试!")
  52. .SetLeftButton(true, "好的", (data) =>
  53. {
  54. GameController.QuitToLoginView(true);
  55. });
  56. }
  57. break;
  58. case ET.ErrorCode.ERR_AntiAddiction:
  59. {
  60. AntiAddictionController.ShowAntiAddictionAlert();
  61. return false;
  62. }
  63. default:
  64. if (ErrorCodeCfgArray.Instance.GetCfg(errorCode) != null)
  65. {
  66. PromptController.Instance.ShowFloatTextPrompt(ErrorCodeCfgArray.Instance.GetCfg(errorCode).tips);
  67. ET.Log.Debug("errorCode" + errorCode.ToString());
  68. }
  69. else
  70. {
  71. PromptController.Instance.ShowFloatTextPrompt("errorCode " + errorCode.ToString());
  72. ET.Log.Error("errorCode" + errorCode.ToString());
  73. }
  74. return true;
  75. }
  76. return false;
  77. }
  78. }
  79. }