ErrorCodeController.cs 3.2 KB

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