Exemple #1
0
        public override void OnMessage(USocket us, ByteBuf bb)
        {
            if (onMessage != null)
            {
                onMessage();
            }
            int len = bb.ReadShort();

            if (bb.ReadableBytes() != len)
            {
                Log.Error("数据长度不对!");
                return;
            }
            MessageID msgId = (MessageID)bb.ReadShort();

            byte[]   data    = bb.ReadBytes(len - 2);
            IMessage msgData = MessageMap.GetMessageData(msgId, data);

            if (msgData == null)
            {
                return;
            }
            //Messenger.BroadcastAsync<IMessage>(msgId.ToString(), msgData);
            Messenger.BroadcastAsync(msgId.ToString(), (object)msgData);
        }
Exemple #2
0
 private void FinishLoad()
 {
     Messenger.BroadcastAsync <string>(MSG_DEFINE.MSG_SCENE_LOAD_COMPLETE, CurrentSceneName);
     mIsLoading = false;
     InitSceneComplete();
     //Framework.GameKernel.StartMonoCoroutine(InitSceneComplete());
 }
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCEnterBattle data = packet as GCEnterBattle;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        Messenger.BroadcastAsync <int>(MessageId.GAME_ENTER_BATTLE, data.MonsterId);
    }
Exemple #4
0
 void OnClose()
 {
     netState = NetState.Closed;
     if (socket != null)
     {
         socket.Close();
     }
     Messenger.BroadcastAsync(MessageId.NetworkDisconnect);
 }
Exemple #5
0
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCMapApplyEffect data = packet as GCMapApplyEffect;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        //此处发送消息不允许使用Messenger.BroadcastSync同步通知
        //throw new System.NotImplementedException(GetType().ToString());
        Messenger.BroadcastAsync(MessageId.MAP_APPLY_EFFECT);
    }
Exemple #6
0
        private void setLoadingPercentage(int progress)
        {
            Messenger.BroadcastAsync<int>(MSG_DEFINE.MSG_LOADING_PROCESS_CHANGE, progress);

            if (progress >= 100)
            {
                progress = 100;
                Complete();
                TimeCostLog.Instance.WriteLog(SceneMgr.Instance.SceneId, eTimeCost.ePreLoad, false);         
            }
        }
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCMapOpenBox data = packet as GCMapOpenBox;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        //此处发送消息不允许使用Messenger.BroadcastSync同步通知
        if (data.Result == 0)
        {
            Messenger.BroadcastAsync(MessageId.MAP_ENTER_SHOP, data.BoxId);
        }
    }
Exemple #8
0
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCGetMapLayerData data = packet as GCGetMapLayerData;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        if (data.Result == 0)
        {
            //Messenger.BroadcastAsync<PBMapLayerData>(MessageId.MAP_GET_MAP_LAYER_DATA, data.LayerData);
            Messenger.BroadcastAsync <PBMapLayerData>(MessageId_Receive.GCGetMapLayerData, data.LayerData);
        }
    }
Exemple #9
0
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCUpdatePlayerData data = packet as GCUpdatePlayerData;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        //此处发送消息不允许使用Messenger.BroadcastSync同步通知UI
        Game.DataManager.UpdateAccount(data.AccountData);
        //目前没有皮肤了,暂时默认皮肤了
        Game.DataManager.UpdatePlayer(data.PlayerData, data.PlayerDetailData);

        Messenger.BroadcastAsync(MessageId.GAME_UPDATE_PLAYER_INFO);
    }
Exemple #10
0
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCSignIn data = packet as GCSignIn;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        //此处发送消息不允许使用Messenger.BroadcastSync同步通知
        Game.DataManager.InitAccount(data.AccountData);
        //目前没有皮肤了,暂时默认皮肤了
        Game.DataManager.InitPlayer(data.PlayerData, data.PlayerDetailData);

        Messenger.BroadcastAsync(MessageId.UI_GAME_START);
    }
