Beispiel #1
0
        public CheckPoint CreateCheckPoint(int number, Vector position, int size)
        {
            CheckPoint newCheckPoint;

            newCheckPoint = new CheckPoint(number, position, size);
            AddCheckPoint(newCheckPoint);

            return(newCheckPoint);
        }
Beispiel #2
0
        public CheckPoint GetNextCheckPoint(CheckPoint checkPoint)
        {
            int checkPointIndex;
            int nextCheckPointIndex;

            checkPointIndex     = checkPoints.IndexOf(checkPoint);
            nextCheckPointIndex = (checkPointIndex + 1) % checkPoints.Count;

            return(checkPoints[nextCheckPointIndex]);
        }
Beispiel #3
0
        private void InitPodRacer(int startingTeamIndex)
        {
            CheckPoint startFinishCheckPoint = Arena.GetStartFinish();
            CheckPoint firstTargetCheckPoint = Arena.GetNextCheckPoint(startFinishCheckPoint);
            double     maxPodSize            = PodRacers.Max(p => p.Size);

            double startingPositionOffset = 0;

            if (PodRacers.Count > 1)
            {
                double angleDelta = 2.0 * Math.PI / PodRacers.Count;
                double alpha      = Math.Sqrt(1.0 / (2.0 * (1 - Math.Cos(angleDelta))));
                startingPositionOffset = 2 * alpha * maxPodSize;

                startingPositionOffset += RaceRules.INITIAL_POSITION_OFFSET;
            }

            Vector startingPositionOffsetVector = new Vector(0, startingPositionOffset);

            double rotatingAngle = 360.0 / PodRacers.Count;

            int teamMaxPodCount = Teams.Max(t => t.PodRacers.Count);

            for (int podIndex = 0; podIndex < teamMaxPodCount; podIndex++)
            {
                int teamIndex = startingTeamIndex;
                for (int index = 0; index < Teams.Count; index++)
                {
                    if (podIndex < Teams[teamIndex].PodRacers.Count)
                    {
                        Teams[teamIndex].PodRacers[podIndex].Velocity = new Vector(0, 0);
                        Teams[teamIndex].PodRacers[podIndex].Position = startFinishCheckPoint.Position + startingPositionOffsetVector;
                        Teams[teamIndex].PodRacers[podIndex].Heading  = (firstTargetCheckPoint.Position - Teams[teamIndex].PodRacers[podIndex].Position).GetAngle();
                        Teams[teamIndex].PodRacers[podIndex].ConvertStateToInt();
                        startingPositionOffsetVector = startingPositionOffsetVector.Rotate(rotatingAngle);
                    }
                    teamIndex = (teamIndex + 1) % Teams.Count;
                }
            }
        }
Beispiel #4
0
 public void AddCheckPoint(CheckPoint checkPoint)
 {
     checkPoints.Add(checkPoint);
 }