Beispiel #1
0
        public void ComputeShot()
        {
            currentPoint.ComputeCurrentShot();

            PlayerMatchInstance currentPMI = MatchEngine.Instance.GetPlayer(currentPoint.currentPlayerShooting);

            switch (currentPoint.currentShot.shotResult)
            {
            case ShotResult.CRIT:
                Debug.Log(currentPMI.Name() + " crits  a " + Shot.GetShotTypeName(currentPoint.currentShot.type) + " @" + currentPoint.currentShot.to.Coord + "!");
                currentPoint.advantage.AddAdvantage(currentPoint.currentPlayerShooting);
                eventReader.OnAdvantageUpdated(currentPoint.advantage);
                FieldShot(currentPoint.currentPlayerShooting, currentPoint.currentShot.from, currentPoint.currentShot.to, currentPoint.currentShot.type, currentPoint.currentShot.shotTime);
                eventReader.OnCritEvent(currentPoint.currentPlayerShooting);
                break;

            case ShotResult.FAIL:
                Debug.Log(currentPMI.Name() + " fails a " + Shot.GetShotTypeName(currentPoint.currentShot.type) + " @" + currentPoint.currentShot.to.Coord + "!");
                scoreManager.ScoreAgainst(currentPoint.currentPlayerShooting);
                FieldShot(currentPoint.currentPlayerShooting, currentPoint.currentShot.from, currentPoint.currentShot.to, currentPoint.currentShot.type, currentPoint.currentShot.shotTime);
                RefreshScoreRecap();
                currentPoint.pointOver = true;
                break;

            default:
                FieldShot(currentPoint.currentPlayerShooting, currentPoint.currentShot.from, currentPoint.currentShot.to, currentPoint.currentShot.type, currentPoint.currentShot.shotTime);
                Debug.Log(currentPMI.Name() + " returns a " + Shot.GetShotTypeName(currentPoint.currentShot.type) + " @" + currentPoint.currentShot.to.Coord + "!");
                break;
            }
        }
        void Awake()
        {
            // if the singleton hasn't been initialized yet
            if (instance != null && instance != this)
            {
                Destroy(this.gameObject);
            }

            instance = this;

            if (SaveData.CurrentMatchExists)
            {
                player = new PlayerMatchInstance(SaveData.current.playerSave);
                cpu    = new PlayerMatchInstance(SaveData.current.calendar.GetTournament().currentMatch.cpuPlayer);
            }
            else
            {
                player = new PlayerMatchInstance("JeanPlayer");
                cpu    = new PlayerMatchInstance("EdouardCPU");
            }

            pointHistory = new PointHistory();

            aIBehavior = new EasyAIBehavior(eventReader);
            StartGame();
        }
Beispiel #3
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));
        }
Beispiel #4
0
        public static Serve CreateServe(int playerShooting, Score score)
        {
            PlayerMatchInstance player = MatchEngine.Instance.GetPlayer(playerShooting);
            int       points           = GetPlayerServingPoints(playerShooting, score);
            ShotCoord from             = GetFromForServing(points);
            ShotCoord to   = GetToForServing(points);
            ShotType  type = ShotType.LONG;
            ShotResultProbabilities shotResultProbabilities = GenerateShotResultProbabilities(playerShooting, type);
            float shotTime = ShotTime.GetTimeForType(type, MatchEngine.Instance.MatchPreferences);

            return(new Serve(playerShooting, type, from, to, shotResultProbabilities, shotTime));
        }
Beispiel #5
0
        private static int GetCritFromAttribute(PlayerMatchInstance playerShooting, PlayerMatchInstance playerReceiving, ShotType shotType, ShotType previousShotType)
        {
            int atkDiff = GetFinalATKShotDifferential(playerShooting, playerReceiving, shotType, previousShotType);

            if (atkDiff >= 0)
            {
                return(atkDiff / 2);
            }
            else
            {
                return(atkDiff / 4);
            }
        }