Exemple #11
0
 public void Update(PBMapPlayerData mapPlayerData)
 {
     CurPos = new MapCardPos(mapPlayerData.PlayerPosX, mapPlayerData.PlayerPosY);
     if (m_Data.Id == MapMgr.Instance.MyMapPlayer.Data.Id && m_Data.HP > mapPlayerData.PlayerData.Hp && mapPlayerData.PlayerData.Food == 0)
     {
         //食物没有了,扣血
         Messenger.Broadcast(MessageId.MAP_PLAYER_NO_FOOD_DAMAGE);
     }
     m_InstanceId = mapPlayerData.InstanceId;
     m_Data.Update(mapPlayerData);
     if (m_Data.HP <= 0)
     {
         Messenger.BroadcastAsync <ulong>(MessageId.MAP_PLAYER_DEAD, m_Data.Id);
     }
 }
Exemple #12
0
    public override void Handle(object sender, IMessage packet)
    {
        base.Handle(sender, packet);
        GCMapPlayerMove data = packet as GCMapPlayerMove;

        //处理完数据和逻辑后,发送消息通知其他模块,绝对不可以直接操作UI等Unity主线程的东西!
        if (data.Result == 0)
        {
            Messenger.BroadcastAsync <GCMapPlayerMove>(MessageId.MAP_PLAYER_MOVE, data);
        }
        else
        {
            Debug.LogError("移动失败");
        }
    }
Exemple #13
0
        public override void OnMessage(USocket us, ByteBuf bb)
        {
            if (onMessage != null)
            {
                onMessage();
            }
            int len = bb.ReadShort();

            if (bb.ReadableBytes() != len)
            {
                Log.Error("数据长度不对!");
                return;
            }
            MessageID msgId = (MessageID)bb.ReadShort();

            byte[]   data    = bb.ReadBytes(len - 2);
            IMessage msgData = null;

            switch (msgId)
            {
            case MessageID.ReqUserLogin:
            case MessageID.ReqUserRegister:
                Log.Error("收到请求消息非法!");
                return;

            case MessageID.ResUserLogin:
                ResUserLoginMessage userLogin = ResUserLoginMessage.Parser.ParseFrom(data);
                msgData = userLogin;
                break;

            case MessageID.ResUserRegister:
                break;

            default:
                break;
            }
            if (msgData == null)
            {
                return;
            }
            Messenger.BroadcastAsync <IMessage>(msgId.ToString(), msgData);
        }
Exemple #14
0
 void OnClose()
 {
     netState = NetState.Closed;
     Messenger.BroadcastAsync(MessageID.NetworkDisconnect.ToString());
 }
Exemple #15
0
 void OnOpen()
 {
     netState = NetState.Connected;
     Messenger.BroadcastAsync(MessageId.NetworkConnect, channelName);
 }
Exemple #16
0
 public override void Start()
 {
     Messenger.BroadcastAsync(MSG_DEFINE.MSG_SCENE_LOAD_PRE);
     StartCoroutine();
 }
Exemple #17
0
 public void BroadcastAsync(uint eventType)
 {
     Messenger.BroadcastAsync(eventType);
 }
Exemple #18
0
 public void BroadcastAsync(uint eventType, Object para1)
 {
     Messenger.BroadcastAsync <Object>(eventType, para1);
 }
Exemple #19
0
 public void BroadcastAsync(uint eventType, System.Object para1, System.Object para2, System.Object para3)
 {
     Messenger.BroadcastAsync <Object, Object, Object>(eventType, para1, para2, para3);
 }
 public void BroadcastAsync(string eventType, System.Object para1, System.Object para2)
 {
     Messenger.BroadcastAsync <Object, Object>(eventType, para1, para2);
 }
 public void BroadcastAsync(string eventType)
 {
     Messenger.BroadcastAsync(eventType);
 }
Exemple #22
0
 void OnOpen()
 {
     netState = NetState.Connected;
     Messenger.BroadcastAsync(MessageID.NetworkConnect.ToString());
 }
 public void Connect(string ip, int port)
 {
     netState = NetState.Connected;
     Messenger.BroadcastAsync(MessageId.NetworkConnect, name);
     excuteThread.Start();
 }