Ejemplo n.º 1
0
        public override void OnEnter()
        {
            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            matchId.Value        = match.MatchId;
            playerCount          = match.PlayerCount;
            hasVacantSlot        = match.HasVacantSlot;
            isMyTurn             = match.IsMyTurn;
            currentParticipantId = match.CurrentParticipantId;
            selfParticipantId    = match.SelfParticipantId;


            if (match.PlayerCount > 0)
            {
                participantIds.Resize(match.PlayerCount);

                Participant[] participants = match.Participants;
                for (int i = 0; i < match.PlayerCount; i++)
                {
                    participantIds.Set(i, participants[i].ParticipantId);
                }
            }
            Finish();
        }
Ejemplo n.º 2
0
        void RematchCallback(bool isRematchSuccess, TurnBasedMatch match)
        {
            if (isRematchSuccess)
            {
                TurnBasedMatchObject temp = new TurnBasedMatchObject();
                temp.Match           = match;
                matchObjectOut.Value = temp;

                if (match.Data != null)
                {
                    data.Value = Convert.ToBase64String(match.Data);
                }
                else
                {
                    data.Value = null;
                }


                isSuccess.Value = true;
                Fsm.Event(eventTarget, isSuccessEvent);
            }
            else
            {
                isSuccess.Value = false;
                Fsm.Event(eventTarget, isNotSuccessEvent);
            }
        }
Ejemplo n.º 3
0
        public override void OnEnter()
        {
            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            MatchOutcome outcome = null;

            switch (param)
            {
            case ResultParam.ParticipantResult:
                outcome = CreateMatchOutcomeWithResults();
                break;

            case ResultParam.ParticipantPlacement:
                outcome = CreateMatchOutcomeWithPlacements();
                break;

            default:
                outcome = CreateMatchOutcomeWithResultandPlacement();
                break;
            }
            if (outcome != null)
            {
                byte[] binaryData = Convert.FromBase64String(data.Value);
                GameServices.TurnBased.Finish(match, binaryData, outcome, OutComeCallBack);
                return;
            }
        }
Ejemplo n.º 4
0
        public override void OnEnter()
        {
            GameServices.TurnBased.GetAllMatches((allMatches) =>
            {
                if (allMatches != null)
                {
                    matchCount.Value = allMatches.Length;

                    matches.Resize(matchCount.Value);

                    for (int i = 0; i < matchCount.Value; i++)
                    {
                        TurnBasedMatchObject matchObject = new TurnBasedMatchObject();

                        matchObject.Match = allMatches[i];

                        matches.Set(i, matchObject);
                    }
                    Fsm.Event(eventTarget, isSuccessEvent);
                    Finish();
                }
                else
                {
                    Fsm.Event(eventTarget, isNotSuccessEvent);
                    Finish();
                }
            });
        }
Ejemplo n.º 5
0
        public override void OnEnter()
        {
            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            GameServices.TurnBased.AcknowledgeFinished(match, AcknowledgeFinishedCallback);
        }
Ejemplo n.º 6
0
        public override void OnEnter()
        {
            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            GameServices.TurnBased.Rematch(match, RematchCallback);
        }
Ejemplo n.º 7
0
        void OnMatchArrives(TurnBasedMatch match, bool shouldAutoLaunchIn, bool playerWantsToQuitIn)
        {
            TurnBasedMatchObject temp = new TurnBasedMatchObject();

            temp.Match        = match;
            matchObject.Value = temp;

            shouldAutoLaunch.Value  = shouldAutoLaunchIn;
            playerWantsToQuit.Value = playerWantsToQuitIn;
            Fsm.Event(eventTarget, onMatchArrivesEvent);
        }
Ejemplo n.º 8
0
        public override void OnEnter()
        {
            DemoUtils_TurnBasedManager manager = turnBaseManager.Value.GetComponent <DemoUtils_TurnBasedManager>();

            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            manager.OnMatchReceived(match, shouldAutoLaunch.Value, playerWantsToQuit.Value);

            Finish();
        }
        public override void OnEnter()
        {
            if (string.IsNullOrEmpty(nextParticipantId.Value))
            {
                nextParticipantId.Value = null;
            }

            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            GameServices.TurnBased.LeaveMatchInTurn(match, nextParticipantId.Value, LeaveMatchInTurnCallBack);
        }
Ejemplo n.º 10
0
        public override void OnEnter()
        {
            if (string.IsNullOrEmpty(nextParticipantId.Value))
            {
                nextParticipantId.Value = null;
            }

            TurnBasedMatchObject temp = (TurnBasedMatchObject)matchObject.Value;

            TurnBasedMatch match = temp.Match;

            byte[] binaryData = Convert.FromBase64String(data.Value);

            GameServices.TurnBased.TakeTurn(match, binaryData, nextParticipantId.Value, TakeTurnCallBack);
        }
        void OnCreateQuickMatch(bool isCreatedSuccess, TurnBasedMatch match)
        {
            if (isCreatedSuccess)
            {
                TurnBasedMatchObject temp = new TurnBasedMatchObject();

                temp.Match = match;

                matchObject.Value = temp;

                isSuccess.Value = true;
                Fsm.Event(eventTarget, isSuccessEvent);
            }
            else
            {
                isSuccess.Value = false;
                Fsm.Event(eventTarget, isNotSuccessEvent);
            }
        }
Ejemplo n.º 12
0
        public override void OnEnter()
        {
            DemoUtils_TurnBasedManager manager      = turnBaseManager.Value.GetComponent <DemoUtils_TurnBasedManager>();
            TurnBasedMatch             currentMatch = manager.CurrentMatch;

            if (currentMatch == null)
            {
                alertString.Value = "Please create a match first.";
                Fsm.Event(eventTarget, isNotSuccessEvent);
            }
            else
            {
                TurnBasedMatchObject temp = new TurnBasedMatchObject();

                temp.Match = currentMatch;

                matchObject.Value = temp;

                alertString.Value = manager.GetMatchDisplayString(currentMatch);

                currentMatchId.Value = currentMatch.MatchId;

                if (manager.SelectedParticipant != null)
                {
                    nextParticipantId.Value = manager.SelectedParticipant.ParticipantId;
                }
                else
                {
                    nextParticipantId.Value = null;
                }
                selectedParticipantLeftMatch.Value = manager.SelectedParticipantLeftMatch;
                isMyTurn.Value   = manager.IsMyTurn;
                canRematch.Value = manager.CanRematch;
                Fsm.Event(eventTarget, isSuccessEvent);
            }
        }