EventDispatcher.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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["cmd"].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. }
  42. else if (cmd == PlazaRoomRep.CreateChestError.GetHashString())
  43. {
  44. }
  45. else if (cmd == PlazaRoomRep.CreateChestSucceed.GetHashString())
  46. {
  47. }
  48. else if (cmd == PlazaRoomRep.ReceiveNewChest.GetHashString())
  49. {
  50. }
  51. else if (cmd == PlazaRoomRep.ReceiveChestRefund.GetHashString())
  52. {
  53. SFSEventManager.PlazaRoomEvent.OnReceiveChestRefund(baseEvent);
  54. }
  55. else if (cmd == PlazaRoomRep.ReceiveChestAward.GetHashString())
  56. {
  57. SFSEventManager.PlazaRoomEvent.OnReceiveChestAward(baseEvent);
  58. }
  59. else if (cmd == PlazaRoomRep.ReceiveAllChestData.GetHashString())
  60. {
  61. SFSEventManager.PlazaRoomEvent.OnReceiveAllChestData(baseEvent);
  62. }
  63. else if (cmd == PlazaRoomRep.ReceiveRoomData.GetHashString())
  64. {
  65. SFSEventManager.PlazaRoomEvent.OnReceiveRoomData(baseEvent);
  66. }
  67. else if (cmd == PlazaRoomRep.ReceiveCustomRoomData.GetHashString())
  68. {
  69. SFSEventManager.PlazaRoomEvent.OnReceiveCustomRoomData(baseEvent);
  70. }
  71. else if (cmd == PlazaRoomRep.ReceiveRoomStatus.GetHashString())
  72. {
  73. SFSEventManager.PlazaRoomEvent.OnReceiveRoomStatus(baseEvent);
  74. }
  75. else if (cmd == PlazaRoomRep.OtherEnterRoom.GetHashString())
  76. {
  77. SFSEventManager.PlazaRoomEvent.OnOtherEnterRoom(baseEvent);
  78. }
  79. else if (cmd == PlazaRoomRep.OtherExitRoom.GetHashString())
  80. {
  81. SFSEventManager.PlazaRoomEvent.OnOtherExitRoom(baseEvent);
  82. }
  83. else
  84. {
  85. throw new Exception();
  86. }
  87. }
  88. }