Example #1
0
        private void Match(Message msg)
        {
            if (msg.NotifyInfo.RpcParams != "0")
            {
                var seq = msg.NotifyInfo.Sequence;
                if (seq > 0)
                {
                    Boolean retParam = MessagePackDecoder <Boolean>(msg.NotifyInfo.RpcParams);
                    if (retParam)
                    {
                        DebugLogger.Debug("匹配成功");
                        LoginRequist.ucl.rpcCall("combat.getOtherId", null, (byte[] data) =>
                        {
                            var massage = BaseFramework.Network.UserClient.ProtobufDecoder(data);

                            if (massage.Response.RpcRsp != null)
                            {
                                var result = UserClient.MessagePackDecoder <object>(massage.Response.RpcRsp);
                                //TODO:显示两个对战玩家信息(uid)
                                GameManager.gm.setEnemyText(result.ToString());
                                GameManager.gm.setUserText(userText);
                                DebugLogger.Debug("OtherID callback: " + result);
                            }
                        });

                        SceneManager.LoadScene("TowerScene");
                    }
                    else
                    {
                        DebugLogger.Debug("匹配失败");
                    }

                    Debug.Log("server callback:isMatchSuccess");
                    // clientReceiveSeq = seq;
                }
            }
        }
Example #2
0
        void StartNotify()
        {
            if (!matchFlag)
            {
                NotificationButtonText.text = "取消(10s返回)";
                matchFlag = true;
                LoginRequist.ucl.rpcCall("combat.start_match", null, (byte[] data) =>
                {
                    var msg = BaseFramework.Network.UserClient.ProtobufDecoder(data);

                    if (msg.Response.RpcRsp != null)
                    {
                        var result = UserClient.MessagePackDecoder <object>(msg.Response.RpcRsp);

                        DebugLogger.Debug("start_match callback: " + result);
                        //NotificationMsg.text = result.ToString();
                    }
                });
            }
            else
            {
                NotificationButtonText.text = "新的匹配";
                matchFlag = false;
                LoginRequist.ucl.rpcCall("combat.cancel_match", null, (byte[] data) =>
                {
                    var msg = UserClient.ProtobufDecoder(data);

                    if (msg.Response.RpcRsp != null)
                    {
                        object result = UserClient.MessagePackDecoder <object>(msg.Response.RpcRsp);
                        //TODO:UI按钮改回“新的匹配”
                        DebugLogger.Debug("cancel_match callback: " + result);
                        //NotificationMsg.text = result.ToString();
                    }
                });
            }
        }