/// <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> /// Advances inning. /// </summary> public static void AdvanceInning() { //Innings pitched InGameManager.currentPitcher.stats.SetStat(0.7f, PlayerStatistics.PS.IP); //If the game satisfies the end condition, end game. if ((InGameManager.game.homeScoreBoard.R != InGameManager.game.awayScoreBoard.R) && InGameManager.currentInning >= 9 && (InGameManager.isBottom || InGameManager.game.homeScoreBoard.R > InGameManager.game.awayScoreBoard.R)) { EndGame(); return; } if (InGameManager.isUIEnabled) { //BoardPanel UI. InGameObjects InGameObjects = GameObject.Find("InGameManager").GetComponent <InGameObjects>(); InGameObjects.boardPanel.AddScorePanel(); } //Switch side. Pitcher tempPitcher = InGameManager.currentPitcher; InGameManager.currentPitcher = InGameManager.otherPitcher; InGameManager.otherPitcher = tempPitcher; if (InGameManager.currentAttack == InGameManager.game.home) { InGameManager.currentAttack = InGameManager.game.away; InGameManager.currentDefend = InGameManager.game.home; InGameManager.currentBatter = InGameManager.awayBattingOrder[InGameManager.awayCurrentBattersIndex]; } else if (InGameManager.currentAttack == InGameManager.game.away) { InGameManager.currentAttack = InGameManager.game.home; InGameManager.currentDefend = InGameManager.game.away; InGameManager.currentBatter = InGameManager.homeBattingOrder[InGameManager.homeCurrentBattersIndex]; } else { throw new System.NullReferenceException("Error: There is no appropriate team matching. Check currentAttack and Game instance again."); } if (InGameManager.isBottom) { InGameManager.isBottom = false; InGameManager.currentInning++; } else { InGameManager.isBottom = true; } for (int i = 0; i < 4; ++i) { InGameManager.runnerInBases[i] = null; } InGameManager.outCount = 0; AtPlate.ClearCount(); //UI if (InGameManager.isUIEnabled) { InGameObjects InGameObjects = GameObject.Find("InGameManager").GetComponent <InGameObjects>(); InGameObjects.PlayerUIApply.SetPlayers(); } }