EventDispatcher.cs 2.9 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. }
  54. else if (cmd == PlazaRoomRep.ReceiveChestData.GetHashString())
  55. {
  56. }
  57. else if (cmd == PlazaRoomRep.ReceiveAllChestData.GetHashString())
  58. {
  59. }
  60. else if (cmd == PlazaRoomRep.ReceiveRoomData.GetHashString())
  61. {
  62. SFSEventManager.PlazaRoomEvent.OnReceiveRoomData(baseEvent);
  63. }
  64. else if (cmd == PlazaRoomRep.ReceiveCustomRoomData.GetHashString())
  65. {
  66. SFSEventManager.PlazaRoomEvent.OnReceiveCustomRoomData(baseEvent);
  67. }
  68. else if (cmd == PlazaRoomRep.ReceiveRoomStatus.GetHashString())
  69. {
  70. SFSEventManager.PlazaRoomEvent.OnReceiveRoomStatus(baseEvent);
  71. }
  72. else if (cmd == PlazaRoomRep.OtherEnterRoom.GetHashString())
  73. {
  74. SFSEventManager.PlazaRoomEvent.OnOtherEnterRoom(baseEvent);
  75. }
  76. else if (cmd == PlazaRoomRep.OtherExitRoom.GetHashString())
  77. {
  78. SFSEventManager.PlazaRoomEvent.OnOtherExitRoom(baseEvent);
  79. }
  80. else
  81. {
  82. throw new Exception();
  83. }
  84. }
  85. }