Пример #1
0
        private MatchOutcome ResolveActions(SinglePlayerInputs _p1Inputs, SinglePlayerInputs _p2Inputs, GameState _currentState)
        {
            //1. Update individual actions and positions
            MatchOutcome p1_update_outcome = _currentState.P1_CState.UpdateCharacterState();

            if (p1_update_outcome.IsEnd())
            {
                return(p1_update_outcome);
            }
            MatchOutcome p2_update_outcome = _currentState.P2_CState.UpdateCharacterState();

            if (p2_update_outcome.IsEnd())
            {
                return(p2_update_outcome);
            }

            //2. Resolve hitbox interaction
            MatchOutcome hitbox_outcome = ResolveHitboxInteractions(_p1Inputs, _p2Inputs, _currentState);

            if (hitbox_outcome.IsEnd())
            {
                return(hitbox_outcome);
            }

            //3. Resolve Positions
            ResolvePositions(_currentState);

            //4. Check timer
            if (_currentState.RemainingTime < 0)
            {
                return(new MatchOutcome(true, true, GameplayEnums.Outcome.TimeOut));
            }

            return(new MatchOutcome());
        }
Пример #2
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;
            }
        }
Пример #3
0
        public void Finish(string matchId, byte[] data, MatchOutcome outcome, Action <bool> callback)
        {
            Logger.d(string.Format("AndroidTbmpClient.Finish matchId={0}, data={1} outcome={2}", matchId, (data != null) ? (data.Length + " bytes") : "(null)", outcome));
            Logger.d("Preparing list of participant results as Android ArrayList.");
            AndroidJavaObject androidJavaObject = new AndroidJavaObject("java.util.ArrayList", new object[0]);

            if (outcome != null)
            {
                foreach (string current in outcome.ParticipantIds)
                {
                    Logger.d("Converting participant result to Android object: " + current);
                    AndroidJavaObject androidJavaObject2 = new AndroidJavaObject("com.google.android.gms.games.multiplayer.ParticipantResult", new object[]
                    {
                        current,
                        JavaUtil.GetAndroidParticipantResult(outcome.GetResultFor(current)),
                        outcome.GetPlacementFor(current)
                    });
                    Logger.d("Adding participant result to Android ArrayList.");
                    androidJavaObject.Call <bool>("add", new object[]
                    {
                        androidJavaObject2
                    });
                    androidJavaObject2.Dispose();
                }
            }
            this.TbmpApiCall("tbmp finish w/ outcome", "finishMatch", callback, null, new object[]
            {
                matchId,
                data,
                androidJavaObject
            });
        }
Пример #4
0
 private void HandleOutcome(MatchOutcome _outcome)
 {
     GameManager.Instance.SoundManager.LowerVolume();
     GameManager.Instance.SoundManager.PlayRoundEndVoice(_outcome.Outcome);
     if (_outcome.P1_Scores)
     {
         Match.P1_Score++;
     }
     if (_outcome.P2_Scores)
     {
         Match.P2_Score++;
     }
     Match.Outcomes.Add(_outcome);
     if (_outcome.Outcome == GameplayEnums.Outcome.TimeOut || _outcome.Outcome == GameplayEnums.Outcome.Trade)
     {
         if (Match.P1_Score >= GameplayConstants.ROUNDS_TO_WIN)
         {
             Match.P1_Score = GameplayConstants.ROUNDS_TO_WIN - 1;
         }
         if (Match.P2_Score >= GameplayConstants.ROUNDS_TO_WIN)
         {
             Match.P2_Score = GameplayConstants.ROUNDS_TO_WIN - 1;
         }
     }
     if (Match.P1_Score >= GameplayConstants.ROUNDS_TO_WIN || Match.P2_Score >= GameplayConstants.ROUNDS_TO_WIN)
     {
         Match.GameOver = true;
         m_setData.AddResult(_outcome);
     }
 }
