public virtual void Btn_MatchPlayer()
    {
        AppendTxt("开始匹配玩家\r\n");
        MatchPlayerInfoPara playerInfo = new MatchPlayerInfoPara()
        {
            CustomPlayerStatus = 1,
            Name            = "p" + UnityEngine.Random.Range(1, 100),
            MatchAttributes = new List <MatchAttribute>()
            {
                new MatchAttribute()
                {
                    Name = "1", Value = 2
                }
            },
        };
        MatchPlayersPara matchPlayerPara = new MatchPlayersPara()
        {
            //MatchCode = "match-0bjyargr", //2v2
            MatchCode      = "match-82hzbk07", // 1v1
            PlayerInfoPara = playerInfo,
        };


        paintRoom.MatchPlayers(matchPlayerPara, eve =>
        {
            if (eve.Code != 0)
            {
                AppendTxt("player匹配失败" + "\r\n");
            }
            else
            {
                AppendTxt("player匹配中..." + "\r\n");
            }
        });
    }
Пример #2
0
        public void MatchPlayers(MatchPlayersPara para, Action <ResponseEvent> callback)
        {
            if (Room.OnMatch != null)
            {
                Sdk.MatchPlayers(para, eve => {
                    if (eve.Data != null)
                    {
                        var rsp = new MatchPlayersRsp();
                        rsp.MergeFrom((ByteString)eve.Data);
                        eve.Data = rsp;
                    }
                    callback?.Invoke(eve);
                });
                return;
            }

            BroadcastOnce.Push(BroadcastOnce.PlayerComplex, callback);

            void Eve(ResponseEvent e)
            {
                if (e.Code == (int)QAppProtoErrCode.EcOk)
                {
                    return;
                }
                e.Data = null;
                BroadcastOnce.Once(BroadcastOnce.PlayerComplex, e);
            }

            Sdk.MatchPlayers(para, Eve);
        }