Beispiel #6
0
        private static int GetPureATKShotDifferential(PlayerMatchInstance playerShooting, PlayerMatchInstance playerReceiving, ShotType shotType)
        {
            switch (shotType)
            {
            case ShotType.LONG:
                return(playerShooting.GetUsableStats().longATK - playerReceiving.GetUsableStats().longDEF);

            case ShotType.RUSH:
                return(playerShooting.GetUsableStats().rushATK - playerReceiving.GetUsableStats().rushDEF);

            case ShotType.SHORT:
                return(playerShooting.GetUsableStats().shortATK - playerReceiving.GetUsableStats().shortDEF);

            case ShotType.SMASH:
                return(playerShooting.GetUsableStats().smashATK - playerReceiving.GetUsableStats().smashDEF);
            }
            return(0);
        }
Beispiel #7
0
        private static int GetDEFShotDifferential(PlayerMatchInstance playerShooting, PlayerMatchInstance playerReceiving, ShotType shotType)
        {
            switch (shotType)
            {
            case ShotType.LONG:
                //if -0, return 0;
                return(Math.Max(playerReceiving.GetUsableStats().longDEF - playerShooting.GetUsableStats().longATK, 0));

            case ShotType.RUSH:
                return(Math.Max(playerReceiving.GetUsableStats().rushDEF - playerShooting.GetUsableStats().rushATK, 0));

            case ShotType.SHORT:
                return(Math.Max(playerReceiving.GetUsableStats().shortDEF - playerShooting.GetUsableStats().shortATK, 0));

            case ShotType.SMASH:
                return(Math.Max(playerReceiving.GetUsableStats().smashDEF - playerShooting.GetUsableStats().smashATK, 0));
            }
            return(0);
        }
 private void Awake()
 {
     player = MatchEngine.Instance.GetPlayer(0);
 }
Beispiel #9
0
 private static void ShotResultAttributesModification(ref ShotResultProbabilities probabilities, PlayerMatchInstance playerShooting, PlayerMatchInstance playerDefending, ShotType shotType, ShotType previousShotType)
 {
     probabilities.AddCrit(GetCritFromAttribute(playerShooting, playerDefending, shotType, previousShotType));
     //You calculate the difference between the atk of the atking player and the def of the defing player
 }
Beispiel #10
0
 public static void ShotTypePlaystyleModification(ref ShotTypeProbabilities shotTypeProbabilities, PlayerMatchInstance shootingPlayer)
 {
     shotTypeProbabilities.MergeWith(shootingPlayer.GetCurrentPlaystyle().shotTypeProbabilities);
 }
Beispiel #11
0
        //------------------------------------------------------------------------------------------------------------------
        //                                                  SHOT TYPES
        //------------------------------------------------------------------------------------------------------------------

        public static ShotTypeProbabilities GenerateShotTypeProbabilities(ShotType previousType, PlayerMatchInstance player)
        {
            ShotTypeProbabilities shotTypeProbabilities = ShotTypeProbabilities.GetShotTypeProbabilitiesFollowing(previousType);

            ShotTypePlaystyleModification(ref shotTypeProbabilities, player);
            return(shotTypeProbabilities);
        }
Beispiel #12
0
        //------------------------------------------------------------------------------------------------------------------
        //                                                  SHOT COORDS
        //------------------------------------------------------------------------------------------------------------------

        public static ShotCoordProbabilities GenerateShotCoordProbabilities(ShotType type, PlayerMatchInstance player)
        {
            ShotCoordProbabilities shotTypeTendencies = GetCoordTendencies(type);

            ShotCoordProbabilities playerTendencies = player.ShotCoordTendencies();

            ShotCoordProbabilities resultingTendencies = ShotCoordProbabilities.Multiply(shotTypeTendencies, playerTendencies);

            return(resultingTendencies);
        }
Beispiel #13
0
        private static void ShotResultOpposingPlayerModification(ref ShotResultProbabilities probabilities, PlayerMatchInstance playerAttacking, ShotType type)
        {
            // Now it's probably going to be where you put all the effects from the previous attack of the other player such as:
            // "After my smashes, your next attack is worst" or something like that

            //This is where you put the opposing player's defensive traits effect like
            //"The smashes against me are less strong" or something like this.
        }
Beispiel #14
0
 private static int GetFinalATKShotDifferential(PlayerMatchInstance playerShooting, PlayerMatchInstance playerReceiving, ShotType shotType, ShotType previousShotType)
 {
     return(GetPureATKShotDifferential(playerShooting, playerReceiving, shotType) + (GetDEFShotDifferential(playerReceiving, playerShooting, previousShotType) / 2));
 }