Пример #5
0
    public void FinishMatch()
    {
        // define the match's outcome
        MatchOutcome outcome = new MatchOutcome();

        outcome.SetParticipantResult(mMatch.SelfParticipantId, MatchOutcome.ParticipantResult.Win);
        if (mMatch.SelfParticipantId == mMatchData.Player1)
        {
            outcome.SetParticipantResult(mMatchData.Player2, MatchOutcome.ParticipantResult.Loss);
        }
        else
        {
            outcome.SetParticipantResult(mMatchData.Player1, MatchOutcome.ParticipantResult.Loss);
        }
        mMatchData.PlayerWon = mMatch.SelfParticipantId;

        PlayGamesPlatform.Instance.TurnBased.Finish(mMatch.MatchId, mMatchData.ToBytes(),
                                                    outcome, (bool success) =>
        {
            if (success)
            {
                mFinalMessage = "YOU WON!!";
            }
            else
            {
                mFinalMessage = "Error winning";
            }
        });
        Debug.Log(mFinalMessage);
    }
Пример #6
0
        public void Finish(string matchId, byte[] data, MatchOutcome outcome, Action <bool> callback)
        {
            Logger.d(string.Format("iOSTbmpClient.Finish matchId={0}, outcome={1}", matchId, outcome.ToString()));
            // We probably need to convert our match outcome into something we can read in


            var           resultsOutput   = new List <Dictionary <string, object> >();
            List <string> allParticipants = outcome.ParticipantIds;
            Dictionary <string, object> nextResult;

            foreach (string participantID in allParticipants)
            {
                Logger.d("Getting results for " + participantID);
                nextResult = new Dictionary <string, object>();
                // Maybe don't add them if their result is unset? Check with Bruno on this one
                if (outcome.GetResultFor(participantID) != MatchOutcome.ParticipantResult.Unset)
                {
                    nextResult["participantId"] = participantID;
                    nextResult["placing"]       = outcome.GetPlacementFor(participantID);
                    nextResult["result"]        = convertParticipantResultToiOSInt(outcome.GetResultFor(participantID));
                }
                resultsOutput.Add(nextResult);
            }
            string resultsAsJson = Json.Serialize(resultsOutput);

            Logger.d("JSonified results are " + resultsAsJson);

            sCallbackSuccessId++;
            sMatchSuccessCallbacks.Add(sCallbackSuccessId, callback);
            GPGSTBMPFinishMatch(matchId, data, data.Length, resultsAsJson, sCallbackSuccessId, TbmpMatchSuccessCallback);
        }
Пример #7
0
        private int CalculateAllMatchOutComes(MatchOutcome matchOutcomeToTrack)
        {
            int outcome = 0;

            foreach (var game in this.teamEvents.Games)
            {
                int gameGoalDifference = 0;
                foreach (var goal in game.Protocol.Goals)
                {
                    gameGoalDifference += (goal.TeamId == this.teamId) ? 1 : -1;
                }
                if (gameGoalDifference > 0 && matchOutcomeToTrack.Equals(MatchOutcome.Win))
                {
                    outcome++;
                }
                else if (gameGoalDifference < 0 && matchOutcomeToTrack.Equals(MatchOutcome.Loss))
                {
                    outcome++;
                }
                else if (gameGoalDifference == 0 && matchOutcomeToTrack.Equals(MatchOutcome.Draw))
                {
                    outcome++;
                }
            }
            return(outcome);
        }
Пример #8
0
        public void Finish(string matchId, byte[] data, MatchOutcome outcome, Action <bool> callback)
        {
            Logger.d(string.Format("AndroidTbmpClient.Finish matchId={0}, data={1} outcome={2}",
                                   matchId, data == null ? "(null)" : data.Length + " bytes", outcome));

            Logger.d("Preparing list of participant results as Android ArrayList.");
            AndroidJavaObject participantResults = new AndroidJavaObject("java.util.ArrayList");

            if (outcome != null)
            {
                foreach (string pid in outcome.ParticipantIds)
                {
                    Logger.d("Converting participant result to Android object: " + pid);
                    AndroidJavaObject thisParticipantResult = new AndroidJavaObject(
                        JavaConsts.ParticipantResultClass, pid,
                        JavaUtil.GetAndroidParticipantResult(outcome.GetResultFor(pid)),
                        outcome.GetPlacementFor(pid));

                    // (yes, the return type of ArrayList.add is bool, strangely)
                    Logger.d("Adding participant result to Android ArrayList.");
                    participantResults.Call <bool>("add", thisParticipantResult);
                    thisParticipantResult.Dispose();
                }
            }

            TbmpApiCall("tbmp finish w/ outcome", "finishMatch", callback, null,
                        matchId, data, participantResults);
        }
