コード例 #1
0
        public static Dictionary <String, OffensivePlay> GetIFormTwoWRPassPlays()
        {
            Dictionary <String, OffensivePlay> retVal = new Dictionary <string, OffensivePlay>();

            RouteTypes[]  routes = new RouteTypes[] { RouteTypes.SLANT, RouteTypes.OUT, RouteTypes.GO, RouteTypes.PASS_BLOCK, RouteTypes.DRAG };
            OffensivePlay play   = new OffensivePlay(OffensivePlayType.PASS, null, routes);

            retVal.Add("Deep Pass", play);
            return(retVal);
        }
コード例 #2
0
ファイル: Field.cs プロジェクト: MatthewLDrake/FootballSim
        private static RouteTypes RunRoute(Player player, RouteTypes routeTypes)
        {
            double time = 0;

            routeTypes.ResetChanges();
            double maxSpeed     = GetMaxSpeed(player.GetSpeed());
            double acceleration = GetAcceleration(player.GetAcceleration());

            while (time < TIME_VAL)
            {
                double currSpeed         = routeTypes.CurrSpeed;
                double distanceTravelled = 0;
                if (maxSpeed == currSpeed)
                {
                    distanceTravelled = MetersToFeet(CalculateDistance(MPHtoMPS(currSpeed), TIME_VAL - time));
                }
                else
                {
                    distanceTravelled = MetersToFeet(CalculateDistance(MPHtoMPS(currSpeed), TIME_VAL - time, acceleration));
                    currSpeed         = MPStoMPH(CalculateFinalSpeed(MPHtoMPS(currSpeed), TIME_VAL - time, acceleration));
                }
                double distanceLeft = routeTypes.GetDistanceLeftOnCurrentBranch();

                if (distanceLeft == -1)
                {
                    routeTypes.Ended = true;
                    break;
                }

                if (distanceLeft > distanceTravelled)
                {
                    time = TIME_VAL;
                }
                else
                {
                    routeTypes.ChangeDirection();
                    double oldDistance = distanceTravelled;
                    distanceTravelled = distanceLeft;
                    if (maxSpeed == routeTypes.CurrSpeed)
                    {
                        time = CalculateTime(MPHtoMPS(maxSpeed), FeetToMeters(distanceTravelled));
                    }
                    else
                    {
                        double addedTime = CalculateTime(MPHtoMPS(routeTypes.CurrSpeed), FeetToMeters(distanceTravelled), acceleration);
                        time     += addedTime;
                        currSpeed = MPStoMPH(CalculateFinalSpeed(MPHtoMPS(currSpeed), addedTime, acceleration));
                    }
                }
                routeTypes.Location += distanceTravelled;
                routeTypes.CurrSpeed = currSpeed;
            }

            return(routeTypes);
        }
コード例 #3
0
ファイル: PlayType.cs プロジェクト: MatthewLDrake/FootballSim
 public RouteTypes(RouteTypes copy, int currLocationX, int currLocationY)
 {
     this.route         = new List <Tuple <Direction, int, bool> >(copy.route);
     this.currLocationX = currLocationX;
     this.currLocationY = currLocationY;
     location           = 0;
     currDirectionX     = 0;
     currDirectionY     = 0;
     currSpeed          = 0;
     ended = false;
     ChangeDirection(route[nextChange].Item1, route[nextChange].Item3);
     nextChange = 1;
 }
コード例 #4
0
ファイル: PlayType.cs プロジェクト: MatthewLDrake/FootballSim
        static RouteTypes()
        {
            List <Tuple <Direction, int, bool> > list = new List <Tuple <Direction, int, bool> >();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 60, true));
            GO = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FLAG, 60, true));
            FADE = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 20, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.MIDDLE, 20, true));
            IN = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 20, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.SIDE_LINE, 20, true));
            OUT = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 20, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.BACK, 1, true));
            CURL = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 0, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.MIDDLE, 6, false));
            list.Add(new Tuple <Direction, int, bool>(Direction.MIDDLE, 20, true));
            DRAG = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FLAG, 20, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.BACK, 1, true));
            BACK_CURL = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 3, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.MIDDLE, 15, false));
            SLANT = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.FORWARD, 15, true));
            list.Add(new Tuple <Direction, int, bool>(Direction.MIDDLE, 15, false));
            POST = new RouteTypes(list);
            list.Clear();

            list.Add(new Tuple <Direction, int, bool>(Direction.PASS_BLOCK, 0, true));
            PASS_BLOCK = new RouteTypes(list);
        }
コード例 #5
0
ファイル: Field.cs プロジェクト: MatthewLDrake/FootballSim
        public static int[][] TestRoute(Player player, RouteTypes type)
        {
            List <Tuple <int, int> > list = new List <Tuple <int, int> >();
            int lastX = 10, lastY = 10;

            list.Add(new Tuple <int, int>(lastX, lastY));
            RouteTypes testRoute = new RouteTypes(type, lastX, lastY);

            while (!testRoute.Ended)
            {
                testRoute = RunRoute(player, testRoute);
                lastX    += testRoute.ChangeInX;
                lastY    += testRoute.ChangeInY;
                list.Add(new Tuple <int, int>(lastX, lastY));
            }

            int[][] retVal = new int[list.Count][];
            for (int i = 0; i < list.Count; i++)
            {
                retVal[i] = new int[] { list[i].Item1, list[i].Item2 };
            }
            return(retVal);
        }