EventDispatcher.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using UnityEngine;
  2. using System;
  3. using System.Collections.Generic;
  4. using Sfs2X.Core;
  5. using Sfs2X.Entities;
  6. using Sfs2X.Requests;
  7. using Sfs2X.Entities.Data;
  8. public class EventDispatcher
  9. {
  10. public SFSEventManager SFSEventManager;
  11. public EventDispatcher(SFSEventManager eventManager)
  12. {
  13. SFSEventManager = eventManager;
  14. SFSEventManager.GardenSmartFox.SmartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
  15. }
  16. public void OnExtensionResponse(BaseEvent baseEvent)
  17. {
  18. string cmd = baseEvent.Params[SFSLabel.DefaultCommand].ToString();
  19. if (cmd == PlazaRoomRep.JoinRoomError.GetHashString())
  20. {
  21. SFSEventManager.PlazaRoomEvent.OnJoinPlazaRoomError(baseEvent);
  22. }
  23. else if (cmd == PlazaRoomRep.JoinRoomSucceed.GetHashString())
  24. {
  25. SFSEventManager.PlazaRoomEvent.OnJoinPlazaRoomSucceed(baseEvent);
  26. }
  27. else if (cmd == PlazaRoomRep.CreateRoomError.GetHashString())
  28. {
  29. SFSEventManager.PlazaRoomEvent.OnCreateRoomError(baseEvent);
  30. }
  31. else if (cmd == PlazaRoomRep.CreateRoomSucceed.GetHashString())
  32. {
  33. SFSEventManager.PlazaRoomEvent.OnCreateRoomSucceed(baseEvent);
  34. }
  35. else if (cmd == PlazaRoomRep.ReceiveInfo.GetHashString())
  36. {
  37. SFSEventManager.PlazaRoomEvent.OnReceiveInfo(baseEvent);
  38. }
  39. else if (cmd == PlazaRoomRep.ActivateDefaultChest.GetHashString())
  40. {
  41. SFSEventManager.PlazaRoomEvent.OnActivateDefaultChest(baseEvent);
  42. }
  43. else if (cmd == PlazaRoomRep.CreateChestError.GetHashString())
  44. {
  45. SFSEventManager.PlazaRoomEvent.OnCreateChestError(baseEvent);
  46. }
  47. else if (cmd == PlazaRoomRep.CreateChestSucceed.GetHashString())
  48. {
  49. SFSEventManager.PlazaRoomEvent.OnCreateChestSucceed(baseEvent);
  50. }
  51. else if (cmd == PlazaRoomRep.ReceiveNewChest.GetHashString())
  52. {
  53. SFSEventManager.PlazaRoomEvent.OnReceiveNewChest(baseEvent);
  54. }
  55. else if (cmd == PlazaRoomRep.ReceiveChestRefund.GetHashString())
  56. {
  57. SFSEventManager.PlazaRoomEvent.OnReceiveChestRefund(baseEvent);
  58. }
  59. else if (cmd == PlazaRoomRep.ReceiveChestAward.GetHashString())
  60. {
  61. SFSEventManager.PlazaRoomEvent.OnReceiveChestAward(baseEvent);
  62. }
  63. else if (cmd == PlazaRoomRep.ReceiveAllChestData.GetHashString())
  64. {
  65. SFSEventManager.PlazaRoomEvent.OnReceiveAllChestData(baseEvent);
  66. }
  67. else if (cmd == PlazaRoomRep.ReceiveRoomData.GetHashString())
  68. {
  69. SFSEventManager.PlazaRoomEvent.OnReceiveRoomData(baseEvent);
  70. }
  71. else if (cmd == PlazaRoomRep.ReceiveCustomRoomData.GetHashString())
  72. {
  73. SFSEventManager.PlazaRoomEvent.OnReceiveCustomRoomData(baseEvent);
  74. }
  75. else if (cmd == PlazaRoomRep.ReceiveRoomFullStatus.GetHashString())
  76. {
  77. SFSEventManager.PlazaRoomEvent.OnReceiveRoomFullStatus(baseEvent);
  78. }
  79. else if (cmd == PlazaRoomRep.OtherEnterRoom.GetHashString())
  80. {
  81. SFSEventManager.PlazaRoomEvent.OnOtherEnterRoom(baseEvent);
  82. }
  83. else if (cmd == PlazaRoomRep.OtherExitRoom.GetHashString())
  84. {
  85. SFSEventManager.PlazaRoomEvent.OnOtherExitRoom(baseEvent);
  86. }
  87. else if (cmd == PlazaRoomRep.ReceiveChestExpireStatus.GetHashString())
  88. {
  89. SFSEventManager.PlazaRoomEvent.OnReceiveChestExpireStatus(baseEvent);
  90. }
  91. else if (cmd == PlazaRoomRep.ReactivateDefaultChest.GetHashString())
  92. {
  93. SFSEventManager.PlazaRoomEvent.OnReactivateDefaultChest(baseEvent);
  94. }
  95. else if (cmd == PlazaRoomRep.DeactivateDefaultChest.GetHashString())
  96. {
  97. SFSEventManager.PlazaRoomEvent.OnDeactivateDefaultChest(baseEvent);
  98. }
  99. else if (cmd == PlazaRoomRep.LeaveRoomSucceed.GetHashString())
  100. {
  101. SFSEventManager.PlazaRoomEvent.OnLeaveRoom(baseEvent);
  102. }
  103. else if (cmd == PlazaRoomRep.CreateRobot.GetHashString())
  104. {
  105. SFSEventManager.PlazaRoomEvent.CreateRobot(baseEvent);
  106. }
  107. else
  108. {
  109. throw new Exception();
  110. }
  111. }
  112. }