Пример #9
0
        void GameplayStateUpdate(SinglePlayerInputs _p1Inputs, SinglePlayerInputs _p2Inputs, bool skipRender = false)
        {
            //1.1 Check for pause? todo
            if (CurrentSplashState.CurrentState == SplashState.State.GameOver)
            {
                //check if any button is pressed to start a new game
                if (_p1Inputs.A || _p1Inputs.B || _p1Inputs.C || _p1Inputs.Start ||
                    _p2Inputs.A || _p2Inputs.B || _p2Inputs.C || _p2Inputs.Start)
                {
                    ApplicationStateManager.GetInstance().SetCharacterSelectScreen(m_setData);
                }
            }
            else if (UpdateSplashScreen())
            {
            }
            else if (m_previousState.RemainingHitstop > 0)
            {
                m_previousState.RemainingHitstop--;
            }
            else
            {
                //2. Sees if the inputs can be applied to current action
                GameState currentState = UpdateGameStateWithInputs(_p1Inputs, _p2Inputs, m_previousState);
                m_p1LastInputs = _p1Inputs;
                m_p2LastInputs = _p2Inputs;

                //3. Resolves actions
                MatchOutcome outcome = ResolveActions(_p1Inputs, _p2Inputs, currentState);



                //4. Checks if the match is over
                if (outcome.IsEnd())
                {
                    //Extra render on game end?
                    GameplayRendererObject.RenderScene(m_previousState, Match, CurrentSplashState);
                    HandleOutcome(outcome);
                    CurrentSplashState.CurrentState    = SplashState.State.RoundOver_ShowResult;
                    CurrentSplashState.FramesRemaining = GameplayConstants.FRAMES_END_ROUND_SPLASH;


                    //camera tests
                    //isPanning = true;
                    isRotating = true;
                }
                --currentState.RemainingTime;
                m_previousStates.Add(currentState);
            }
            if (!skipRender)
            {
                //5. Render Scene
                GameplayRendererObject.RenderScene(m_previousState, Match, CurrentSplashState);

                //6. Camera Tests
                CameraMoveTest(Match);
            }
        }
Пример #10
0
        public void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome, Action <bool> callback)
        {
            if (match == null || outcome == null)
            {
                throw new ArgumentNullException();
            }

            PlayGamesPlatform.Instance.TurnBased.Finish(match.GPGS_TurnBasedMatch, data, outcome.ToGPGSMatchOutcome(), callback);
        }
Пример #11
0
        MatchOutcome CreateMatchOutcomeWithPlacements()
        {
            MatchOutcome buffer = new MatchOutcome();

            for (int i = 0; i < participantIds.Length; i++)
            {
                buffer.SetParticipantPlacement((string)participantIds.Values[i], (uint)placements.Values[i]);
            }
            return(buffer);
        }
Пример #12
0
        MatchOutcome CreateMatchOutcomeWithResults()
        {
            MatchOutcome buffer = new MatchOutcome();

            for (int i = 0; i < participantIds.Length; i++)
            {
                buffer.SetParticipantResult((string)participantIds.Values[i], (MatchOutcome.ParticipantResult)results.Values[i]);
            }
            return(buffer);
        }
Пример #13
0
        /// <summary>
        /// Samples from the model.
        /// </summary>
        /// <param name="truth">The truth.</param>
        /// <param name="players">The players.</param>
        /// <param name="performanceVariance">The performance variance.</param>
        /// <param name="drawMargin">The draw margin.</param>
        /// <returns>
        /// The <see cref="Game" />.
        /// </returns>
        public static Game Sample(Marginals truth, IList <string> players, double performanceVariance, double drawMargin)
        {
            double perf1 = new Gaussian(truth.Skills[players[0]].GetMean(), performanceVariance).Sample();
            double perf2 = new Gaussian(truth.Skills[players[1]].GetMean(), performanceVariance).Sample();

            double       diff    = perf1 - perf2;
            MatchOutcome outcome = diff < drawMargin ? MatchOutcome.Draw : (diff > 0 ? MatchOutcome.Player1Win : MatchOutcome.Player2Win);

            return(TwoPlayerGame.CreateGame(Guid.NewGuid().ToString(), players[0], players[1], outcome));
        }
Пример #14
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = base.GetHashCode();
         hashCode = (hashCode * 397) ^ MatchOutcome.GetHashCode();
         hashCode = (hashCode * 397) ^ ObjectiveScore.GetHashCode();
         return(hashCode);
     }
 }
