Exemple #1
0
        public void startLoginProcess()
        {
            //DebugLogger.Debug("start login process " + LoginInputAccount.text, Color.blue);
            ucl = NetClient.GetInstance("logic");

            /*
             * if (ucl.Login(ServerIP, ServerPort, LoginInputAccount.text))
             * {
             *  switchScene("ServerScene");
             *  //LoginRequist.ucl.rpcCall("notifytester.rpc_start_notify", "1", null);
             * }
             * else
             * {
             *  DebugLogger.Debug("Login Error");
             * }
             */

            if (ucl.Login(ServerIP, ServerPort, GameObject.FindGameObjectWithTag("UserName").GetComponent <InputField>().text))
            {
                //switchScene("ServerScene");
                GameManager.Instance.StartMatchmaking();
            }
            else
            {
                DebugLogger.Debug("Login Error");
            }
        }
Exemple #2
0
        // 指定连接类型,用于创建战斗类
        public static UserClient GetInstance(string ctype)
        {
            var ncl = new UserClient(NetConfigDict.config[ctype], ++sClientId, Instance);

            sClients[sClientId] = ncl;
            sClientId++;
            return(ncl);
        }
 void startLoginProcess()
 {
     DebugLogger.Debug("start login process " + LoginInputAccount.text, Color.blue);
     ucl = NetClient.GetInstance("logic");
     if (ucl.Login(ServerIP, ServerPort, LoginInputAccount.text))
     {
         switchScene("GameNode");
     }
     else
     {
         DebugLogger.Debug("Login Error");
     }
 }
Exemple #4
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;
                }
            }
        }
Exemple #5
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();
                    }
                });
            }
        }