예제 #1
0
 public EzGetGatheringResult(
     GetGatheringResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzGathering(result.item);
     }
 }
 public EzCancelMatchmakingResult(
     CancelMatchmakingResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzGathering(result.item);
     }
 }
예제 #3
0
 public EzDoMatchmakingResult(
     DoMatchmakingResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzGathering(result.item);
     }
     MatchmakingContextToken = result.matchmakingContextToken;
 }
        /// <summary>
        /// 既存のギャザリングに参加する
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public IEnumerator SimpleMatchmakingJoinGathering(
            UnityAction <AsyncResult <EzDoMatchmakingResult> > callback
            )
        {
            Validate();

            var request = Gs2Util.LoadGlobalGameObject <MatchmakingRequest>("MatchmakingRequest");

            AsyncResult <EzDoMatchmakingResult> result = null;
            string contextToken = null;

            while (true)
            {
                yield return(gs2Client.client.Matchmaking.DoMatchmaking(
                                 r => { result = r; },
                                 request.gameSession,
                                 gs2MatchmakingSetting.matchmakingNamespaceName,
                                 new EzPlayer
                {
                    RoleName = "default"
                },
                                 contextToken
                                 ));

                if (result.Error != null)
                {
                    gs2MatchmakingSetting.onError.Invoke(
                        result.Error
                        );

                    callback.Invoke(result);
                    yield break;
                }

                if (result.Result.Item != null)
                {
                    _gathering = result.Result.Item;
                    callback.Invoke(result);

                    if (_complete)
                    {
                        gs2MatchmakingSetting.onMatchmakingComplete.Invoke(_gathering, _joinedPlayerIds);
                    }

                    yield break;
                }

                contextToken = result.Result.MatchmakingContextToken;
            }
        }
예제 #5
0
        /// <summary>
        /// 誰でもいいので参加者を募集するギャザリングを新規作成
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="capacity"></param>
        /// <returns></returns>
        public IEnumerator SimpleMatchmakingCreateGathering(
            UnityAction <AsyncResult <EzCreateGatheringResult> > callback,
            int capacity
            )
        {
            Validate();

            var request = Gs2Util.LoadGlobalGameObject <MatchmakingRequest>("MatchmakingRequest");

            AsyncResult <EzCreateGatheringResult> result = null;

            yield return(gs2Client.client.Matchmaking.CreateGathering(
                             r => { result = r; },
                             request.gameSession,
                             gs2MatchmakingSetting.matchmakingNamespaceName,
                             new EzPlayer
            {
                RoleName = "default"
            },
                             new List <EzCapacityOfRole>
            {
                new EzCapacityOfRole
                {
                    RoleName = "default",
                    Capacity = capacity
                },
            },
                             new List <EzAttributeRange>(),
                             new List <string>(),
                             null
                             ));

            if (result.Error != null)
            {
                gs2MatchmakingSetting.onError.Invoke(
                    result.Error
                    );
                callback.Invoke(result);
                yield break;
            }

            _joinedPlayerIds.Clear();
            _gathering = result.Result.Item;
            _joinedPlayerIds.Add(request.gameSession.AccessToken.UserId);

            gs2MatchmakingSetting.onUpdateJoinedPlayerIds.Invoke(_gathering, _joinedPlayerIds);

            callback.Invoke(result);
        }