Пример #15
0
        private bool isZooming      = false;        // Is the camera zooming?

        private void CameraMoveTest(MatchState _matchState)
        {
            if (_matchState.Outcomes.Count <= 0)
            {
                return;
            }
            MatchOutcome lastOutcome = _matchState.Outcomes[_matchState.Outcomes.Count - 1];

            if (lastOutcome.Outcome != GameplayEnums.Outcome.Shimmy && lastOutcome.Outcome != GameplayEnums.Outcome.WhiffPunish)
            {
                return;
            }
            float rotationSpeed = 0f;

            if (lastOutcome.P1_Scores)
            {
                rotationSpeed += 20f;
            }
            if (lastOutcome.P2_Scores)
            {
                rotationSpeed -= 20f;
            }
            Camera mc = Camera.main;

            // Rotate camera along X and Y axis
            if (isRotating)
            {
                mc.transform.RotateAround(Vector3.zero, Vector3.up, rotationSpeed * Time.deltaTime);
                Camera.main.fieldOfView -= 0.01f;

                //Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);

                //mc.transform.RotateAround(mc.transform.position, mc.transform.right, -pos.y * turnSpeed);
                //mc.transform.RotateAround(mc.transform.position, Vector3.up, pos.x * turnSpeed);
            }

            // Move the camera on it's XY plane
            if (isPanning)
            {
                Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);

                Vector3 move = new Vector3(pos.x * panSpeed, pos.y * panSpeed, 0);
                mc.transform.Translate(move, Space.Self);
            }

            // Move the camera linearly along Z axis
            if (isZooming)
            {
                Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - mouseOrigin);

                Vector3 move = pos.y * zoomSpeed * mc.transform.forward;
                mc.transform.Translate(move, Space.World);
            }
        }
Пример #16
0
 public void AddResult(MatchOutcome _outcome)
 {
     MatchResult.Result res;
     if (_outcome.P1_Scores)
     {
         res = MatchResult.Result.P1_Win;
     }
     else
     {
         res = MatchResult.Result.P2_Win;
     }
     m_results.Add(new Match.MatchResult(res));
 }
        [InlineData(new [] { "a" }, 0, MatchOutcome.Partial, 0)]                        //not enough
        public void TestOptionWithArgumentsMatches(string[] input, int startIdx, MatchOutcome expMatchLength, int expNumMatchTokens)
        {
            ArgumentToken arg1 = new ArgumentToken <int> .Builder().Name("arg1").Parser(int.TryParse).Build();

            var token = new OptionWithArgumentToken.Builder()
                        .Name("option", "alt1", "alt2")
                        .WithArgument(arg1)
                        .Build();

            TokenMatchResult matchResult = token.Matches(input, startIdx);

            Assert.True(expMatchLength == matchResult.MatchOutcome, $"Failed in case \"{input}\"");
            Assert.Equal(expNumMatchTokens, matchResult.TokensMatched);
        }
Пример #18
0
        public void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome, Action <bool> callback)
        {
            Util.NullArgumentTest(match);
            Util.NullArgumentTest(data);
            Util.NullArgumentTest(outcome);

            // Grab the GKTurnBasedMatch.
            var gkMatch = match.GC_TurnBasedMatch;

            // Set outcome for all participants.
            var participants = gkMatch.Participants.ToArray(
                ptr => InteropObjectFactory <GKTurnBasedParticipant> .FromPointer(ptr, p => new GKTurnBasedParticipant(p)));

            foreach (var p in participants)
            {
                var gkPlayer = p.Player;
                if (gkPlayer != null)
                {
                    p.MatchOutcome = outcome.ToGKTurnBasedMatchOutcome(gkPlayer.PlayerID);
                }
                else
                {
                    p.MatchOutcome = new GKTBMOutcome()
                    {
                        outcome = GKTBMOutcome.Outcome.Quit
                    }
                };                                                                              // disconnected player should have outcome as Quit.
            }

            // End match in turn.
            gkMatch.EndMatchInTurn(
                data,
                error =>
            {
                if (error != null)
                {
                    Debug.Log("Failed to finish match with error " + error.LocalizedDescription);
                }

                if (callback != null)
                {
                    callback(error == null);
                }
            });
        }
