private DefensivePlay ChooseDefensivePlay(Formation formation) { DefensiveFormation defense = PlayBook.GetInstance().fourThree; return(defense.GetPlay("Man Two Under")); // TODO: Implement coach playcalling logic }
private void SetUpPlay(int lineToGain, OffensivePlay offense, DefensivePlay defense, bool teamOnePossesion) { OffensiveFormation offensiveFormation = offense.GetFormation() as OffensiveFormation; offensivePlayers = offensiveFormation.GetPlayers(teamOnePossesion ? teamOne.GetDepthChart() : teamTwo.GetDepthChart()); DefensiveFormation defensiveFormation = defense.GetFormation() as DefensiveFormation; defensivePlayers = defensiveFormation.GetPlayers(teamOnePossesion ? teamTwo.GetDepthChart() : teamOne.GetDepthChart()); offensivePlayerLocations = new Tuple <int, int> [11]; defensivePlayerLocations = new Tuple <int, int> [11]; for (int i = 0; i < offensivePlayerLocations.Length; i++) { offensivePlayerLocations[i] = new Tuple <int, int>(-1, -1); defensivePlayerLocations[i] = new Tuple <int, int>(-1, -1); } int midPoint = ball.GetWidth(); int lineOfScrimmage = ball.GetLength(); field[lineOfScrimmage, midPoint] = 4; offensivePlayerLocations[3] = new Tuple <int, int>(lineOfScrimmage, midPoint); field[lineOfScrimmage, midPoint - 3] = 3; field[lineOfScrimmage, midPoint - 6] = 2; field[lineOfScrimmage, midPoint + 3] = 5; field[lineOfScrimmage, midPoint + 6] = 6; EligibleRecieverLayout[] locations = offensiveFormation.GetLocations(); List <int> leftTEs = new List <int>(), rightTEs = new List <int>(), leftWRs = new List <int>(), rightWRs = new List <int>(); if (offensiveFormation.GetShotGun()) { field[lineOfScrimmage - 15, midPoint] = 1; for (int i = 0; i < locations.Length; i++) { if (locations[i].GetLocation() == EligibleLocation.BACKFIELD) { if (locations[i].GetLeft()) { field[lineOfScrimmage - 15, midPoint - 3] = 7 + i; } else { field[lineOfScrimmage - 15, midPoint + 3] = 7 + i; } } else { if (locations[i].GetPosition() == (int)Constants.WR) { if (locations[i].GetLeft()) { leftWRs.Add(i); } else { rightWRs.Add(i); } } else { if (locations[i].GetLeft()) { leftTEs.Add(i); } else { rightTEs.Add(i); } } } } } else { field[lineOfScrimmage - 3, midPoint] = 1; for (int i = 0; i < locations.Length; i++) { if (locations[i].GetLocation() == EligibleLocation.BACKFIELD || locations[i].GetLocation() == EligibleLocation.CENTER_BACKFIELD) { int playerMidPoint; if (locations[i].GetLocation() == EligibleLocation.CENTER_BACKFIELD) { playerMidPoint = midPoint; } else if (locations[i].GetLeft()) { playerMidPoint = midPoint - 3; } else { playerMidPoint = midPoint + 3; } int playerLine; if (locations[i].GetPosition() == 1) { playerLine = lineOfScrimmage - 15; } else { playerLine = lineOfScrimmage - 9; } field[playerLine, playerMidPoint] = 7 + i; } else { if (locations[i].GetPosition() == (int)Constants.WR) { if (locations[i].GetLeft()) { leftWRs.Add(i); } else { rightWRs.Add(i); } } else { if (locations[i].GetLeft()) { leftTEs.Add(i); } else { rightTEs.Add(i); } } } } } for (int i = 0; i < leftTEs.Count; i++) { int playerMidPoint = midPoint - (i * 3 + 9); int playerLine; if (locations[leftTEs[i]].GetLocation() == EligibleLocation.ON_LINE) { playerLine = lineOfScrimmage; } else { playerLine = lineOfScrimmage - 2; } field[playerLine, playerMidPoint] = 7 + leftTEs[i]; } for (int i = 0; i < rightTEs.Count; i++) { int playerMidPoint = midPoint + (i * 3 + 9); int playerLine; if (locations[rightTEs[i]].GetLocation() == EligibleLocation.ON_LINE) { playerLine = lineOfScrimmage; } else { playerLine = lineOfScrimmage - 2; } field[playerLine, playerMidPoint] = 7 + rightTEs[i]; } for (int i = 0; i < leftWRs.Count; i++) { int num = i + 1; int playerMidPoint = (num * midPoint) / (leftWRs.Count + 1);//(num * midPoint) / (leftWRs.Count + num); int playerLine; if (locations[leftWRs[i]].GetLocation() == EligibleLocation.ON_LINE) { playerLine = lineOfScrimmage; } else { playerLine = lineOfScrimmage - 2; } field[playerLine, playerMidPoint] = 7 + leftWRs[i]; } for (int i = 0; i < rightWRs.Count; i++) { int num = i + 1; int playerMidPoint = midPoint + (num * ((160 - midPoint)) / (rightWRs.Count + 1)); int playerLine; if (locations[rightWRs[i]].GetLocation() == EligibleLocation.ON_LINE) { playerLine = lineOfScrimmage; } else { playerLine = lineOfScrimmage - 2; } field[playerLine, playerMidPoint] = 7 + rightWRs[i]; } File.WriteAllText(fileName + ".txt", field.ToString()); fileName++; }
private PlayBook() { iFormTwoWR = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.FB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.TE, true, EligibleLocation.ON_LINE) }, PassPlays.GetIFormTwoWRPassPlays()); iFormTwoTE = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.FB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.TE, false, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.TE, true, EligibleLocation.ON_LINE) }, new Dictionary <String, OffensivePlay>() ); iFormTwinTE = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.FB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.TE, false, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.TE, false, EligibleLocation.OFF_LINE) }, new Dictionary <String, OffensivePlay>() ); singleBackFourWR = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.ON_LINE) }, new Dictionary <String, OffensivePlay>() ); singleBackBunch = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.OFF_LINE, (int)Constants.TE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.ON_LINE) }, new Dictionary <String, OffensivePlay>() ); singleBackTwoTE = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.TE, true, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.WR, true, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.TE, false, EligibleLocation.ON_LINE) }, new Dictionary <String, OffensivePlay>() ); singleBackTwinTE = new OffensiveFormation(new EligibleRecieverLayout[] { new EligibleRecieverLayout((int)Constants.HB, false, EligibleLocation.CENTER_BACKFIELD), new EligibleRecieverLayout((int)Constants.TE, true, EligibleLocation.ON_LINE), new EligibleRecieverLayout((int)Constants.TE, true, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.OFF_LINE), new EligibleRecieverLayout((int)Constants.WR, false, EligibleLocation.ON_LINE) }, new Dictionary <String, OffensivePlay>() ); fourThree = new DefensiveFormation(2, 2, 3, 2, 2); fourFour = new DefensiveFormation(2, 1, 4, 2, 2); threeFour = new DefensiveFormation(2, 2, 4, 2, 1); nickel = new DefensiveFormation(3, 2, 2, 2, 2); threeThreeFive = new DefensiveFormation(3, 2, 3, 2, 1); twoFourFive = new DefensiveFormation(3, 2, 4, 2, 0); nickelStrong = new DefensiveFormation(2, 3, 2, 2, 2); threeTwoSix = new DefensiveFormation(4, 2, 2, 2, 1); dime = new DefensiveFormation(4, 2, 1, 2, 2); quarter = new DefensiveFormation(5, 2, 1, 2, 1); goalline = new DefensiveFormation(2, 1, 3, 2, 3); }
private void RunPlay(Play player, OffensiveFormation offense, DefensiveFormation defense) { Field field = Field.GetInstance(); }