Example #1
0
        public static Shot CreateShot(int playerShooting, Shot previousShot, Advantage advantage, ShotType previousShotType)
        {
            PlayerMatchInstance     player = MatchEngine.Instance.GetPlayer(playerShooting);
            ShotType                type   = GenerateShotTypeProbabilities(previousShot.type, player).Calculate();
            ShotCoord               from   = previousShot.to;
            ShotCoord               to     = CalculateShotCoord(GenerateShotCoordProbabilities(type, player));
            ShotResultProbabilities shotResultProbabilities = GenerateShotResultProbabilities(to, playerShooting, type, advantage, previousShotType);
            float shotTime = ShotTime.GetTimeForType(type, MatchEngine.Instance.MatchPreferences);

            return(new Shot(playerShooting, type, from, to, shotResultProbabilities, false, shotTime));
        }
Example #2
0
        public Point(Score score, PointHistory history)
        {
            shotHistory = new List <HistoryShot>();
            pointOver   = false;
            advantage   = new Advantage();

            //TODO TOSS RIGHT THERE
            if (history.FirstPoint())
            {
                currentPlayerServing = 0;
                Serve serve = ShotMaker.CreateServe(currentPlayerServing, score);
                currentShot = serve;
            }
            else
            {
                currentPlayerServing = history.GetLastPointWinner();
                Serve serve = ShotMaker.CreateServe(currentPlayerServing, score);
                currentShot = serve;
            }
        }
 private void UpdateAdvantageUI(Advantage advantage)
 {
     advantageBar.UpdateAdvantage(advantage);
 }
Example #4
0
        private static ShotResultProbabilities GenerateShotResultProbabilities(ShotCoord to, int playerShooting, ShotType type, Advantage advantage, ShotType previousShotType)
        {
            ShotResultProbabilities probabilities = ShotResultProbabilities.GetShotTypeResultProbabilities(type);

            ShotResultAttributesModification(ref probabilities, MatchEngine.Instance.GetPlayer(playerShooting), MatchEngine.Instance.GetOtherPlayer(playerShooting), type, previousShotType);
            ShotResultAdvantageModification(ref probabilities, playerShooting, advantage);
            ShotResultOpposingPlayerModification(ref probabilities, MatchEngine.Instance.GetPlayer(playerShooting), type);



            return(probabilities);
        }
Example #5
0
 private static void ShotResultAdvantageModification(ref ShotResultProbabilities probabilities, int playerShooting, Advantage advantage)
 {
     if (advantage.Player == playerShooting)
     {
         probabilities.AddCrit(ADVANTAGE_CRIT * advantage.Amount);
     }
     else
     {
         probabilities.AddFail(DISADVANTAGE_FAIL * advantage.Amount);
     }
 }
Example #6
0
 public void OnAdvantageUpdated(Advantage advantage)
 {
     advantageUpdatedEvent.Invoke(advantage);
 }