Пример #19
0
        private void EndGame(MatchOutcome.ParticipantResult localPlayerResult, MatchOutcome.ParticipantResult opponentResult,
                             int x, int y, Action <TicTacToeGameModel.Mark> successCallback)
        {
            if (model == null)
            {
                return;
            }

            MatchOutcome outcome = new MatchOutcome();

            outcome.SetParticipantResult(model.Match.SelfParticipantId, localPlayerResult);
            outcome.SetParticipantResult(model.Opponent.ParticipantId, opponentResult);

            model.TransferDatas.IsGameOver  = true;
            model.TransferDatas.FinalResult = outcome;
            model.TransferDatas.CurrentTurn = GetOppositeMark(model.TransferDatas.CurrentTurn);
            model.TransferDatas.MoveCount++;
            CanMove = false;

            view.StartProgressUI("Ending game");
            GameServices.TurnBased.Finish(model.Match, model.TransferDatas.ToByteArray(), outcome,
                                          success =>
            {
                view.StopProgressUI("Ending game: " + GetResultMessage(success));

                if (!success)
                {
                    CanMove = true;
                    model.TransferDatas.CurrentTurn = GetOppositeMark(model.TransferDatas.CurrentTurn);
                    model.TransferDatas.IsGameOver  = false;
                    model.TransferDatas.FinalResult = null;
                    model.TransferDatas.MoveCount--;
                    model.TransferDatas.Board[x][y] = TicTacToeGameModel.TileState.Blank;
                }
                else
                {
                    view.EndGame(localPlayerResult);

                    if (successCallback != null)
                    {
                        successCallback(GetOppositeMark(model.TransferDatas.CurrentTurn));
                    }
                }
            });
        }
Пример #20
0
    void DoTbmpFinish()
    {
        if (mMatch == null)
        {
            mStatus = "No match is active.";
            return;
        }
        if (mMatch.TurnStatus != TurnBasedMatch.MatchTurnStatus.MyTurn)
        {
            mStatus = "Not my turn.";
            return;
        }

        // I win; every one else loses
        MatchOutcome outcome = new MatchOutcome();

        foreach (Participant p in mMatch.Participants)
        {
            if (p.ParticipantId.Equals(mMatch.SelfParticipantId))
            {
                outcome.SetParticipantResult(p.ParticipantId,
                                             MatchOutcome.ParticipantResult.Win, 1);
            }
            else
            {
                outcome.SetParticipantResult(p.ParticipantId,
                                             MatchOutcome.ParticipantResult.Loss, 2);
            }
        }

        SetStandBy("Finishing match...");
        PlayGamesPlatform.Instance.TurnBased.Finish(mMatch,
                                                    System.Text.ASCIIEncoding.Default.GetBytes("the end!"),
                                                    outcome, (bool success) => {
            EndStandBy();
            ShowEffect(success);
            mStatus = success ? "Successfully finished match." : "Failed to finish match.";
            if (success)
            {
                mMatch = null;
                mUi    = Ui.Tbmp;
            }
        });
    }
Пример #21
0
        public static String ToString(MatchOutcome data)
        {
            String friendlyString = "";

            switch (data)
            {
            case MatchOutcome.OneVsOneWinner:
                friendlyString = "Winner";
                break;

            case MatchOutcome.OneVsOneLooser:
                friendlyString = "Loser";
                break;

            default:
                break;
            }
            return(friendlyString);
        }
Пример #22
0
        public void Finish(TurnBasedMatch match, byte[] data, MatchOutcome outcome,
                           Action <bool> callback)
        {
            callback = Callbacks.AsOnGameThreadCallback(callback);
            FindEqualVersionMatch(match, callback, foundMatch =>
            {
                ParticipantResults results = foundMatch.Results();

                foreach (string participantId in outcome.ParticipantIds)
                {
                    Types.MatchResult matchResult =
                        ResultToMatchResult(outcome.GetResultFor(participantId));
                    uint placing = outcome.GetPlacementFor(participantId);

                    if (results.HasResultsForParticipant(participantId))
                    {
                        // If the match already has results for this participant, make sure that they're
                        // consistent with what's already there.
                        var existingResults = results.ResultsForParticipant(participantId);
                        var existingPlacing = results.PlacingForParticipant(participantId);

                        if (matchResult != existingResults || placing != existingPlacing)
                        {
                            Logger.e(string.Format("Attempted to override existing results for " +
                                                   "participant {0}: Placing {1}, Result {2}",
                                                   participantId, existingPlacing, existingResults));
                            callback(false);
                            return;
                        }
                    }
                    else
                    {
                        // Otherwise, get updated results and dispose of the old ones.
                        var oldResults = results;
                        results        = oldResults.WithResult(participantId, placing, matchResult);
                        oldResults.Dispose();
                    }
                }

                mTurnBasedManager.FinishMatchDuringMyTurn(foundMatch, data, results,
                                                          response => callback(response.RequestSucceeded()));
            });
        }
