/// <summary> /// Adds ball count. /// </summary> public static void AddBall(bool isHBP = false, bool isIBB = false) { if (isHBP) { InGameManager.currentPitcher.stats.SetStat(1, PlayerStatistics.PS.HB); InGameManager.currentBatter.stats.SetStat(1, PlayerStatistics.PS.HBP); BaseRunning.AdvanceRunner(1); ClearCount(); Debug.Log("HBP"); } else if (isIBB) { InGameManager.currentPitcher.stats.SetStat(1, PlayerStatistics.PS.IBB_PIT); InGameManager.currentBatter.stats.SetStat(1, PlayerStatistics.PS.IBB_BAT); BaseRunning.AdvanceRunner(1); ClearCount(); Debug.Log("IBB"); } else if (InGameManager.ballCount >= 3) { InGameManager.currentPitcher.stats.SetStat(1, PlayerStatistics.PS.BB_PIT); InGameManager.currentBatter.stats.SetStat(1, PlayerStatistics.PS.BB_BAT); BaseRunning.AdvanceRunner(1); ClearCount(); Debug.Log("BASE ON BALLS"); } else { InGameManager.ballCount++; Debug.Log("BALL"); } }
/// <summary> /// Conduct behaviours when a batter hit a ball in a common way. /// </summary> /// <param name="hit"></param> public static void AddHit(Hit hit, bool isITPHR = false) { //Clears count. AtPlate.ClearCount(); if (InGameManager.isBottom) { InGameManager.game.homeScoreBoard.H++; } else { InGameManager.game.awayScoreBoard.H++; } //Add AB by 1. InGameManager.currentBatter.stats.SetStat(1, PlayerStatistics.PS.AB); InGameManager.currentBatter.stats.SetStat(1, PlayerStatistics.PS.H_BAT); if (hit == Hit.SINGLE) { currentBatter.stats.SetStat(1, PlayerStatistics.PS.SIN); BaseRunning.AdvanceRunner(1); Debug.Log("SINGLE"); } else if (hit == Hit.DOUBLE) { currentBatter.stats.SetStat(1, PlayerStatistics.PS.DBL); BaseRunning.AdvanceRunner(2); Debug.Log("DOUBLE"); } else if (hit == Hit.TRIPLE) { currentBatter.stats.SetStat(1, PlayerStatistics.PS.TRP); BaseRunning.AdvanceRunner(3); Debug.Log("TRIPLE"); } else if (hit == Hit.HOME_RUN) { currentBatter.stats.SetStat(1, PlayerStatistics.PS.HR_BAT); if (isITPHR) { currentBatter.stats.SetStat(1, PlayerStatistics.PS.ITPHR); } BaseRunning.AdvanceRunner(4); Debug.Log("HOME RUN"); } //If inning is over 9 and walked off, finishes game. if (InGameManager.currentInning > 9 && InGameManager.isBottom && InGameManager.game.homeScoreBoard.R > InGameManager.game.awayScoreBoard.R) { Innings.EndGame(); } }
/// <summary> /// A single turn. /// </summary> public void Turn() { if (isUIEnabled) { //InningPanel InGameObjects.inningPanel.UpdateLayout(); //OutPanel InGameObjects.outPanelLayout.ClearLayout(); InGameObjects.outPanelLayout.UpdateLayout(); //BasePanel InGameObjects.basePanel.UpdateLayout(); InGameObjects.basePanel.UpdateStealing(); //ScorePanel InGameObjects.scorePanel.UpdateLayout(); //BoardPanel InGameObjects.boardPanel.UpdateLayout(); //Field_Condition InGameObjects.PlayerUIApply.SetPlayers(true); } //Initializes stealingAttempts array to false. for (int i = 0; i < 4; ++i) { stealingAttempts[i] = false; } //First, determine whether runners in bases attempt to steal base or not. for (int i = 1; i <= 3; ++i) { bool isBaseStealing = BaseRunning.BaseStealDetermine(runnerInBases[i], true); if (isBaseStealing) { Debug.Log("BASE " + i + "TRYING TO STEAL"); //If a runner is going to steal base, change stealingAttempt bool to true. stealingAttempts[i] = true; } } if (isUIEnabled) { //This is a stealingAttempts UI update. InGameObjects.basePanel.UpdateStealing(); } //Then, a pitcher determines whether pick off the ball or not. bool isPickedOff = PickingOff.PickOffDetermine(out int whichBase, true); if (isPickedOff) { Debug.Log("PICK OFF"); //If the pitcher picks off the ball, a pickoff function starts and control goes to ball in play. PickingOff.PickOff(-1, true); BallInPlay(BallInPlayMode.PICKOFF, true, whichBase); return; } else { //If not picked off, pitcher pitches, and sets wildpitch and hitbypitch bool variables. Pitching.Pitch(out bool isWildPitch, out bool isHitByPitch, true); if (isWildPitch) { Debug.Log("WILD PITCHED"); //If a pitcher wild pitched, control goes to ball in play. PitchedWild.WildPitch(currentPitcher); BallInPlay(BallInPlayMode.WILD_PITCH); return; } else { //If not wild pitched, determine wheter a batter swung or not. bool isSwung = AtPlate.SwingDetermine(true); if (isHitByPitch) { //If a batter got a hit-by-pitch ball, advances runner by 1 base, and the turn ends. AtPlate.AddBall(true); return; } else { //If not hit-by-pitch ball, check if a batter swung. if (isSwung) { Debug.Log("He Swings!"); //If swung, determine whether a swing hit or not. bool isHit = Hitting.HitDetermine(true); if (isHit) { //If hit, control goes to ball in play. BallInPlay(BallInPlayMode.NORMAL); return; } else { //If not hit, adds a strike. AtPlate.AddStrike(); return; } } else { //If not swung, determine whether a ball is strike or ball. bool isInStrike = Pitching.InStrikeZoneDetermine(true); if (isInStrike) { //If a ball is in strikezone, adds a strike. AtPlate.AddStrike(); return; } else { //If not in strikezone, adds a ball. AtPlate.AddBall(); return; } } } } } }