123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using UnityEngine;
- using System;
- using System.Collections.Generic;
- using Sfs2X.Core;
- using Sfs2X.Entities;
- using Sfs2X.Requests;
- using Sfs2X.Entities.Data;
- public class EventDispatcher
- {
- public SFSEventManager SFSEventManager;
- public EventDispatcher(SFSEventManager eventManager)
- {
- SFSEventManager = eventManager;
- SFSEventManager.GardenSmartFox.SmartFox.AddEventListener(SFSEvent.EXTENSION_RESPONSE, OnExtensionResponse);
- }
- public void OnExtensionResponse(BaseEvent baseEvent)
- {
- string cmd = baseEvent.Params[SFSLabel.DefaultCommand].ToString();
- if (cmd == PlazaRoomRep.JoinRoomError.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnJoinPlazaRoomError(baseEvent);
- }
- else if (cmd == PlazaRoomRep.JoinRoomSucceed.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnJoinPlazaRoomSucceed(baseEvent);
- }
- else if (cmd == PlazaRoomRep.CreateRoomError.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnCreateRoomError(baseEvent);
- }
- else if (cmd == PlazaRoomRep.CreateRoomSucceed.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnCreateRoomSucceed(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveInfo.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveInfo(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ActivateDefaultChest.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnActivateDefaultChest(baseEvent);
- }
- else if (cmd == PlazaRoomRep.CreateChestError.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnCreateChestError(baseEvent);
- }
- else if (cmd == PlazaRoomRep.CreateChestSucceed.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnCreateChestSucceed(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveNewChest.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveNewChest(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveChestRefund.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveChestRefund(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveChestAward.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveChestAward(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveAllChestData.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveAllChestData(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveRoomData.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveRoomData(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveCustomRoomData.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveCustomRoomData(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveRoomFullStatus.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveRoomFullStatus(baseEvent);
- }
- else if (cmd == PlazaRoomRep.OtherEnterRoom.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnOtherEnterRoom(baseEvent);
- }
- else if (cmd == PlazaRoomRep.OtherExitRoom.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnOtherExitRoom(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReceiveChestExpireStatus.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReceiveChestExpireStatus(baseEvent);
- }
- else if (cmd == PlazaRoomRep.ReactivateDefaultChest.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnReactivateDefaultChest(baseEvent);
- }
- else if (cmd == PlazaRoomRep.DeactivateDefaultChest.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnDeactivateDefaultChest(baseEvent);
- }
- else if (cmd == PlazaRoomRep.LeaveRoomSucceed.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.OnLeaveRoom(baseEvent);
- }
- else if (cmd == PlazaRoomRep.CreateRobot.GetHashString())
- {
- SFSEventManager.PlazaRoomEvent.CreateRobot(baseEvent);
- }
- else
- {
- throw new Exception();
- }
- }
- }
|