Пример #23
0
    void FinishMatch()
    {
        bool winnerIsMe = mMatchData.Winner == mMyMark;

        // define the match's outcome
        MatchOutcome outcome = new MatchOutcome();

        outcome.SetParticipantResult(mMatch.SelfParticipantId,
                                     winnerIsMe ? MatchOutcome.ParticipantResult.Win : MatchOutcome.ParticipantResult.Loss);
        outcome.SetParticipantResult(GetAdversaryParticipantId(),
                                     winnerIsMe ? MatchOutcome.ParticipantResult.Loss : MatchOutcome.ParticipantResult.Win);

        // finish the match
        SetStandBy("Sending...");
        PlayGamesPlatform.Instance.TurnBased.Finish(mMatch, mMatchData.ToBytes(),
                                                    outcome, (bool success) => {
            EndStandBy();
            mFinalMessage = success ? (winnerIsMe ? "YOU WON!" : "YOU LOST!") :
                            "ERROR finishing match.";
        });
    }
        public void Finish()
        {
            if (CurrentMatch == null)
            {
                NativeUI.Alert("Error", NullMatchMessage);
                return;
            }

            if (!IsMyTurn)
            {
                NativeUI.Alert("Warning", "Not your turn.");
                return;
            }

            if (CurrentMatchData == null)
            {
                NativeUI.Alert("Error", "Couldn't find any match data.");
                return;
            }

            MatchOutcome outcome = new MatchOutcome();

            outcome.SetParticipantResult(CurrentMatch.SelfParticipantId, MatchOutcome.ParticipantResult.Won);
            foreach (var id in CurrentOpponents.Select(p => p.ParticipantId))
            {
                outcome.SetParticipantResult(id, MatchOutcome.ParticipantResult.Lost);
            }

            CurrentMatchData.WinnerName = CurrentMatch.Self.DisplayName;
            var callback = GetAlertCallbackAction("Finished the match successfully.", "Failed to finish the match.");

            callback += success =>
            {
                if (success)
                {
                    canTakeTurn = false;
                }
            };
            GameServices.TurnBased.Finish(CurrentMatch, CurrentMatchData.ToByteArray(), outcome, callback);
        }
Пример #25
0
        public TokenMatchResult(ICommandToken token, string matchedTokensText, string fullMatchText, MatchOutcome matchOutcome, int charsMatched, int tokensMatched)
        {
            if (matchedTokensText == null)
            {
                throw new ArgumentNullException(nameof(matchedTokensText));
            }
            if (fullMatchText == null)
            {
                throw new ArgumentNullException(nameof(fullMatchText));
            }
            if (charsMatched < 0 || charsMatched > matchedTokensText.Length)
            {
                throw new ArgumentOutOfRangeException($"{nameof(charsMatched)} should be <= {nameof(matchedTokensText)}.Length");
            }
            ArgumentValues = new ValueBag <ArgumentToken>();

            Token             = token;
            MatchedTokensText = matchedTokensText;
            FullMatchText     = fullMatchText;
            MatchOutcome      = matchOutcome;
            CharsMatched      = charsMatched;
            TokensMatched     = tokensMatched;
        }
Пример #26
0
        public static GKTurnBasedMatchOutcome ToGKTurnBasedMatchOutcome(this MatchOutcome matchOutcome, string participantId)
        {
            var gkMatchOutcome = new GKTurnBasedMatchOutcome();
            var result         = matchOutcome.GetParticipantResult(participantId);
            var placement      = matchOutcome.GetParticipantPlacement(participantId);

            switch (result)
            {
            case ParticipantResult.CustomPlacement:
                gkMatchOutcome.outcome       = GKTurnBasedMatchOutcome.Outcome.Custom;
                gkMatchOutcome.customOutcome = placement;
                break;

            case ParticipantResult.Lost:
                gkMatchOutcome.outcome = GKTurnBasedMatchOutcome.Outcome.Lost;
                break;

            case ParticipantResult.None:
                gkMatchOutcome.outcome = GKTurnBasedMatchOutcome.Outcome.None;
                break;

            case ParticipantResult.Tied:
                gkMatchOutcome.outcome = GKTurnBasedMatchOutcome.Outcome.Tied;
                break;

            case ParticipantResult.Won:
                gkMatchOutcome.outcome = GKTurnBasedMatchOutcome.Outcome.Won;
                break;

            default:
                gkMatchOutcome.outcome = GKTurnBasedMatchOutcome.Outcome.None;
                break;
            }

            return(gkMatchOutcome);
        }
Пример #27
0
 public ITeam GetCompeditor(MatchOutcome position)
 {
     return(EndNodeTeam);
 }
Пример #28
0
 public void AddFinalist(INode node, MatchOutcome pos)
 {
     EndNodeFinalist = new FinalistData(node, pos);
 }
Пример #29
0
    private void RenderMatchResult(MatchState _matchState)
    {
        if (_matchState.Outcomes.Count <= 0)
        {
            return;
        }
        MatchOutcome lastOutcome = _matchState.Outcomes[_matchState.Outcomes.Count - 1];

        if (lastOutcome.P1_Scores && lastOutcome.P2_Scores)
        {
            m_spriteList.TXT_Draw.Active = true;
        }
        else if (lastOutcome.P1_Scores)
        {
            m_spriteList.TXT_Player1.Active = true;
            m_spriteList.TXT_Win.Active     = true;
        }
        else if (lastOutcome.P2_Scores)
        {
            m_spriteList.TXT_Player2.Active = true;
            m_spriteList.TXT_Win.Active     = true;
        }

        switch (lastOutcome.Outcome)
        {
        case GameplayEnums.Outcome.Counter:
            m_spriteList.TXT_Counterhit.Active = true;
            break;

        case GameplayEnums.Outcome.Shimmy:
            m_spriteList.TXT_Shimmy.Active = true;
            break;

        case GameplayEnums.Outcome.StrayHit:
            m_spriteList.TXT_StrayHit.Active = true;
            break;

        case GameplayEnums.Outcome.Throw:
            m_spriteList.TXT_Throw.Active = true;
            break;

        case GameplayEnums.Outcome.TimeOut:
            m_spriteList.TXT_Timeout.Active = true;
            break;

        case GameplayEnums.Outcome.Trade:
            m_spriteList.TXT_Trade.Active = true;
            break;

        case GameplayEnums.Outcome.WhiffPunish:
            m_spriteList.TXT_WhiffPunish.Active = true;
            break;

        case GameplayEnums.Outcome.Sweep:
            m_spriteList.TXT_Feet.Active = true;
            break;

        case GameplayEnums.Outcome.Punish:
            m_spriteList.TXT_Punish.Active = true;
            break;
        }
    }
 public void Finish(GooglePlayGames.BasicApi.Multiplayer.TurnBasedMatch match, byte[] data, MatchOutcome outcome, Action <bool> callback)
 {
     callback = Callbacks.AsOnGameThreadCallback(callback);
     FindEqualVersionMatch(match, callback, delegate(NativeTurnBasedMatch foundMatch)
     {
         GooglePlayGames.Native.PInvoke.ParticipantResults participantResults = foundMatch.Results();
         foreach (string participantId in outcome.ParticipantIds)
         {
             Types.MatchResult matchResult = ResultToMatchResult(outcome.GetResultFor(participantId));
             uint placementFor             = outcome.GetPlacementFor(participantId);
             if (participantResults.HasResultsForParticipant(participantId))
             {
                 Types.MatchResult matchResult2 = participantResults.ResultsForParticipant(participantId);
                 uint num = participantResults.PlacingForParticipant(participantId);
                 if (matchResult != matchResult2 || placementFor != num)
                 {
                     Logger.e($"Attempted to override existing results for participant {participantId}: Placing {num}, Result {matchResult2}");
                     callback(false);
                     return;
                 }
             }
             else
             {
                 GooglePlayGames.Native.PInvoke.ParticipantResults participantResults2 = participantResults;
                 participantResults = participantResults2.WithResult(participantId, placementFor, matchResult);
                 participantResults2.Dispose();
             }
         }
         mTurnBasedManager.FinishMatchDuringMyTurn(foundMatch, data, participantResults, delegate(TurnBasedManager.TurnBasedMatchResponse response)
         {
             callback(response.RequestSucceeded());
         });
     });
 }